📄 winldap.pas
字号:
//
// Values required for Modification command These are options for the
// mod_op field of LDAPMod structure
//
const
{$EXTERNALSYM LDAP_MOD_ADD}
LDAP_MOD_ADD = $00;
{$EXTERNALSYM LDAP_MOD_DELETE}
LDAP_MOD_DELETE = $01;
{$EXTERNALSYM LDAP_MOD_REPLACE}
LDAP_MOD_REPLACE = $02;
{$EXTERNALSYM LDAP_MOD_BVALUES}
LDAP_MOD_BVALUES = $80;
type
{$EXTERNALSYM PLDAPModA}
PLDAPModA = ^LDAPModA;
{$EXTERNALSYM PLDAPModW}
PLDAPModW = ^LDAPModW;
{$EXTERNALSYM PLDAPMod}
PLDAPMod = PLDAPModA;
{$EXTERNALSYM LDAPModA}
LDAPModA = record
mod_op: ULONG;
mod_type: PAnsiChar;
case integer of
0:(modv_strvals: ^PAnsiChar);
1:(modv_bvals: ^PLDAPBerVal);
end;
{$EXTERNALSYM LDAPModW}
LDAPModW = record
mod_op: ULONG;
mod_type: PWideChar;
case integer of
0:(modv_strvals: ^PWideChar);
1:(modv_bvals: ^PLDAPBerVal);
end;
{$EXTERNALSYM LDAPMod}
LDAPMod = LDAPModA;
TLDAPModA = LDAPModA;
TLDAPModW = LDAPModW;
TLDAPMod = TLDAPModA;
{$HPPEMIT '#pragma pack(pop)'}
//
// macros compatible with reference implementation...
//
{$EXTERNALSYM LDAP_IS_CLDAP}
function LDAP_IS_CLDAP(ld: PLDAP): Boolean;
{$EXTERNALSYM NAME_ERROR}
function NAME_ERROR(n: Integer): Boolean;
//
// function definitions for LDAP API
//
//
// Create a connection block to an LDAP server. HostName can be NULL, in
// which case we'll try to go off and find the "default" LDAP server.
//
// Note that if we have to go off and find the default server, we'll pull
// in NETAPI32.DLL and ADVAPI32.DLL.
//
// If it returns NULL, an error occurred. Pick up error code with
// GetLastError().
//
// ldap_open actually opens the connection at the time of the call,
// whereas ldap_init only opens the connection when an operation is performed
// that requires it.
{$EXTERNALSYM ldap_openA}
function ldap_openA(HostName: PAnsiChar; PortNumber: ULONG): PLDAP; cdecl;
{$EXTERNALSYM ldap_openW}
function ldap_openW(HostName: PWideChar; PortNumber: ULONG): PLDAP; cdecl;
{$EXTERNALSYM ldap_open}
function ldap_open(HostName: PChar; PortNumber: ULONG): PLDAP; cdecl;
{$EXTERNALSYM ldap_initA}
function ldap_initA(HostName: PAnsiChar; PortNumber: ULONG): PLDAP; cdecl;
{$EXTERNALSYM ldap_initW}
function ldap_initW(HostName: PWideChar; PortNumber: ULONG): PLDAP; cdecl;
{$EXTERNALSYM ldap_init}
function ldap_init(HostName: PChar; PortNumber: ULONG): PLDAP; cdecl;
{$EXTERNALSYM ldap_sslinitA}
function ldap_sslinitA(HostName: PAnsiChar; PortNumber: ULONG; secure: integer): PLDAP; cdecl;
{$EXTERNALSYM ldap_sslinitW}
function ldap_sslinitW(HostName: PWideChar; PortNumber: ULONG; secure: integer): PLDAP; cdecl;
{$EXTERNALSYM ldap_sslinit}
function ldap_sslinit(HostName: PChar; PortNumber: ULONG; secure: integer): PLDAP; cdecl;
//
// when calling ldap_init, you can call ldap_connect explicitly to have the
// library contact the server. This is useful for checking for server
// availability. This call is not required however, since the other functions
// will call it internally if it hasn't already been called.
//
{$EXTERNALSYM ldap_connect}
function ldap_connect(ld: PLDAP; timeout: PLDAPTimeval): ULONG; cdecl;
//
// This is similar to ldap_open except it creates a connection block for
// UDP based Connectionless LDAP services. No TCP session is maintained.
//
// If it returns NULL, an error occurred. Pick up error code with
// GetLastError().
//
{$EXTERNALSYM cldap_openA}
function cldap_openA(HostName: PAnsiChar; PortNumber: ULONG): PLDAP; cdecl;
{$EXTERNALSYM cldap_openW}
function cldap_openW(HostName: PWideChar; PortNumber: ULONG): PLDAP; cdecl;
{$EXTERNALSYM cldap_open}
function cldap_open(HostName: PChar; PortNumber: ULONG): PLDAP; cdecl;
//
// Call unbind when you're done with the connection, it will free all
// resources associated with the connection.
//
// There is no ldap_close... use ldap_unbind even if you haven't called
// ldap_bind on the connection.
//
{$EXTERNALSYM ldap_unbind}
function ldap_unbind(ld: PLDAP): ULONG; cdecl;
{$EXTERNALSYM ldap_unbind_s}
function ldap_unbind_s(ld: PLDAP): ULONG; cdecl; // calls ldap_unbind
//
// Calls to get and set options on connection blocks... use them rather
// than modifying the LDAP block directly.
//
{$EXTERNALSYM ldap_get_option}
function ldap_get_option(ld: PLDAP; option: integer; outvalue: pointer): ULONG; cdecl;
{$EXTERNALSYM ldap_get_optionW}
function ldap_get_optionW(ld: PLDAP; option: integer; outvalue: pointer): ULONG; cdecl;
{$EXTERNALSYM ldap_set_option}
function ldap_set_option(ld: PLDAP; option: integer; invalue: pointer): ULONG; cdecl;
{$EXTERNALSYM ldap_set_optionW}
function ldap_set_optionW(ld: PLDAP; option: integer; invalue: pointer): ULONG; cdecl;
//
// These are the values to pass to ldap_get/set_option :
//
const
{$EXTERNALSYM LDAP_OPT_DESC}
LDAP_OPT_DESC = $01;
{$EXTERNALSYM LDAP_OPT_DEREF}
LDAP_OPT_DEREF = $02;
{$EXTERNALSYM LDAP_OPT_SIZELIMIT}
LDAP_OPT_SIZELIMIT = $03;
{$EXTERNALSYM LDAP_OPT_TIMELIMIT}
LDAP_OPT_TIMELIMIT = $04;
{$EXTERNALSYM LDAP_OPT_THREAD_FN_PTRS}
LDAP_OPT_THREAD_FN_PTRS = $05;
{$EXTERNALSYM LDAP_OPT_REBIND_FN}
LDAP_OPT_REBIND_FN = $06;
{$EXTERNALSYM LDAP_OPT_REBIND_ARG}
LDAP_OPT_REBIND_ARG = $07;
{$EXTERNALSYM LDAP_OPT_REFERRALS}
LDAP_OPT_REFERRALS = $08;
{$EXTERNALSYM LDAP_OPT_RESTART}
LDAP_OPT_RESTART = $09;
LDAP_OPT_SSL = $0a;
{$EXTERNALSYM LDAP_OPT_IO_FN_PTRS}
LDAP_OPT_IO_FN_PTRS = $0b;
{$EXTERNALSYM LDAP_OPT_CACHE_FN_PTRS}
LDAP_OPT_CACHE_FN_PTRS = $0d;
{$EXTERNALSYM LDAP_OPT_CACHE_STRATEGY}
LDAP_OPT_CACHE_STRATEGY = $0e;
{$EXTERNALSYM LDAP_OPT_CACHE_ENABLE}
LDAP_OPT_CACHE_ENABLE = $0f;
{$EXTERNALSYM LDAP_OPT_REFERRAL_HOP_LIMIT}
LDAP_OPT_REFERRAL_HOP_LIMIT = $10;
{$EXTERNALSYM LDAP_OPT_PROTOCOL_VERSION}
LDAP_OPT_PROTOCOL_VERSION = $11;
{$EXTERNALSYM LDAP_OPT_VERSION}
LDAP_OPT_VERSION = $11;
{$EXTERNALSYM LDAP_OPT_SORTKEYS}
LDAP_OPT_SORTKEYS = $11;
//
// These are new ones that we've defined, not in current RFC draft.
//
{$EXTERNALSYM LDAP_OPT_HOST_NAME}
LDAP_OPT_HOST_NAME = $30;
{$EXTERNALSYM LDAP_OPT_ERROR_NUMBER}
LDAP_OPT_ERROR_NUMBER = $31;
{$EXTERNALSYM LDAP_OPT_ERROR_STRING}
LDAP_OPT_ERROR_STRING = $32;
{$EXTERNALSYM LDAP_OPT_SERVER_ERROR}
LDAP_OPT_SERVER_ERROR = $33;
{$EXTERNALSYM LDAP_OPT_SERVER_EXT_ERROR}
LDAP_OPT_SERVER_EXT_ERROR = $34;
{$EXTERNALSYM LDAP_OPT_HOST_REACHABLE}
LDAP_OPT_HOST_REACHABLE = $3E;
//
// These options control the keep-alive logic. Keep alives are sent as
// ICMP ping messages (which currently don't go through firewalls).
//
// There are three values that control how this works :
// PING_KEEP_ALIVE : min number of seconds since we last received a response
// from the server before we send a keep-alive ping
// PING_WAIT_TIME : number of milliseconds we wait for the response to
// come back when we send a ping
// PING_LIMIT : number of unanswered pings we send before we close the
// connection.
//
// To disable the keep-alive logic, set any of the values (PING_KEEP_ALIVE,
// PING_LIMIT, or PING_WAIT_TIME) to zero.
//
// The current default/min/max for these values are as follows :
//
// PING_KEEP_ALIVE : 120/5/maxInt seconds (may also be zero)
// PING_WAIT_TIME : 2000/10/60000 milliseconds (may also be zero)
// PING_LIMIT : 4/0/maxInt
//
{$EXTERNALSYM LDAP_OPT_PING_KEEP_ALIVE}
LDAP_OPT_PING_KEEP_ALIVE = $36;
{$EXTERNALSYM LDAP_OPT_PING_WAIT_TIME}
LDAP_OPT_PING_WAIT_TIME = $37;
{$EXTERNALSYM LDAP_OPT_PING_LIMIT}
LDAP_OPT_PING_LIMIT = $38;
//
// These won't be in the RFC. Only use these if you're going to be dependent
// on our implementation.
//
{$EXTERNALSYM LDAP_OPT_DNSDOMAIN_NAME}
LDAP_OPT_DNSDOMAIN_NAME = $3B; // return DNS name of domain
{$EXTERNALSYM LDAP_OPT_GETDSNAME_FLAGS}
LDAP_OPT_GETDSNAME_FLAGS = $3D; // flags for DsGetDcName
{$EXTERNALSYM LDAP_OPT_PROMPT_CREDENTIALS}
LDAP_OPT_PROMPT_CREDENTIALS = $3F; // prompt for creds? currently
// only for DPA & NTLM if no creds
// are loaded
{$EXTERNALSYM LDAP_OPT_AUTO_RECONNECT}
LDAP_OPT_AUTO_RECONNECT = $91; // enable/disable autoreconnect
{$EXTERNALSYM LDAP_OPT_SSPI_FLAGS}
LDAP_OPT_SSPI_FLAGS = $92; // flags to pass to InitSecurityContext
//
// To retrieve information on an secure connection, a pointer to a
// SecPkgContext_connectionInfo structure (defined in schnlsp.h) must be
// passed in. On success, it is filled with relevent security information.
//
{$EXTERNALSYM LDAP_OPT_SSL_INFO}
LDAP_OPT_SSL_INFO = $93;
//
// Turing on either the sign or the encrypt option prior to binding using
// LDAP_AUTH_NEGOTIATE will result in the ensuing LDAP session to be signed
// or encrypted using either Kerberos or NTLM (as negotiated by the underlying
// security packages). Note that these options can't be used with SSL.
//
{$EXTERNALSYM LDAP_OPT_SIGN}
LDAP_OPT_SIGN = $95;
{$EXTERNALSYM LDAP_OPT_ENCRYPT}
LDAP_OPT_ENCRYPT = $96;
//
// The user can set a preferred SASL method prior to binding using LDAP_AUTH_NEGOTIATE
// We will try to use this mechanism while binding. One example is "GSSAPI".
//
{$EXTERNALSYM LDAP_OPT_SASL_METHOD}
LDAP_OPT_SASL_METHOD = $97;
//
// Setting this option to LDAP_OPT_ON will instruct the library to only perform an
// A-Record DNS lookup on the supplied host string. This option is OFF by default.
//
{$EXTERNALSYM LDAP_OPT_AREC_EXCLUSIVE}
LDAP_OPT_AREC_EXCLUSIVE = $98;
//
// Retrieve the security context associated with the connection.
//
{$EXTERNALSYM LDAP_OPT_SECURITY_CONTEXT}
LDAP_OPT_SECURITY_CONTEXT = $99;
//
// End of Microsoft only options
//
{$EXTERNALSYM LDAP_OPT_ON}
LDAP_OPT_ON = Pointer(1);
{$EXTERNALSYM LDAP_OPT_OFF}
LDAP_OPT_OFF = Pointer(0);
//
// For chasing referrals, we extend this a bit for LDAP_OPT_REFERRALS. If
// the value is not LDAP_OPT_ON or LDAP_OPT_OFF, we'll treat them as the
// following :
//
// LDAP_CHASE_SUBORDINATE_REFERRALS : chase subordinate referrals (or
// references) returned in a v3 search
// LDAP_CHASE_EXTERNAL_REFERRALS : chase external referrals. These are
// returned possibly on any operation except bind.
//
// If you OR these flags together, it's equivalent to setting referrals to
// LDAP_OPT_ON.
//
{$EXTERNALSYM LDAP_CHASE_SUBORDINATE_REFERRALS}
LDAP_CHASE_SUBORDINATE_REFERRALS = $00000020;
{$EXTERNALSYM LDAP_CHASE_EXTERNAL_REFERRALS}
LDAP_CHASE_EXTERNAL_REFERRALS = $00000040;
//
// Bind is required as the first operation to v2 servers, not so for v3
// servers. See above description of authentication methods.
//
{$EXTERNALSYM ldap_simple_bindA}
function ldap_simple_bindA(ld: PLDAP; dn, passwd: PAnsiChar): ULONG; cdecl;
{$EXTERNALSYM ldap_simple_bindW}
function ldap_simple_bindW(ld: PLDAP; dn, passwd: PWideChar): ULONG; cdecl;
{$EXTERNALSYM ldap_simple_bind}
function ldap_simple_bind(ld: PLDAP; dn, passwd: PChar): ULONG; cdecl;
{$EXTERNALSYM ldap_simple_bind_sA}
function ldap_simple_bind_sA(ld: PLDAP; dn, passwd: PAnsiChar): ULONG; cdecl;
{$EXTERNALSYM ldap_simple_bind_sW}
function ldap_simple_bind_sW(ld: PLDAP; dn, passwd: PWideChar): ULONG; cdecl;
{$EXTERNALSYM ldap_simple_bind_s}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -