📄 winldap.h
字号:
} LDAP_TIMEVAL, * PLDAP_TIMEVAL;
//
// The berval structure is used to pass in any arbitrary octet string. It
// is useful for attributes that cannot be represented using a null
// terminated string.
//
typedef struct berval {
ULONG bv_len;
PCHAR bv_val;
} LDAP_BERVAL, * PLDAP_BERVAL, BERVAL, * PBERVAL;
//
// The following structure has to be compatible with reference implementation.
//
typedef struct ldapmsg {
ULONG lm_msgid; // message number for given connection
ULONG lm_msgtype; // message type of the form LDAP_RES_xxx
PVOID lm_ber; // ber form of message
struct ldapmsg *lm_chain; // pointer to next result value
struct ldapmsg *lm_next; // pointer to next message
ULONG lm_time;
//
// new fields below not in reference implementation
//
PLDAP Connection; // connection from which we received response
PVOID Request; // owning request (opaque structure)
ULONG lm_returncode; // server's return code
USHORT lm_referral; // index of referral within ref table
BOOLEAN lm_chased; // has referral been chased already?
BOOLEAN lm_eom; // is this the last entry for this message?
BOOLEAN ConnectionReferenced; // is the Connection still valid?
} LDAPMessage, *PLDAPMessage;
//
// Controls... there are three types :
//
// 1) those passed to the server
// 2) those passed to the client and handled by the client API
// 3) those returned by the server
//
typedef struct ldapcontrolA {
PCHAR ldctl_oid;
struct berval ldctl_value;
BOOLEAN ldctl_iscritical;
} LDAPControlA, *PLDAPControlA;
typedef struct ldapcontrolW {
PWCHAR ldctl_oid;
struct berval ldctl_value;
BOOLEAN ldctl_iscritical;
} LDAPControlW, *PLDAPControlW;
#if LDAP_UNICODE
#define LDAPControl LDAPControlW
#define PLDAPControl PLDAPControlW
#else
#define LDAPControl LDAPControlA
#define PLDAPControl PLDAPControlA
#endif
//
// Client controls section : these are the client controls that wldap32.dll
// supports.
//
// If you specify LDAP_CONTROL_REFERRALS in a control, the value field should
// point to a ULONG of the following flags :
//
// LDAP_CHASE_SUBORDINATE_REFERRALS
// LDAP_CHASE_EXTERNAL_REFERRALS
//
#define LDAP_CONTROL_REFERRALS_W L"1.2.840.113556.1.4.616"
#define LDAP_CONTROL_REFERRALS "1.2.840.113556.1.4.616"
//
// Values required for Modification command These are options for the
// mod_op field of LDAPMod structure
//
#define LDAP_MOD_ADD 0x00
#define LDAP_MOD_DELETE 0x01
#define LDAP_MOD_REPLACE 0x02
#define LDAP_MOD_BVALUES 0x80 // AND in this flag if berval structure used
typedef struct ldapmodW {
ULONG mod_op;
PWCHAR mod_type;
union {
PWCHAR *modv_strvals;
struct berval **modv_bvals;
} mod_vals;
} LDAPModW, *PLDAPModW;
typedef struct ldapmodA {
ULONG mod_op;
PCHAR mod_type;
union {
PCHAR *modv_strvals;
struct berval **modv_bvals;
} mod_vals;
} LDAPModA, *PLDAPModA;
#if LDAP_UNICODE
#define LDAPMod LDAPModW
#define PLDAPMod PLDAPModW
#else
#define LDAPMod LDAPModA
#define PLDAPMod PLDAPModA
#endif
#if !defined(_WIN64)
#pragma pack(pop)
#endif
//
// macros compatible with reference implementation...
//
#define LDAP_IS_CLDAP( ld ) ( (ld)->ld_sb.sb_naddr > 0 )
#define mod_values mod_vals.modv_strvals
#define mod_bvalues mod_vals.modv_bvals
#define NAME_ERROR(n) ((n & 0xf0) == 0x20)
//
// 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.
//
// multi-thread: ldap_open*, ldap_init*, and ldap_sslinit* calls are safe.
//
WINLDAPAPI LDAP * LDAPAPI ldap_openW( const PWCHAR HostName, ULONG PortNumber );
WINLDAPAPI LDAP * LDAPAPI ldap_openA( const PCHAR HostName, ULONG PortNumber );
WINLDAPAPI LDAP * LDAPAPI ldap_initW( const PWCHAR HostName, ULONG PortNumber );
WINLDAPAPI LDAP * LDAPAPI ldap_initA( const PCHAR HostName, ULONG PortNumber );
WINLDAPAPI LDAP * LDAPAPI ldap_sslinitW( PWCHAR HostName, ULONG PortNumber, int secure );
WINLDAPAPI LDAP * LDAPAPI ldap_sslinitA( PCHAR HostName, ULONG PortNumber, int secure );
//
// 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.
//
WINLDAPAPI ULONG LDAPAPI ldap_connect( LDAP *ld,
struct l_timeval *timeout
);
#if LDAP_UNICODE
#define ldap_open ldap_openW
#define ldap_init ldap_initW
#define ldap_sslinit ldap_sslinitW
#else
WINLDAPAPI LDAP * LDAPAPI ldap_open( PCHAR HostName, ULONG PortNumber );
WINLDAPAPI LDAP * LDAPAPI ldap_init( PCHAR HostName, ULONG PortNumber );
WINLDAPAPI LDAP * LDAPAPI ldap_sslinit( PCHAR HostName, ULONG PortNumber, int secure );
#endif
//
// 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().
//
// multi-thread: cldap_open* calls are safe.
//
WINLDAPAPI LDAP * LDAPAPI cldap_openW( PWCHAR HostName, ULONG PortNumber );
WINLDAPAPI LDAP * LDAPAPI cldap_openA( PCHAR HostName, ULONG PortNumber );
#if LDAP_UNICODE
#define cldap_open cldap_openW
#else
WINLDAPAPI LDAP * LDAPAPI cldap_open( PCHAR HostName, ULONG PortNumber );
#endif
//
// 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.
//
// multi-thread: ldap_unbind* calls are safe EXCEPT don't use the LDAP *
// stucture after it's been freed.
//
WINLDAPAPI ULONG LDAPAPI ldap_unbind( LDAP *ld );
WINLDAPAPI ULONG LDAPAPI ldap_unbind_s( LDAP *ld ); // calls ldap_unbind
//
// Calls to get and set options on connection blocks... use them rather
// than modifying the LDAP block directly.
//
//
// multi-thread: ldap_get_option is safe
// multi-thread: ldap_set_option is not safe in that it affects the
// connection as a whole. beware if threads share connections.
WINLDAPAPI ULONG LDAPAPI ldap_get_option( LDAP *ld, int option, void *outvalue );
WINLDAPAPI ULONG LDAPAPI ldap_get_optionW( LDAP *ld, int option, void *outvalue );
WINLDAPAPI ULONG LDAPAPI ldap_set_option( LDAP *ld, int option, const void *invalue );
WINLDAPAPI ULONG LDAPAPI ldap_set_optionW( LDAP *ld, int option, const void *invalue );
#if LDAP_UNICODE
#define ldap_get_option ldap_get_optionW
#define ldap_set_option ldap_set_optionW
#endif
//
// These are the values to pass to ldap_get/set_option :
//
#define LDAP_OPT_DESC 0x01
#define LDAP_OPT_DEREF 0x02
#define LDAP_OPT_SIZELIMIT 0x03
#define LDAP_OPT_TIMELIMIT 0x04
#define LDAP_OPT_THREAD_FN_PTRS 0x05
#define LDAP_OPT_REBIND_FN 0x06
#define LDAP_OPT_REBIND_ARG 0x07
#define LDAP_OPT_REFERRALS 0x08
#define LDAP_OPT_RESTART 0x09
#define LDAP_OPT_SSL 0x0a
#define LDAP_OPT_IO_FN_PTRS 0x0b
#define LDAP_OPT_CACHE_FN_PTRS 0x0d
#define LDAP_OPT_CACHE_STRATEGY 0x0e
#define LDAP_OPT_CACHE_ENABLE 0x0f
#define LDAP_OPT_REFERRAL_HOP_LIMIT 0x10
#define LDAP_OPT_PROTOCOL_VERSION 0x11 // known by two names.
#define LDAP_OPT_VERSION 0x11
//
// These are new ones that we've defined, not in current RFC draft.
//
#define LDAP_OPT_HOST_NAME 0x30
#define LDAP_OPT_ERROR_NUMBER 0x31
#define LDAP_OPT_ERROR_STRING 0x32
#define LDAP_OPT_SERVER_ERROR 0x33
#define LDAP_OPT_SERVER_EXT_ERROR 0x34
#define LDAP_OPT_HOST_REACHABLE 0x3E
//
// 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
//
#define LDAP_OPT_PING_KEEP_ALIVE 0x36
#define LDAP_OPT_PING_WAIT_TIME 0x37
#define LDAP_OPT_PING_LIMIT 0x38
//
// These won't be in the RFC. Only use these if you're going to be dependent
// on our implementation.
//
#define LDAP_OPT_DNSDOMAIN_NAME 0x3B // return DNS name of domain
#define LDAP_OPT_GETDSNAME_FLAGS 0x3D // flags for DsGetDcName
#define LDAP_OPT_PROMPT_CREDENTIALS 0x3F // prompt for creds? currently
// only for DPA & NTLM if no creds
// are loaded
#define LDAP_OPT_AUTO_RECONNECT 0x91 // enable/disable autoreconnect
#define LDAP_OPT_SSPI_FLAGS 0x92 // 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.
//
#define LDAP_OPT_SSL_INFO 0x93
//
// 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.
//
#define LDAP_OPT_SIGN 0x95
#define LDAP_OPT_ENCRYPT 0x96
//
// 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".
//
#define LDAP_OPT_SASL_METHOD 0x97
//
// 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.
//
#define LDAP_OPT_AREC_EXCLUSIVE 0x98
//
// Retrieve the security context associated with the connection.
//
#define LDAP_OPT_SECURITY_CONTEXT 0x99
//
// End of Microsoft only options
//
#define LDAP_OPT_ON ((void *) 1)
#define LDAP_OPT_OFF ((void *) 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.
//
#define LDAP_CHASE_SUBORDINATE_REFERRALS 0x00000020
#define LDAP_CHASE_EXTERNAL_REFERRALS 0x00000040
//
// Bind is required as the first operation to v2 servers, not so for v3
// servers. See above description of authentication methods.
//
// multi-thread: bind calls are not safe in that it affects the
// connection as a whole. beware if threads share connections
// and try to mulithread binds with other operations.
WINLDAPAPI ULONG LDAPAPI ldap_simple_bindW( LDAP *ld, PWCHAR dn, PWCHAR passwd );
WINLDAPAPI ULONG LDAPAPI ldap_simple_bindA( LDAP *ld, PCHAR dn, PCHAR passwd );
WINLDAPAPI ULONG LDAPAPI ldap_simple_bind_sW( LDAP *ld, PWCHAR dn, PWCHAR passwd );
WINLDAPAPI ULONG LDAPAPI ldap_simple_bind_sA( LDAP *ld, PCHAR dn, PCHAR passwd );
WINLDAPAPI ULONG LDAPAPI ldap_bindW( LDAP *ld, PWCHAR dn, PWCHAR cred, ULONG method );
WINLDAPAPI ULONG LDAPAPI ldap_bindA( LDAP *ld, PCHAR dn, PCHAR cred, ULONG method );
WINLDAPAPI ULONG LDAPAPI ldap_bind_sW( LDAP *ld, PWCHAR dn, PWCHAR cred, ULONG method );
WINLDAPAPI ULONG LDAPAPI ldap_bind_sA( LDAP *ld, PCHAR dn, PCHAR cred, ULONG method );
//
// The following functions can be used to pass in any arbitrary credentials
// to the server. The application must be ready to interpret the response
// sent back from the server.
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -