-Added ldap, lber and ntml headers

git-svn-id: trunk@4632 -
This commit is contained in:
ivost 2006-09-17 13:06:51 +00:00
parent 71f0936a33
commit e01ebfc345
12 changed files with 5111 additions and 9 deletions

9
.gitattributes vendored
View File

@ -2919,6 +2919,15 @@ packages/extra/imlib/fpmake.inc svneol=native#text/plain
packages/extra/imlib/fpmake.pp svneol=native#text/plain
packages/extra/imlib/gdk_imlib/gdk_imlib.pp svneol=native#text/plain
packages/extra/imlib/imlib/imlib.pp svneol=native#text/plain
packages/extra/ldap/Makefile svneol=native#text/plain
packages/extra/ldap/lber.pas svneol=native#text/plain
packages/extra/ldap/lber_typesh.inc svneol=native#text/plain
packages/extra/ldap/lberh.inc svneol=native#text/plain
packages/extra/ldap/ldap.pas svneol=native#text/plain
packages/extra/ldap/ldap_featuresh.inc svneol=native#text/plain
packages/extra/ldap/ldap_schemah.inc svneol=native#text/plain
packages/extra/ldap/ldaph.inc svneol=native#text/plain
packages/extra/ldap/ntlm.pas svneol=native#text/plain
packages/extra/libgd/Makefile svneol=native#text/plain
packages/extra/libgd/Makefile.fpc svneol=native#text/plain
packages/extra/libgd/README -text

View File

@ -1,5 +1,5 @@
#
# Don't edit, this file is generated by FPCMake Version 2.0.0 [2006/09/14]
# Don't edit, this file is generated by FPCMake Version 2.0.0 [2006/09/16]
#
default: all
MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos sparc-linux sparc-netbsd sparc-solaris x86_64-linux x86_64-freebsd x86_64-win64 arm-linux arm-palmos arm-wince arm-gba powerpc64-linux
@ -231,7 +231,7 @@ UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
endif
PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
ifeq ($(FULL_TARGET),i386-linux)
override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 unixutil
override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 ldap unixutil
endif
ifeq ($(FULL_TARGET),i386-go32v2)
override TARGET_DIRS+=unzip
@ -270,7 +270,7 @@ ifeq ($(FULL_TARGET),i386-wince)
override TARGET_DIRS+=unzip zlib tcl fftw
endif
ifeq ($(FULL_TARGET),m68k-linux)
override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4
override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 ldap
endif
ifeq ($(FULL_TARGET),m68k-freebsd)
override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 md4
@ -288,7 +288,7 @@ ifeq ($(FULL_TARGET),m68k-palmos)
override TARGET_DIRS+=palmunits
endif
ifeq ($(FULL_TARGET),powerpc-linux)
override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4
override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 ldap
endif
ifeq ($(FULL_TARGET),powerpc-netbsd)
override TARGET_DIRS+=unzip zlib x11 opengl gtk syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 md4
@ -300,7 +300,7 @@ ifeq ($(FULL_TARGET),powerpc-darwin)
override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 univint
endif
ifeq ($(FULL_TARGET),sparc-linux)
override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4
override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 ldap
endif
ifeq ($(FULL_TARGET),sparc-netbsd)
override TARGET_DIRS+=unzip zlib x11 opengl gtk syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 md4
@ -309,7 +309,7 @@ ifeq ($(FULL_TARGET),sparc-solaris)
override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1
endif
ifeq ($(FULL_TARGET),x86_64-linux)
override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4
override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 ldap
endif
ifeq ($(FULL_TARGET),x86_64-freebsd)
override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 md4
@ -318,7 +318,7 @@ ifeq ($(FULL_TARGET),x86_64-win64)
override TARGET_DIRS+=unzip opengl gtk gtk2 zlib tcl cdrom fpgtk winunits fftw md4
endif
ifeq ($(FULL_TARGET),arm-linux)
override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4
override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 ldap
endif
ifeq ($(FULL_TARGET),arm-palmos)
override TARGET_DIRS+=palmunits
@ -327,7 +327,7 @@ ifeq ($(FULL_TARGET),arm-wince)
override TARGET_DIRS+=unzip zlib tcl fftw
endif
ifeq ($(FULL_TARGET),powerpc64-linux)
override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4
override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 ldap
endif
override INSTALL_FPCPACKAGE=y
override INSTALL_FPCSUBDIR=packages/extra
@ -1419,6 +1419,7 @@ TARGET_DIRS_FPGTK=1
TARGET_DIRS_NEWT=1
TARGET_DIRS_UUID=1
TARGET_DIRS_MD4=1
TARGET_DIRS_LDAP=1
TARGET_DIRS_UNIXUTIL=1
endif
ifeq ($(FULL_TARGET),i386-go32v2)
@ -1616,6 +1617,7 @@ TARGET_DIRS_FPGTK=1
TARGET_DIRS_NEWT=1
TARGET_DIRS_UUID=1
TARGET_DIRS_MD4=1
TARGET_DIRS_LDAP=1
endif
ifeq ($(FULL_TARGET),m68k-freebsd)
TARGET_DIRS_UNZIP=1
@ -1717,6 +1719,7 @@ TARGET_DIRS_FPGTK=1
TARGET_DIRS_NEWT=1
TARGET_DIRS_UUID=1
TARGET_DIRS_MD4=1
TARGET_DIRS_LDAP=1
endif
ifeq ($(FULL_TARGET),powerpc-netbsd)
TARGET_DIRS_UNZIP=1
@ -1793,6 +1796,7 @@ TARGET_DIRS_FPGTK=1
TARGET_DIRS_NEWT=1
TARGET_DIRS_UUID=1
TARGET_DIRS_MD4=1
TARGET_DIRS_LDAP=1
endif
ifeq ($(FULL_TARGET),sparc-netbsd)
TARGET_DIRS_UNZIP=1
@ -1865,6 +1869,7 @@ TARGET_DIRS_FPGTK=1
TARGET_DIRS_NEWT=1
TARGET_DIRS_UUID=1
TARGET_DIRS_MD4=1
TARGET_DIRS_LDAP=1
endif
ifeq ($(FULL_TARGET),x86_64-freebsd)
TARGET_DIRS_UNZIP=1
@ -1929,6 +1934,7 @@ TARGET_DIRS_FPGTK=1
TARGET_DIRS_NEWT=1
TARGET_DIRS_UUID=1
TARGET_DIRS_MD4=1
TARGET_DIRS_LDAP=1
endif
ifeq ($(FULL_TARGET),arm-palmos)
TARGET_DIRS_PALMUNITS=1
@ -1965,6 +1971,7 @@ TARGET_DIRS_FPGTK=1
TARGET_DIRS_NEWT=1
TARGET_DIRS_UUID=1
TARGET_DIRS_MD4=1
TARGET_DIRS_LDAP=1
endif
ifdef TARGET_DIRS_UNZIP
unzip_all:
@ -3091,6 +3098,51 @@ md4:
$(MAKE) -C md4 all
.PHONY: md4_all md4_debug md4_smart md4_release md4_units md4_examples md4_shared md4_install md4_sourceinstall md4_exampleinstall md4_distinstall md4_zipinstall md4_zipsourceinstall md4_zipexampleinstall md4_zipdistinstall md4_clean md4_distclean md4_cleanall md4_info md4_makefiles md4
endif
ifdef TARGET_DIRS_LDAP
ldap_all:
$(MAKE) -C ldap all
ldap_debug:
$(MAKE) -C ldap debug
ldap_smart:
$(MAKE) -C ldap smart
ldap_release:
$(MAKE) -C ldap release
ldap_units:
$(MAKE) -C ldap units
ldap_examples:
$(MAKE) -C ldap examples
ldap_shared:
$(MAKE) -C ldap shared
ldap_install:
$(MAKE) -C ldap install
ldap_sourceinstall:
$(MAKE) -C ldap sourceinstall
ldap_exampleinstall:
$(MAKE) -C ldap exampleinstall
ldap_distinstall:
$(MAKE) -C ldap distinstall
ldap_zipinstall:
$(MAKE) -C ldap zipinstall
ldap_zipsourceinstall:
$(MAKE) -C ldap zipsourceinstall
ldap_zipexampleinstall:
$(MAKE) -C ldap zipexampleinstall
ldap_zipdistinstall:
$(MAKE) -C ldap zipdistinstall
ldap_clean:
$(MAKE) -C ldap clean
ldap_distclean:
$(MAKE) -C ldap distclean
ldap_cleanall:
$(MAKE) -C ldap cleanall
ldap_info:
$(MAKE) -C ldap info
ldap_makefiles:
$(MAKE) -C ldap makefiles
ldap:
$(MAKE) -C ldap all
.PHONY: ldap_all ldap_debug ldap_smart ldap_release ldap_units ldap_examples ldap_shared ldap_install ldap_sourceinstall ldap_exampleinstall ldap_distinstall ldap_zipinstall ldap_zipsourceinstall ldap_zipexampleinstall ldap_zipdistinstall ldap_clean ldap_distclean ldap_cleanall ldap_info ldap_makefiles ldap
endif
ifdef TARGET_DIRS_UNIXUTIL
unixutil_all:
$(MAKE) -C unixutil all

View File

@ -6,7 +6,7 @@ dirs_linux=unzip zlib fftw \
x11 opengl gtk gtk2 syslog \
forms svgalib ggi libpng libgd \
utmp bfd gdbm ncurses tcl cdrom \
imlib gnome1 fpgtk newt uuid md4
imlib gnome1 fpgtk newt uuid md4 ldap
dirs_i386_linux=unixutil
dirs_netbsd=unzip zlib \
x11 opengl gtk syslog \

1828
packages/extra/ldap/Makefile Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,94 @@
unit lber;
{$mode objfpc}
interface
{$linklib lber}
{$include lber_typesh.inc}
{$include lberh.inc}
implementation
function LBER_INVALID(t: ber_tag_t): ber_tag_t;
// #define LBER_INVALID(t) (((t) & (ber_tag_t) = $080UL) && (((t) & (ber_tag_t) ~ = $0FF))
begin
LBER_INVALID := (t and $80) and (t and $FF);
end;
function LBER_OPT_ON: Pointer;
// #define LBER_OPT_ON ((void *) &ber_pvt_opt_on)
begin
LBER_OPT_ON := @ber_pvt_opt_on;
end;
function LBER_SBIOD_READ_NEXT(sbiod: PSockbuf_IO_Desc; buf: Pointer; len: ber_len_t): ber_slen_t;
// #define LBER_SBIOD_READ_NEXT( sbiod, buf, len ) ( (sbiod)->sbiod_next->sbiod_io->sbi_read( (sbiod)->sbiod_next, buf, len ) )
begin
LBER_SBIOD_READ_NEXT := sbiod^.sbiod_next^.sbiod_io^.sbi_read(sbiod^.sbiod_next, buf, len);
end;
function LBER_SBIOD_WRITE_NEXT(sbiod: PSockbuf_IO_Desc; buf: Pointer; len: ber_len_t): ber_slen_t;
// #define LBER_SBIOD_WRITE_NEXT( sbiod, buf, len ) ( (sbiod)->sbiod_next->sbiod_io->sbi_write( (sbiod)->sbiod_next, buf, len ) )
begin
LBER_SBIOD_WRITE_NEXT := sbiod^.sbiod_next^.sbiod_io^.sbi_write(sbiod^.sbiod_next, buf, len);
end;
function LBER_SBIOD_CTRL_NEXT(sbiod: PSockbuf_IO_Desc; opt: cint; arg: Pointer): cint;
// #define LBER_SBIOD_CTRL_NEXT( sbiod, opt, arg ) ( (sbiod)->sbiod_next ? ( (sbiod)->sbiod_next->sbiod_io->sbi_ctrl( (sbiod)->sbiod_next, opt, arg ) ) : 0 )
begin
if Assigned(sbiod^.sbiod_next) then
LBER_SBIOD_CTRL_NEXT := sbiod^.sbiod_next^.sbiod_io^.sbi_ctrl(sbiod^.sbiod_next, opt, arg) else
LBER_SBIOD_CTRL_NEXT := 0;
end;
function ber_bvstr(const str: PChar): PBerval;
begin
ber_bvstr := ber_str2bv(str, 0, false, nil);
end;
function ber_bvstrdup(const str: PChar): PBerval;
begin
ber_bvstrdup := ber_str2bv(str, 0, true, nil);
end;
function memcmp(p1, p2: Pointer; len: cint): cint;
var
I: cint;
begin
for I := 0 to len -1 do
begin
if pbyte(p1)^ < pbyte(p2)^ then
begin
memcmp := -1;
Exit;
end;
if pbyte(p1)^ > pbyte(p2)^ then
begin
memcmp := 1;
Exit;
end;
inc(p1, 1);
inc(p2, 1);
end;
memcmp := 0;
end;
function ber_bvcmp(v1, v2: PBerval): cint;
// #define ber_bvcmp(v1,v2) ((v1)->bv_len < (v2)->bv_len ? -1 : ((v1)->bv_len > (v2)->bv_len ? 1 : memcmp((v1)->bv_val, (v2)->bv_val, (v1)->bv_len) ))
begin
if v1^.bv_len < v2^.bv_len then ber_bvcmp := -1 else
if v1^.bv_len > v2^.bv_len then ber_bvcmp := 1 else
ber_bvcmp := memcmp(v1^.bv_val, v2^.bv_val, v1^.bv_len);
end;
function ber_errno: cint;
begin
ber_errno := ber_errno_addr^;
end;
end.

View File

@ -0,0 +1,66 @@
(* include/lber_types.h. Generated by configure. *)
(* $OpenLDAP: pkg/ldap/include/lber_types.h.in,v 1.10.2.3 2005/01/20 17:00:58 kurt Exp $ *)
(* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2005 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*)
(*
* LBER types
*)
uses
ctypes;
type
PPPChar = ^PPChar;
(* LBER Boolean, enum, integers (32 bits or larger) *)
LBER_INT_T = cint;
(* LBER tags (32 bits or larger) *)
LBER_TAG_T = clong;
(* LBER socket descriptor *)
LBER_SOCKET_T = cint;
(* LBER lengths (32 bits or larger) *)
LBER_LEN_T = clong;
(* ------------------------------------------------------------ *)
(* Booleans, enumerations, and integers *)
pber_int_t = ^ber_int_t;
ber_int_t = cint; // LBER_INT_T;
(* signed and unsigned versions *)
pber_sint_t = ^ber_sint_t;
ber_sint_t = csint; // signed LBER_INT_T
pber_uint_t = ^ber_uint_t;
ber_uint_t = cuint; // unsigned LBER_INT_T
(* tags *)
pber_tag_t = ^ber_tag_t;
ber_tag_t = culong; // unsigned LBER_TAG_T
(* "socket" descriptors *)
pber_socket_t = ^ber_socket_t;
ber_socket_t = cint; // LBER_SOCKET_T
(* lengths *)
pber_len_t = ^ber_len_t;
ber_len_t = culong; // unsigned LBER_LEN_T
(* signed lengths *)
pber_slen_t = ^ber_slen_t;
ber_slen_t = clong; // signed LBER_LEN_T;

View File

@ -0,0 +1,427 @@
(* $OpenLDAP: pkg/ldap/include/lber.h,v 1.83.2.11 2005/01/20 17:00:58 kurt Exp $ *)
(* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2005 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*)
(* Portions Copyright (c) 1990 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*)
(* Overview of LBER tag construction
*
* Bits
* ______
* 8 7 | CLASS
* 0 0 = UNIVERSAL
* 0 1 = APPLICATION
* 1 0 = CONTEXT-SPECIFIC
* 1 1 = PRIVATE
* _____
* | 6 | DATA-TYPE
* 0 = PRIMITIVE
* 1 = CONSTRUCTED
* ___________
* | 5 ... 1 | TAG-NUMBER
*)
const
(* BER classes and mask *)
LBER_CLASS_UNIVERSAL = ber_tag_t($00);
LBER_CLASS_APPLICATION = ber_tag_t($40);
LBER_CLASS_CONTEXT = ber_tag_t($80);
LBER_CLASS_PRIVATE = ber_tag_t($c0);
LBER_CLASS_MASK = ber_tag_t($c0);
(* BER encoding type and mask *)
LBER_PRIMITIVE = ber_tag_t($00);
LBER_CONSTRUCTED = ber_tag_t($20);
LBER_ENCODING_MASK = ber_tag_t($20);
LBER_BIG_TAG_MASK = ber_tag_t($1f);
LBER_MORE_TAG_MASK = ber_tag_t($80);
(*
* Note that LBER_ERROR and LBER_DEFAULT are values that can never appear
* as valid BER tags, and so it is safe to use them to report errors. In
* fact, any tag for which the following is true is invalid:
*)
function LBER_INVALID(t: ber_tag_t): ber_tag_t;
const
LBER_ERROR = ber_tag_t(-1);
LBER_DEFAULT = ber_tag_t(-1);
(* general BER types we know about *)
LBER_BOOLEAN = ber_tag_t($01);
LBER_INTEGER = ber_tag_t($02);
LBER_BITSTRING = ber_tag_t($03);
LBER_OCTETSTRING = ber_tag_t($04);
LBER_NULL = ber_tag_t($05);
LBER_ENUMERATED = ber_tag_t($0a);
LBER_SEQUENCE = ber_tag_t($30); (* constructed *)
LBER_SET = ber_tag_t($31); (* constructed *)
(* LBER BerElement options *)
LBER_USE_DER = $01;
(* get/set options for BerElement *)
LBER_OPT_BER_OPTIONS = $01;
LBER_OPT_BER_DEBUG = $02;
LBER_OPT_BER_REMAINING_BYTES = $03;
LBER_OPT_BER_TOTAL_BYTES = $04;
LBER_OPT_BER_BYTES_TO_WRITE = $05;
LBER_OPT_BER_MEMCTX = $06;
LBER_OPT_DEBUG_LEVEL = LBER_OPT_BER_DEBUG;
LBER_OPT_REMAINING_BYTES = LBER_OPT_BER_REMAINING_BYTES;
LBER_OPT_TOTAL_BYTES = LBER_OPT_BER_TOTAL_BYTES;
LBER_OPT_BYTES_TO_WRITE = LBER_OPT_BER_BYTES_TO_WRITE;
LBER_OPT_LOG_PRINT_FN = $8001;
LBER_OPT_MEMORY_FNS = $8002;
LBER_OPT_ERROR_FN = $8003;
LBER_OPT_LOG_PRINT_FILE = $8004;
(* get/set Memory Debug options *)
LBER_OPT_MEMORY_INUSE = $8005; (* for memory debugging *)
LBER_OPT_LOG_PROC = $8006; (* for external logging function *)
type
BER_ERRNO_FN = function: pcint; cdecl;
BER_LOG_PRINT_FN = procedure(const buf: PChar); cdecl;
BER_MEMALLOC_FN = function(size: ber_len_t): Pointer; cdecl;
BER_MEMCALLOC_FN = function(n: ber_len_t; size: ber_len_t): Pointer; cdecl;
BER_MEMREALLOC_FN = function(p: Pointer; size: ber_len_t): Pointer; cdecl;
BER_MEMFREE_FN = function(p: Pointer): Pointer; cdecl;
plber_memory_fns = ^lber_memory_fns;
lber_memory_fns = record
bmf_malloc : BER_MEMALLOC_FN;
bmf_calloc : BER_MEMCALLOC_FN;
bmf_realloc : BER_MEMREALLOC_FN;
bmf_free : BER_MEMFREE_FN;
end;
PBerMemoryFunctions = ^BerMemoryFunctions;
BerMemoryFunctions = lber_memory_fns;
const
(* LBER Sockbuf_IO options *)
LBER_SB_OPT_GET_FD = 1;
LBER_SB_OPT_SET_FD = 2;
LBER_SB_OPT_HAS_IO = 3;
LBER_SB_OPT_SET_NONBLOCK = 4;
LBER_SB_OPT_GET_SSL = 7;
LBER_SB_OPT_DATA_READY = 8;
LBER_SB_OPT_SET_READAHEAD = 9;
LBER_SB_OPT_DRAIN = 10;
LBER_SB_OPT_NEEDS_READ = 11;
LBER_SB_OPT_NEEDS_WRITE = 12;
LBER_SB_OPT_GET_MAX_INCOMING = 13;
LBER_SB_OPT_SET_MAX_INCOMING = 14;
(* Largest option used by the library *)
LBER_SB_OPT_OPT_MAX = 14;
(* LBER IO operations stacking levels *)
LBER_SBIOD_LEVEL_PROVIDER = 10;
LBER_SBIOD_LEVEL_TRANSPORT = 20;
LBER_SBIOD_LEVEL_APPLICATION = 30;
(* get/set options for Sockbuf *)
LBER_OPT_SOCKBUF_DESC = $1000;
LBER_OPT_SOCKBUF_OPTIONS = $1001;
LBER_OPT_SOCKBUF_DEBUG = $1002;
LBER_OPT_SUCCESS = 0;
LBER_OPT_ERROR = -1;
(* on/off values *)
const
LBER_OPT_OFF = Pointer(0);
var
ber_pvt_opt_on: char; cvar; external;
function LBER_OPT_ON: Pointer;
(* Structure for LBER IO operarion descriptor *)
type
PBerElement = Pointer;
PSockbuf = Pointer;
PSeqorset = Pointer;
PSockbuf_IO = ^Sockbuf_IO;
PSockbuf_IO_Desc = ^Sockbuf_IO_Desc;
Sockbuf_IO_Desc = record
sbiod_level : cint;
sbiod_sb : PSockbuf;
sbiod_io : PSockbuf_IO;
sbiod_pvt : Pointer;
sbiod_next : PSockbuf_IO_Desc;
end;
(* Structure for LBER IO operation functions *)
Sockbuf_IO = record
sbi_setup : function(sbiod: PSockbuf_IO_Desc; arg: Pointer): cint; cdecl;
sbi_remove : function(sbiod: PSockbuf_IO_Desc): cint; cdecl;
sbi_ctrl : function(sbiod: PSockbuf_IO_Desc; opt: cint; arg: Pointer): cint; cdecl;
sbi_read : function(sbiod: PSockbuf_IO_Desc; buf: Pointer; len: ber_len_t): ber_slen_t; cdecl;
sbi_write : function(sbiod: PSockbuf_IO_Desc; buf: Pointer; len: ber_len_t): ber_slen_t; cdecl;
sbi_close : function(sbiod: PSockbuf_IO_Desc): cint; cdecl;
end;
(* Helper macros for LBER IO functions *)
function LBER_SBIOD_READ_NEXT(sbiod: PSockbuf_IO_Desc; buf: Pointer; len: ber_len_t): ber_slen_t;
function LBER_SBIOD_WRITE_NEXT(sbiod: PSockbuf_IO_Desc; buf: Pointer; len: ber_len_t): ber_slen_t;
function LBER_SBIOD_CTRL_NEXT(sbiod: PSockbuf_IO_Desc; opt: cint; arg: Pointer): cint;
(* structure for returning a sequence of octet strings + length *)
type
PPPBerval = ^PPBerval;
PPBerval = ^PBerval;
PBerval = ^Berval;
Berval = record
bv_len : ber_len_t;
bv_val : PChar;
end;
PBerVarray = ^BerVarray;
BerVarray = ^PBerval; (* To distinguish from a single bv *)
(* this should be moved to lber-cint.h *)
(*
* in bprint.c:
*)
procedure ber_error_print(const data: PChar); cdecl; external;
procedure ber_bprint(const data: PChar; len: ber_len_t); cdecl; external;
procedure ber_dump(ber: PBerElement; inout : cint); cdecl; external;
procedure ber_sos_dump(sos: PSeqorset); cdecl; external;
(*
* in decode.c:
*)
type
BERDecodeCallback = function(ber: PBerElement; data: Pointer; mode: cint): cint; cdecl;
function ber_get_tag(ber: PBerElement): ber_tag_t; cdecl; external;
function ber_skip_tag(ber: PBerElement; var len: ber_len_t): ber_tag_t; cdecl; external;
function ber_peek_tag(ber: PBerElement; var len: ber_len_t): ber_tag_t; cdecl; external;
function ber_get_int(ber: PBerElement; var num: ber_int_t): ber_tag_t; cdecl; external;
function ber_get_enum(ber: PBerElement; var num: ber_int_t): ber_tag_t; cdecl; external;
function ber_get_stringb(ber: PBerElement; buf: PChar; var len: ber_len_t): ber_tag_t; cdecl; external;
function ber_get_stringbv(ber: PBerElement; bv: PBerval; alloc: cbool): ber_tag_t; cdecl; external;
function ber_get_stringa(ber: PBerElement; var buf: PChar): ber_tag_t; cdecl; external;
function ber_get_stringal(ber: PBerElement; var bv: PBerval): ber_tag_t; cdecl; external;
function ber_get_bitstringa(ber: PBerElement; var buf: PChar; var len: ber_len_t): ber_tag_t; cdecl; external;
function ber_get_null(ber: PBerElement): ber_tag_t; cdecl; external;
function ber_get_Boolean(ber: PBerElement; var boolval: ber_int_t): ber_tag_t; cdecl; external;
function ber_first_element(ber: PBerElement; var len: ber_len_t; var last: PChar): ber_tag_t; cdecl; external;
function ber_next_element(ber: PBerElement; var len: ber_len_t; const last: PChar): ber_tag_t; cdecl; external;
function ber_scanf(ber: PBerElement;const fmt: PChar): ber_tag_t; cdecl; varargs; external;
(*
* in encode.c
*)
type
BEREncodeCallback = function(ber: PBerElement; data: Pointer): cint;
function ber_put_enum(ber: PBerElement; num: ber_int_t; tag: ber_tag_t): cint; cdecl; external;
function ber_put_int(ber: PBerElement; num: ber_int_t; tag: ber_tag_t): cint; cdecl; external;
function ber_put_ostring(ber: PBerElement; const str: PChar; len: ber_len_t; tag: ber_tag_t): cint; cdecl; external;
function ber_put_berval(ber: PBerElement; bv: PBerval; tag: ber_tag_t): cint; cdecl; external;
function ber_put_string(ber: PBerElement; const str: PChar; tag: ber_tag_t): cint; cdecl; external;
function ber_put_bitstring(ber: PBerElement; const str: PChar; bitlen: ber_len_t; tag: ber_tag_t): cint; cdecl; external;
function ber_put_null(ber: PBerElement; tag: ber_tag_t): cint; cdecl; external;
function ber_put_boolean(ber: PBerElement; boolval: ber_int_t; tag: ber_tag_t): cint; cdecl; external;
function ber_start_seq(ber: PBerElement; tag: ber_tag_t): cint; cdecl; external;
function ber_start_set(ber: PBerElement; tag: ber_tag_t): cint; cdecl; external;
function ber_put_seq(ber: PBerElement): cint; cdecl; external;
function ber_put_set(ber: PBerElement): cint; cdecl; external;
function ber_printf(ber: PBerElement; const fmt: PChar): cint; cdecl; varargs; external;
(*
* in io.c:
*)
function ber_read(ber: PBerElement; buf: PChar; len: ber_len_t): ber_slen_t; cdecl; external;
function ber_write(ber: PBerElement; const buf: PChar; len: ber_len_t; nosos: cint): ber_slen_t; cdecl; external;
procedure ber_free(ber: PBerElement; freebuf: cbool); cdecl; external;
procedure ber_free_buf(ber: PBerElement); cdecl; external;
function ber_flush(sb: PSockbuf; ber: PBerElement; freeit: cbool): cint; cdecl; external;
function ber_alloc: PBerElement; cdecl; external; deprecated;
function der_alloc: PBerElement; cdecl; external; deprecated;
function ber_alloc_t(beroptions: cint): PBerElement; cdecl; external;
function ber_dup(ber: PBerElement): PBerElement; cdecl; external;
function ber_get_next(sb: PSockbuf; var len: ber_len_t; ber: PBerElement): ber_tag_t; cdecl; external;
procedure ber_init2(ber: PBerElement; bv: PBerval; options: cint); cdecl; external;
procedure ber_init_w_nullc(ber: PBerElement; options: cint); cdecl; external; deprecated;
procedure ber_reset(ber: PBerElement; was_writing: cbool); cdecl; external;
function ber_init(bv: PBerval): PBerElement; cdecl; external;
function ber_flatten(ber: PBerElement; var bvPtr: PBerval): cint; cdecl; external;
function ber_flatten2(ber: PBerElement; bv: PBerval; alloc: cbool): cint; cdecl; external;
function ber_remaining(ber: PBerElement): cint; cdecl; external;
(*
* LBER ber accessor functions
*)
function ber_get_option(item: Pointer; option: cint; outvalue: Pointer): cint; cdecl; external;
function ber_set_option(item: Pointer; option: cint; const invalue: Pointer): cint; cdecl; external;
(*
* LBER sockbuf.c
*)
function ber_sockbuf_alloc: PSockbuf; cdecl; external;
procedure ber_sockbuf_free(sb: PSockbuf); cdecl; external;
function ber_sockbuf_add_io(sb: PSockbuf; sbio: PSockbuf_IO; layer: cint; arg: Pointer): cint; cdecl; external;
function ber_sockbuf_remove_io(sb: PSockbuf; sbio: PSockbuf_IO; layer: cint): cint; cdecl; external;
function ber_sockbuf_ctrl(sb: PSockbuf; opt: cint; arg: Pointer): cint; cdecl; external;
var
ber_sockbuf_io_tcp : Sockbuf_IO; cvar; external;
ber_sockbuf_io_readahead : Sockbuf_IO; cvar; external;
ber_sockbuf_io_fd : Sockbuf_IO; cvar; external;
ber_sockbuf_io_debug : Sockbuf_IO; cvar; external;
{$IFDEF LDAP_CONNECTIONLESS}
ber_sockbuf_io_udp : Sockbuf_IO; cvar; external;
{$ENDIF}
(*
* LBER memory.c
*)
function ber_memalloc(s: ber_len_t): Pointer; cdecl; external;
function ber_memrealloc(p: Pointer; s: ber_len_t): Pointer; cdecl; external;
function ber_memcalloc(n: ber_len_t; s: ber_len_t): Pointer; cdecl; external;
procedure ber_memfree(p: Pointer); cdecl; external;
procedure ber_memvfree(vector: PPointer); cdecl; external;
procedure ber_bvfree(bv: PBerval); cdecl; external;
procedure ber_bvecfree(bv: PPBerval); cdecl; external;
function ber_bvecadd(var bvec: PPPBerval; bv: PBerval): cint; cdecl; external;
function ber_dupbv(dst: PBerval; src: PBerval): PBerval; cdecl; external;
function ber_bvdup(src: PBerval): PBerval; cdecl; external;
function ber_str2bv(const str: PChar; len: ber_len_t; duplicate: cbool; bv: PBerval): PBerval; cdecl; external;
function ber_mem2bv(const str: PChar; len: ber_len_t; duplicate: cbool; bv: PBerval): PBerval; cdecl; external;
function ber_bvstr(const str: PChar): PBerval;
function ber_bvstrdup(const str: PChar): PBerval;
function ber_strdup(const str: PChar): PChar; cdecl; external;
procedure ber_bvarray_free(p: BerVarray); cdecl; external;
function ber_bvarray_add(p: PBerVarray; bv: PBerval): cint; cdecl; external;
function ber_bvcmp(v1, v2: PBerval): cint;
(*
* error.c
*)
function ber_errno_addr: pcint; cdecl; external;
function ber_errno: cint;
const
LBER_ERROR_NONE = $0;
LBER_ERROR_PARAM = $1;
LBER_ERROR_MEMORY = $2;

View File

@ -0,0 +1,73 @@
unit ldap;
{$mode objfpc}
interface
uses
ctypes,
lber;
{$linklib ldap}
{$include ldap_featuresh.inc}
{$include ldap_schemah.inc}
{$include ldaph.inc}
implementation
function LDAP_OPT_ON: Pointer;
// #define LDAP_OPT_ON ((void *) &ber_pvt_opt_on)
begin
LDAP_OPT_ON := @ber_pvt_opt_on;
end;
function LDAP_RANGE(n, x, y: ber_int_t): Boolean;
// #define LDAP_RANGE(n,x,y) (((x) <= (n)) && ((n) <= (y)))
begin
LDAP_RANGE := (x <= n) and (n <= y);
end;
function LDAP_ATTR_ERROR(n: ber_int_t): Boolean;
// #define LDAP_ATTR_ERROR(n) LDAP_RANGE((n),0x10,0x15) (* 16-21 *)
begin
LDAP_ATTR_ERROR := LDAP_RANGE(n, $10, $15);
end;
function LDAP_NAME_ERROR(n: ber_int_t): Boolean;
// #define LDAP_NAME_ERROR(n) LDAP_RANGE((n),0x20,0x24) (* 32-34,36 *)
begin
LDAP_NAME_ERROR := LDAP_RANGE(n, $20, $24);
end;
function LDAP_SECURITY_ERROR(n: ber_int_t): Boolean;
// #define LDAP_SECURITY_ERROR(n) LDAP_RANGE((n),0x2F,0x32) (* 47-50 *)
begin
LDAP_SECURITY_ERROR := LDAP_RANGE(n, $2F, $32);
end;
function LDAP_SERVICE_ERROR(n: ber_int_t): Boolean;
// #define LDAP_SERVICE_ERROR(n) LDAP_RANGE((n),0x33,0x36) (* 51-54 *)
begin
LDAP_SERVICE_ERROR := LDAP_RANGE(n, $33, $36);
end;
function LDAP_UPDATE_ERROR(n: ber_int_t): Boolean;
// #define LDAP_UPDATE_ERROR(n) LDAP_RANGE((n),0x40,0x47) (* 64-69,71 *)
begin
LDAP_UPDATE_ERROR := LDAP_RANGE(n, $40, $47);
end;
function LDAP_API_ERROR(n: ber_int_t): Boolean;
// #define LDAP_API_ERROR(n) LDAP_RANGE((n),0x51,0x61) (* 81-97 *)}
begin
LDAP_API_ERROR := n < 0;
end;
function LDAP_API_RESULT(n: ber_int_t): Boolean;
// #define LDAP_API_RESULT(n) (((n) == LDAP_SUCCESS) || LDAP_RANGE((n),0x51,0x61)) (* 0,81-97 *)
begin
LDAP_API_RESULT := n <= 0;
end;
end.

View File

@ -0,0 +1,59 @@
(* include/ldap_features.h. Generated automatically by configure. *)
(* $OpenLDAP: pkg/ldap/include/ldap_features.h.in,v 1.13.2.1 2003/02/09 17:02:17 kurt Exp $ *)
(*
* Copyright 1998-2003 The OpenLDAP Foundation, Redwood City, California, USA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License. A copy of this license is available at
* http://www.OpenLDAP.org/license.html or in file LICENSE in the
* top-level directory of the distribution.
*)
(*
* LDAP Features
*)
(* OpenLDAP API version macros *)
const
LDAP_VENDOR_VERSION = 20228;
LDAP_VENDOR_VERSION_MAJOR = 2;
LDAP_VENDOR_VERSION_MINOR = 2;
LDAP_VENDOR_VERSION_PATCH = 28;
(*
** WORK IN PROGRESS!
**
** OpenLDAP reentrancy/thread-safeness should be dynamically
** checked using ldap_get_option().
**
** The -lldap implementation is not thread-safe.
**
** The -lldap_r implementation is:
** LDAP_API_FEATURE_THREAD_SAFE (basic thread safety)
** but also be:
** LDAP_API_FEATURE_SESSION_THREAD_SAFE
** LDAP_API_FEATURE_OPERATION_THREAD_SAFE
**
** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE
** can be used to determine if -lldap_r is available at compile
** time. You must define LDAP_THREAD_SAFE if and only if you
** link with -lldap_r.
**
** If you fail to define LDAP_THREAD_SAFE when linking with
** -lldap_r or define LDAP_THREAD_SAFE when linking with -lldap,
** provided header definations and declarations may be incorrect.
**
*)
(* is -lldap_r available or not *)
{$DEFINE LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE}
(* LDAP v2 Kerberos Bind *)
//{$UNDEF LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND}
(* LDAP v2 Referrals *)
//{$UNDEF LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS}

View File

@ -0,0 +1,255 @@
(* $OpenLDAP: pkg/ldap/include/ldap_schema.h,v 1.32.2.3 2005/01/20 17:00:59 kurt Exp $ *)
(* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2005 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*)
(* ldap-schema.h - Header for basic schema handling functions that can be
* used by both clients and servers.
* these routines should be renamed ldap_x_...
*)
(* Codes for parsing errors *)
const
LDAP_SCHERR_OUTOFMEM = 1;
LDAP_SCHERR_UNEXPTOKEN = 2;
LDAP_SCHERR_NOLEFTPAREN = 3;
LDAP_SCHERR_NORIGHTPAREN = 4;
LDAP_SCHERR_NODIGIT = 5;
LDAP_SCHERR_BADNAME = 6;
LDAP_SCHERR_BADDESC = 7;
LDAP_SCHERR_BADSUP = 8;
LDAP_SCHERR_DUPOPT = 9;
LDAP_SCHERR_EMPTY = 10;
LDAP_SCHERR_MISSING = 11;
LDAP_SCHERR_OUT_OF_ORDER = 12;
type
pldap_schema_extension_item = ^ldap_schema_extension_item;
ldap_schema_extension_item = record
lsei_name : PChar;
lsei_values : PPChar;
end;
PPLDAPSchemaExtensionItem = ^PLDAPSchemaExtensionItem;
PLDAPSchemaExtensionItem = ^LDAPSchemaExtensionItem;
LDAPSchemaExtensionItem = ldap_schema_extension_item;
pldap_syntax = ^ldap_syntax;
ldap_syntax = record
syn_oid : PChar; (* REQUIRED *)
syn_names : PPChar; (* OPTIONAL *)
syn_desc : PChar; (* OPTIONAL *)
syn_extensions : PPLDAPSchemaExtensionItem; (* OPTIONAL *)
end;
PLDAPSyntax = ^ldap_syntax;
LDAPSyntax = ldap_syntax;
pldap_matchingrule = ^ldap_matchingrule;
ldap_matchingrule = record
mr_oid : PChar; (* REQUIRED *)
mr_names : PPChar; (* OPTIONAL *)
mr_desc : PChar; (* OPTIONAL *)
mr_obsolete : cint; (* OPTIONAL *)
mr_syntax_oid : PChar; (* REQUIRED *)
mr_extensions : PPLDAPSchemaExtensionItem; (* OPTIONAL *)
end;
PLDAPMatchingRule = ^LDAPMatchingRule;
LDAPMatchingRule = ldap_matchingrule;
pldap_matchingruleuse = ^ldap_matchingruleuse;
ldap_matchingruleuse = record
mru_oid : PChar; (* REQUIRED *)
mru_names : PPChar; (* OPTIONAL *)
mru_desc : PChar; (* OPTIONAL *)
mru_obsolete : cint; (* OPTIONAL *)
mru_applies_oids: PPChar; (* REQUIRED *)
mru_extensions : PPLDAPSchemaExtensionItem; (* OPTIONAL *)
end;
PLDAPMatchingRuleUse = ^LDAPMatchingRuleUse;
LDAPMatchingRuleUse = ldap_matchingruleuse;
pldap_attributetype = ^ldap_attributetype;
ldap_attributetype = record
at_oid : PChar; (* REQUIRED *)
at_names : PPChar; (* OPTIONAL *)
at_desc : PChar; (* OPTIONAL *)
at_obsolete : cint; (* 0=no, 1=yes *)
at_sup_oid : PChar; (* OPTIONAL *)
at_equality_oid : PChar; (* OPTIONAL *)
at_ordering_oid : PChar; (* OPTIONAL *)
at_substr_oid : PChar; (* OPTIONAL *)
at_syntax_oid : PChar; (* OPTIONAL *)
at_syntax_len : cint; (* OPTIONAL *)
at_single_value : cint; (* 0=no, 1=yes *)
at_collective : cint; (* 0=no, 1=yes *)
at_no_user_mod : cint; (* 0=no, 1=yes *)
at_usage : cint; (* 0=userApplications, 1=directoryOperation, 2=distributedOperation, 3=dSAOperation *)
at_extensions : PPLDAPSchemaExtensionItem; (* OPTIONAL *)
end;
PLDAPAttributeType = ^LDAPAttributeType;
LDAPAttributeType = ldap_attributetype;
pldap_objectclass = ^ldap_objectclass;
ldap_objectclass = record
oc_oid : PChar; (* REQUIRED *)
oc_names : PPChar; (* OPTIONAL *)
oc_desc : PChar; (* OPTIONAL *)
oc_obsolete : cint; (* 0=no, 1=yes *)
oc_sup_oids : PPChar; (* OPTIONAL *)
oc_kind : cint; (* 0=ABSTRACT, 1=STRUCTURAL, 2=AUXILIARY *)
oc_at_oids_must : PPChar; (* OPTIONAL *)
oc_at_oids_may : PPChar; (* OPTIONAL *)
oc_extensions : PPLDAPSchemaExtensionItem; (* OPTIONAL *)
end;
PLDAPObjectClass = ^LDAPObjectClass;
LDAPObjectClass = ldap_objectclass;
pldap_contentrule = ^ldap_contentrule;
ldap_contentrule = record
cr_oid : PChar; (* REQUIRED *)
cr_names : PPChar; (* OPTIONAL *)
cr_desc : PChar; (* OPTIONAL *)
cr_sup_oids : PPChar; (* OPTIONAL *)
cr_obsolete : cint; (* 0=no, 1=yes *)
cr_oc_oids_aux : PPChar; (* OPTIONAL *)
cr_at_oids_must : PPChar; (* OPTIONAL *)
cr_at_oids_may : PPChar; (* OPTIONAL *)
cr_at_oids_not : PPChar; (* OPTIONAL *)
cr_extensions : PPLDAPSchemaExtensionItem; (* OPTIONAL *)
end;
PLDAPContentRule = ^LDAPContentRule;
LDAPContentRule = ldap_contentrule;
pldap_nameform = ^ldap_nameform;
ldap_nameform = record
nf_oid : PChar; (* REQUIRED *)
nf_names : PPChar; (* OPTIONAL *)
nf_desc : PChar; (* OPTIONAL *)
nf_obsolete : cint; (* 0=no, 1=yes *)
nf_objectclass : PChar; (* REQUIRED *)
nf_at_oids_must : PPChar; (* REQUIRED *)
nf_at_oids_may : PPChar; (* OPTIONAL *)
nf_extensions : PPLDAPSchemaExtensionItem; (* OPTIONAL *)
end;
PLDAPNameForm = ^LDAPNameForm;
LDAPNameForm = ldap_nameform;
pldap_structurerule = ^ldap_structurerule;
ldap_structurerule = record
sr_ruleid : cint; (* REQUIRED *)
sr_names : PPChar; (* OPTIONAL *)
sr_desc : PChar; (* OPTIONAL *)
sr_obsolete : cint; (* 0=no, 1=yes *)
sr_nameform : PChar; (* REQUIRED *)
sr_nsup_ruleids : cint; (* number of sr_sup_ruleids *)
sr_sup_ruleids : pcint; (* OPTIONAL *)
sr_extensions : PPLDAPSchemaExtensionItem; (* OPTIONAL *)
end;
PLDAPStructureRule = ^LDAPStructureRule;
LDAPStructureRule = ldap_structurerule;
(*
* Misc macros
*)
const
LDAP_SCHEMA_NO = 0;
LDAP_SCHEMA_YES = 1;
LDAP_SCHEMA_USER_APPLICATIONS = 0;
LDAP_SCHEMA_DIRECTORY_OPERATION = 1;
LDAP_SCHEMA_DISTRIBUTED_OPERATION = 2;
LDAP_SCHEMA_DSA_OPERATION = 3;
LDAP_SCHEMA_ABSTRACT = 0;
LDAP_SCHEMA_STRUCTURAL = 1;
LDAP_SCHEMA_AUXILIARY = 2;
(*
* Flags that control how liberal the parsing routines are.
*)
const
LDAP_SCHEMA_ALLOW_NONE = $00; (* Strict parsing *)
LDAP_SCHEMA_ALLOW_NO_OID = $01; (* Allow missing oid *)
LDAP_SCHEMA_ALLOW_QUOTED = $02; (* Allow bogus extra quotes *)
LDAP_SCHEMA_ALLOW_DESCR = $04; (* Allow descr instead of OID *)
LDAP_SCHEMA_ALLOW_DESCR_PREFIX = $08; (* Allow descr as OID prefix *)
LDAP_SCHEMA_ALLOW_OID_MACRO = $10; (* Allow OID macros in slapd *)
LDAP_SCHEMA_ALLOW_OUT_OF_ORDER_FIELDS = $20; (* Allow fields in most any order *)
LDAP_SCHEMA_ALLOW_ALL = $3f; (* Be very liberal in parsing *)
LDAP_SCHEMA_SKIP = $80; (* Don't malloc any result *)
function ldap_syntax2name(syn: PLDAPSyntax): PChar; cdecl; external;
function ldap_matchingrule2name(mr: PLDAPMatchingRule): PChar; cdecl; external;
function ldap_matchingruleuse2name(mru: PLDAPMatchingRuleUse): PChar; cdecl; external;
function ldap_attributetype2name(_at: PLDAPAttributeType): PChar; cdecl; external;
function ldap_objectclass2name(oc: PLDAPObjectClass): PChar; cdecl; external;
function ldap_contentrule2name(cr: PLDAPContentRule): PChar; cdecl; external;
function ldap_nameform2name(nf: PLDAPNameForm): PChar; cdecl; external;
function ldap_structurerule2name(sr: PLDAPStructureRule): PChar; cdecl; external;
procedure ldap_syntax_free(syn: PLDAPSyntax); cdecl; external;
procedure ldap_matchingrule_free(mr: PLDAPMatchingRule); cdecl; external;
procedure ldap_matchingruleuse_free(mru: PLDAPMatchingRuleUse); cdecl; external;
procedure ldap_attributetype_free(_at: PLDAPAttributeType); cdecl; external;
procedure ldap_objectclass_free(oc: PLDAPObjectClass); cdecl; external;
procedure ldap_contentrule_free(cr: PLDAPContentRule); cdecl; external;
procedure ldap_nameform_free(nf: PLDAPNameForm); cdecl; external;
procedure ldap_structurerule_free(sr: PLDAPStructureRule); cdecl; external;
function ldap_str2structurerule(const s: PChar; code: pcint; const errp: PPChar; flags: cuint): PLDAPStructureRule; cdecl; external;
function ldap_str2nameform(const s: PChar; code: pcint; const errp: PPChar; flags: cuint): PLDAPNameForm; cdecl; external;
function ldap_str2contentrule(const s: PChar; code: pcint; const errp: PPChar; flags: cuint): PLDAPContentRule; cdecl; external;
function ldap_str2objectclass(const s: PChar; code: pcint; const errp: PPChar; flags: cuint): PLDAPObjectClass; cdecl; external;
function ldap_str2attributetype(const s: PChar; code: pcint; const errp: PPChar; flags: cuint): PLDAPAttributeType; cdecl; external;
function ldap_str2syntax(const s: PChar; code: pcint; const errp: PPChar; flags: cuint): PLDAPSyntax; cdecl; external;
function ldap_str2matchingrule(const s: PChar; code: pcint; const errp: PPChar; flags: cuint): PLDAPMatchingRule; cdecl; external;
function ldap_str2matchingruleuse(const s: PChar; code: pcint; const errp: PPChar; flags: cuint): PLDAPMatchingRuleUse; cdecl; external;
function ldap_structurerule2str(sr: PLDAPStructureRule): PChar; cdecl; external;
function ldap_structurerule2bv(sr: PLDAPStructureRule; bv: PBerval): PBerval; cdecl; external;
function ldap_nameform2str(nf: PLDAPNameForm): PChar; cdecl; external;
function ldap_nameform2bv(nf: PLDAPNameForm; bv: PBerval): PBerval; cdecl; external;
function ldap_contentrule2str(cr: PLDAPContentRule): PChar; cdecl; external;
function ldap_contentrule2bv(cr: PLDAPContentRule; bv: PBerval): PBerval; cdecl; external;
function ldap_objectclass2str(oc: PLDAPObjectClass): PChar; cdecl; external;
function ldap_objectclass2bv(oc: PLDAPObjectClass; bv: PBerval): PBerval; cdecl; external;
function ldap_attributetype2str(_at: PLDAPAttributeType): PChar; cdecl; external;
function ldap_attributetype2bv(_at: PLDAPAttributeType; bv: PBerval): PBerval; cdecl; external;
function ldap_syntax2str(syn: PLDAPSyntax): PChar; cdecl; external;
function ldap_syntax2bv(syn: PLDAPSyntax; bv: PBerval): PBerval; cdecl; external;
function ldap_matchingrule2str(mr: PLDAPMatchingRule): PChar; cdecl; external;
function ldap_matchingrule2bv(mr: PLDAPMatchingRule; bv: PBerval): PBerval; cdecl; external;
function ldap_matchingruleuse2str(mru: PLDAPMatchingRuleUse): PChar; cdecl; external;
function ldap_matchingruleuse2bv(mru: PLDAPMatchingRuleUse; bv: PBerval): PBerval; cdecl; external;
function ldap_scherr2str(code: cint): PChar; cdecl; external;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,434 @@
(*
Translation of the SAMBA md4 code for FreePascal
Copyright (C) 2006 by Ivo Steinmann
Ported from SAMBA/source/libsmb/smbdes.c
Unix SMB/CIFS implementation.
a partial implementation of DES designed for use in the
SMB authentication protocol
Copyright (C) Andrew Tridgell 1998
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*)
unit ntlm;
{$mode objfpc}
interface
uses
Strings,
Math,
md4;
type
THash = array[0..15] of Byte;
procedure nt_lm_owf_gen(const pwd: PChar; var nt_p16: THash; var lm_p16: THash);
procedure hash_to_str(const h: THash; const str: PChar);
implementation
//
// Ported from SAMBA/source/libsmb/smbdes.c
//
const
perm1: array[0..55] of Byte = (
57, 49, 41, 33, 25, 17, 9,
1, 58, 50, 42, 34, 26, 18,
10, 2, 59, 51, 43, 35, 27,
19, 11, 3, 60, 52, 44, 36,
63, 55, 47, 39, 31, 23, 15,
7, 62, 54, 46, 38, 30, 22,
14, 6, 61, 53, 45, 37, 29,
21, 13, 5, 28, 20, 12, 4);
perm2: array[0..47] of Byte = (
14, 17, 11, 24, 1, 5,
3, 28, 15, 6, 21, 10,
23, 19, 12, 4, 26, 8,
16, 7, 27, 20, 13, 2,
41, 52, 31, 37, 47, 55,
30, 40, 51, 45, 33, 48,
44, 49, 39, 56, 34, 53,
46, 42, 50, 36, 29, 32);
perm3: array[0..63] of Byte = (
58, 50, 42, 34, 26, 18, 10, 2,
60, 52, 44, 36, 28, 20, 12, 4,
62, 54, 46, 38, 30, 22, 14, 6,
64, 56, 48, 40, 32, 24, 16, 8,
57, 49, 41, 33, 25, 17, 9, 1,
59, 51, 43, 35, 27, 19, 11, 3,
61, 53, 45, 37, 29, 21, 13, 5,
63, 55, 47, 39, 31, 23, 15, 7);
perm4: array[0..47] of Byte = (
32, 1, 2, 3, 4, 5,
4, 5, 6, 7, 8, 9,
8, 9, 10, 11, 12, 13,
12, 13, 14, 15, 16, 17,
16, 17, 18, 19, 20, 21,
20, 21, 22, 23, 24, 25,
24, 25, 26, 27, 28, 29,
28, 29, 30, 31, 32, 1);
perm5: array[0..31] of Byte = (
16, 7, 20, 21,
29, 12, 28, 17,
1, 15, 23, 26,
5, 18, 31, 10,
2, 8, 24, 14,
32, 27, 3, 9,
19, 13, 30, 6,
22, 11, 4, 25);
perm6: array[0..63] of Byte = (
40, 8, 48, 16, 56, 24, 64, 32,
39, 7, 47, 15, 55, 23, 63, 31,
38, 6, 46, 14, 54, 22, 62, 30,
37, 5, 45, 13, 53, 21, 61, 29,
36, 4, 44, 12, 52, 20, 60, 28,
35, 3, 43, 11, 51, 19, 59, 27,
34, 2, 42, 10, 50, 18, 58, 26,
33, 1, 41, 9, 49, 17, 57, 25);
sc: array[0..15] of Byte = (1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1);
sbox: array[0..7, 0..3, 0..15] of Byte = (
((14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7),
(0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8),
(4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0),
(15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13)),
((15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10),
(3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5),
(0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15),
(13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9)),
((10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8),
(13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1),
(13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7),
(1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12)),
((7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15),
(13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9),
(10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4),
(3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14)),
((2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9),
(14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6),
(4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14),
(11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3)),
((12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11),
(10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8),
(9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6),
(4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13)),
((4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1),
(13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6),
(1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2),
(6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12)),
((13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7),
(1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2),
(7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8),
(2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11)));
procedure permute({out} const _out: PByte; {in} const _in: PByte; {in} const p: PByte; {in} const n: Integer);
var
i: Integer;
begin
for i := 0 to n-1 do
_out[i] := _in[p[i]-1];
end;
procedure lshift({in/out} const d: PByte; {in} const count: Integer; {in} const n: Integer);
var
_out : array[0..63] of Byte;
i : Integer;
begin
for i := 0 to n-1 do
_out[i] := d[(i+count) mod n];
for i := 0 to n-1 do
d[i] := _out[i];
end;
procedure concat({out} const _out: PByte; {in} const _in1, _in2: PByte; {in} const l1, l2: Integer);
var
i: Integer;
begin
for i := 0 to l1-1 do
_out[i] := _in1[i];
for i := 0 to l2-1 do
_out[i+l1] := _in2[i];
end;
procedure mxor({out} const _out: PByte; {in} const _in1, _in2: PByte; {in} const n: Integer);
var
i: Integer;
begin
for i := 0 to n-1 do
_out[i] := _in1[i] xor _in2[i];
end;
procedure dohash({out} const _out: PByte; {in} const _in: PByte; {in} const key: PByte; {in} const forw: Boolean);
var
i : Integer;
j : Integer;
k : Integer;
pk1 : array[0..55] of Byte;
c : array[0..27] of Byte;
d : array[0..27] of Byte;
cd : array[0..55] of Byte;
ki : array[0..15,0..47] of Byte;
pd1 : array[0..63] of Byte;
l : array[0..31] of Byte;
r : array[0..31] of Byte;
rl : array[0..63] of Byte;
er : array[0..47] of Byte;
erk : array[0..47] of Byte;
b : array[0..7,0..5] of Byte;
cb : array[0..31] of Byte;
pcb : array[0..31] of Byte;
r2 : array[0..31] of Byte;
m : Integer;
n : Integer;
begin
permute(@pk1, key, @perm1, 56);
for i := 0 to 27 do
begin
c[i] := pk1[i];
d[i] := pk1[i+28];
end;
for i := 0 to 15 do
begin
lshift(@c, sc[i], 28);
lshift(@d, sc[i], 28);
concat(@cd, @c, @d, 28, 28);
permute(@ki[i][0], @cd, @perm2, 48);
end;
permute(@pd1, _in, @perm3, 64);
for i := 0 to 31 do
begin
l[i] := pd1[i];
r[i] := pd1[i+32];
end;
for i := 0 to 15 do
begin
permute(@er, @r, @perm4, 48);
if forw then
mxor(@erk, @er, @ki[i][0], 48) else
mxor(@erk, @er, @ki[15-i][0], 48);
for j := 0 to 7 do
for k := 0 to 5 do
b[j][k] := erk[j*6 + k];
for j := 0 to 7 do
begin
m := (b[j][0] shl 1) or b[j][5];
n := (b[j][1] shl 3) or (b[j][2] shl 2) or (b[j][3] shl 1) or (b[j][4]);
for k := 0 to 3 do
b[j][k] := min(sbox[j][m][n] and (1 shl (3-k)), 1); // store binary
end;
for j := 0 to 7 do
for k := 0 to 3 do
cb[j*4+k] := b[j][k];
permute(@pcb, @cb, @perm5, 32);
mxor(@r2, @l, @pcb, 32);
for j := 0 to 31 do
begin
l[j] := r[j];
r[j] := r2[j];
end;
end;
concat(@rl, @r, @l, 32, 32);
permute(_out, @rl, @perm6, 64);
end;
procedure str_to_key({in} const str: PByte; {out} const key: PByte);
var
i: Integer;
begin
key[0] := str[0] shr 1;
key[1] := ((str[0] and $01) shl 6) or (str[1] shr 2);
key[2] := ((str[1] and $03) shl 5) or (str[2] shr 3);
key[3] := ((str[2] and $07) shl 4) or (str[3] shr 4);
key[4] := ((str[3] and $0F) shl 3) or (str[4] shr 5);
key[5] := ((str[4] and $1F) shl 2) or (str[5] shr 6);
key[6] := ((str[5] and $3F) shl 1) or (str[6] shr 7);
key[7] := str[6] and $7F;
for i := 0 to 7 do
key[i] := key[i] shl 1;
end;
procedure smbhash({out} const _out: PByte; {in} const _in: PByte; {in} const key: PByte; {in} const forw: Boolean);
var
i : Integer;
outb : array[0..63] of Byte;
inb : array[0..63] of Byte;
keyb : array[0..63] of Byte;
key2 : array[0..7] of Byte;
begin
str_to_key(key, @key2);
for i := 0 to 63 do
begin
inb[i] := min( _in[i div 8] and (1 shl (7-(i mod 8))), 1); // store binary
keyb[i] := min(key2[i div 8] and (1 shl (7-(i mod 8))), 1); // store binary
outb[i] := 0;
end;
dohash(@outb, @inb, @keyb, forw);
for i := 0 to 7 do
_out[I] := 0;
for i := 0 to 63 do
begin
if outb[i] <> 0 then
_out[i div 8] := _out[i div 8] or (1 shl (7-(i mod 8)));
end;
end;
procedure E_P16({in} const p14: PByte; {out} const p16: PByte);
const
sp8: array[0..7] of Byte = ($4b, $47, $53, $21, $40, $23, $24, $25);
begin
smbhash(@p16[0], @sp8, @p14[0], True);
smbhash(@p16[8], @sp8, @p14[7], True);
end;
procedure E_P24({in} const p21: PByte; {in} const c8: PByte; {out} const p24: PByte);
begin
smbhash(@p24[0], c8, @p21[0], True);
smbhash(@p24[8], c8, @p21[7], True);
smbhash(@p24[16], c8, @p21[14], True);
end;
//
// Ported from SAMBA/source/libsmb/smbencrypt.c
//
(*
* Creates the MD4 Hash of the users password in NT UNICODE.
*)
procedure E_md4hash({in} const pwd: PByte; {out} const p16: PByte);
var
len : Integer;
wpwd : array[0..128] of Word;
begin
FillChar(wpwd, Sizeof(wpwd), 0);
(* Password must be converted to NT unicode - null terminated *)
len := 0;
while (len < 128) and (pwd[len] <> 0) do
begin
wpwd[len] := pwd[len];
Inc(len);
end;
mdfour(p16, @wpwd[0], 2*len);
FillChar(wpwd, Sizeof(wpwd), 0);
end;
procedure E_deshash({in} const pwd: PByte; {out} const p16: PByte);
var
dospwd: array[0..14] of Byte;
begin
FillChar(dospwd, Sizeof(dospwd), 0);
(* Password must be converted to DOS charset - null terminated, uppercase *)
StrLCopy(@dospwd, @pwd[0], Sizeof(dospwd)-1);
StrUpper(@dospwd);
(* ONly the first 14 chars are considered, password need not be null terminated *)
E_P16(@dospwd, p16);
FillChar(dospwd, Sizeof(dospwd), 0);
end;
(*
* Does both the NT and LM owfs of a user's password
*)
procedure nt_lm_owf_gen({in} const pwd: PChar; {out} var nt_p16: THash; {out} var lm_p16: THash);
var
passwd: array[0..513] of Char;
begin
FillChar(passwd, Sizeof(passwd), 0);
StrLCopy(passwd, pwd, sizeof(passwd)-1);
(* Calculate the MD4 hash (NT compatible) of the password *)
FillChar(nt_p16, Sizeof(nt_p16), 0);
E_md4hash(@passwd, @nt_p16);
(* Calculate the SMB (lanman) hash functions of the password *)
FillChar(lm_p16, Sizeof(lm_p16), 0);
E_deshash(@passwd, @lm_p16);
(* clear out local copy of user's password (just being paranoid). *)
FillChar(passwd, Sizeof(passwd), 0);
end;
procedure hash_to_str({in} const h: THash; {out} const str: PChar);
const
to_hex: array[0..15] of char = ('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
var
i: integer;
p: PChar;
begin
p := str;
for i := 0 to 15 do
begin
p^ := to_hex[(h[i] shr 4) and $F];
Inc(p);
p^ := to_hex[h[i] and $F];
inc(p);
end;
p^ := #0;
end;
end.