Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3273 lines
100 KiB

  1. /*++
  2. Copyright (c) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. winldap.h LDAP client 32 API header file
  5. Abstract:
  6. This module is the header file for the 32 bit LDAP client API for
  7. Windows NT and Windows 95. This API is based on RFC 1823 with some
  8. enhancements for LDAP v3.
  9. Notes about Unicode support :
  10. If you have UNICODE defined at compile time, you'll pull in the unicode
  11. versions of the calls. Note that your executable may then not work with
  12. other implementations of the LDAP API that don't support Unicode. If
  13. UNICODE is not defined, then we define the LDAP calls without the trailing
  14. 'A' (as in ldap_bind rather than ldap_bindA) so that your app may work
  15. with other implementations that don't support Unicode.
  16. The import library has all three forms of the call present... ldap_bindW,
  17. ldap_bindA, and ldap_bind. ldap_bindA simply calls ldap_bind. ldap_bind
  18. simply converts the arguments to unicode and calls ldap_bindW. The
  19. reason this is done is because we have to put UTF-8 on the wire, so if
  20. we converted from Unicode to single byte, we'd loose information. Since
  21. all core processing is done in Unicode, nothing is lost.
  22. Updates :
  23. 11/01/96 Modified for new API RFC draft.
  24. Environments :
  25. Win32 user mode
  26. --*/
  27. //
  28. // Only pull in this header file once... controlled by LDAP_CLIENT_DEFINED
  29. // variable.
  30. //
  31. #ifndef LDAP_CLIENT_DEFINED
  32. #define LDAP_CLIENT_DEFINED
  33. #if _MSC_VER > 1000
  34. #pragma once
  35. #endif
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. #ifndef BASETYPES
  40. #include <windef.h>
  41. #endif
  42. #ifndef _SCHNLSP_H_
  43. #include <schnlsp.h>
  44. #endif
  45. #if !defined(_WINLDAP_)
  46. #define WINLDAPAPI DECLSPEC_IMPORT
  47. #else
  48. //#define WINLDAPAPI __declspec(dllexport)
  49. #define WINLDAPAPI
  50. #endif
  51. #ifndef LDAPAPI
  52. #define LDAPAPI __cdecl
  53. #endif
  54. //
  55. // The #define LDAP_UNICODE controls if we map the undecorated calls to
  56. // their unicode counterparts or just leave them defined as the normal
  57. // single byte entry points.
  58. //
  59. // If you want to write a UNICODE enabled application, you'd normally
  60. // just have UNICODE defined and then we'll default to using all LDAP
  61. // Unicode calls.
  62. //
  63. #ifndef LDAP_UNICODE
  64. #ifdef UNICODE
  65. #define LDAP_UNICODE 1
  66. #else
  67. #define LDAP_UNICODE 0
  68. #endif
  69. #endif
  70. //
  71. // Global constants
  72. //
  73. #define LDAP_PORT 389
  74. #define LDAP_SSL_PORT 636
  75. #define LDAP_GC_PORT 3268
  76. #define LDAP_SSL_GC_PORT 3269
  77. //
  78. // The default version of the API is 2. If required, the user MUST set the
  79. // version to 3 using the LDAP_OPT_VERSION option.
  80. //
  81. #define LDAP_VERSION1 1
  82. #define LDAP_VERSION2 2
  83. #define LDAP_VERSION3 3
  84. #define LDAP_VERSION LDAP_VERSION2
  85. //
  86. // All tags are CCFTTTTT.
  87. // CC Tag Class 00 = universal
  88. // 01 = application wide
  89. // 10 = context specific
  90. // 11 = private use
  91. //
  92. // F Form 0 primitive
  93. // 1 constructed
  94. //
  95. // TTTTT Tag Number
  96. //
  97. //
  98. // LDAP v2 & v3 commands.
  99. //
  100. #define LDAP_BIND_CMD 0x60L // application + constructed
  101. #define LDAP_UNBIND_CMD 0x42L // application + primitive
  102. #define LDAP_SEARCH_CMD 0x63L // application + constructed
  103. #define LDAP_MODIFY_CMD 0x66L // application + constructed
  104. #define LDAP_ADD_CMD 0x68L // application + constructed
  105. #define LDAP_DELETE_CMD 0x4aL // application + primitive
  106. #define LDAP_MODRDN_CMD 0x6cL // application + constructed
  107. #define LDAP_COMPARE_CMD 0x6eL // application + constructed
  108. #define LDAP_ABANDON_CMD 0x50L // application + primitive
  109. #define LDAP_SESSION_CMD 0x71L // not in base LDAP protocol
  110. #define LDAP_EXTENDED_CMD 0x77L // application + constructed
  111. //
  112. // Responses/Results for LDAP v2 & v3
  113. //
  114. #define LDAP_RES_BIND 0x61L // application + constructed
  115. #define LDAP_RES_SEARCH_ENTRY 0x64L // application + constructed
  116. #define LDAP_RES_SEARCH_RESULT 0x65L // application + constructed
  117. #define LDAP_RES_MODIFY 0x67L // application + constructed
  118. #define LDAP_RES_ADD 0x69L // application + constructed
  119. #define LDAP_RES_DELETE 0x6bL // application + constructed
  120. #define LDAP_RES_MODRDN 0x6dL // application + constructed
  121. #define LDAP_RES_COMPARE 0x6fL // application + constructed
  122. #define LDAP_RES_SESSION 0x72L // not in base LDAP protocol
  123. #define LDAP_RES_REFERRAL 0x73L // application + constructed
  124. #define LDAP_RES_EXTENDED 0x78L // application + constructed
  125. #define LDAP_RES_ANY (-1L)
  126. #define LDAP_INVALID_CMD 0xff
  127. #define LDAP_INVALID_RES 0xff
  128. //
  129. // We'll make the error codes compatible with reference implementation
  130. //
  131. typedef enum {
  132. LDAP_SUCCESS = 0x00,
  133. LDAP_OPERATIONS_ERROR = 0x01,
  134. LDAP_PROTOCOL_ERROR = 0x02,
  135. LDAP_TIMELIMIT_EXCEEDED = 0x03,
  136. LDAP_SIZELIMIT_EXCEEDED = 0x04,
  137. LDAP_COMPARE_FALSE = 0x05,
  138. LDAP_COMPARE_TRUE = 0x06,
  139. LDAP_AUTH_METHOD_NOT_SUPPORTED = 0x07,
  140. LDAP_STRONG_AUTH_REQUIRED = 0x08,
  141. LDAP_REFERRAL_V2 = 0x09,
  142. LDAP_PARTIAL_RESULTS = 0x09,
  143. LDAP_REFERRAL = 0x0a,
  144. LDAP_ADMIN_LIMIT_EXCEEDED = 0x0b,
  145. LDAP_UNAVAILABLE_CRIT_EXTENSION = 0x0c,
  146. LDAP_CONFIDENTIALITY_REQUIRED = 0x0d,
  147. LDAP_SASL_BIND_IN_PROGRESS = 0x0e,
  148. LDAP_NO_SUCH_ATTRIBUTE = 0x10,
  149. LDAP_UNDEFINED_TYPE = 0x11,
  150. LDAP_INAPPROPRIATE_MATCHING = 0x12,
  151. LDAP_CONSTRAINT_VIOLATION = 0x13,
  152. LDAP_ATTRIBUTE_OR_VALUE_EXISTS = 0x14,
  153. LDAP_INVALID_SYNTAX = 0x15,
  154. LDAP_NO_SUCH_OBJECT = 0x20,
  155. LDAP_ALIAS_PROBLEM = 0x21,
  156. LDAP_INVALID_DN_SYNTAX = 0x22,
  157. LDAP_IS_LEAF = 0x23,
  158. LDAP_ALIAS_DEREF_PROBLEM = 0x24,
  159. LDAP_INAPPROPRIATE_AUTH = 0x30,
  160. LDAP_INVALID_CREDENTIALS = 0x31,
  161. LDAP_INSUFFICIENT_RIGHTS = 0x32,
  162. LDAP_BUSY = 0x33,
  163. LDAP_UNAVAILABLE = 0x34,
  164. LDAP_UNWILLING_TO_PERFORM = 0x35,
  165. LDAP_LOOP_DETECT = 0x36,
  166. LDAP_SORT_CONTROL_MISSING = 0x3C,
  167. LDAP_OFFSET_RANGE_ERROR = 0x3D,
  168. LDAP_NAMING_VIOLATION = 0x40,
  169. LDAP_OBJECT_CLASS_VIOLATION = 0x41,
  170. LDAP_NOT_ALLOWED_ON_NONLEAF = 0x42,
  171. LDAP_NOT_ALLOWED_ON_RDN = 0x43,
  172. LDAP_ALREADY_EXISTS = 0x44,
  173. LDAP_NO_OBJECT_CLASS_MODS = 0x45,
  174. LDAP_RESULTS_TOO_LARGE = 0x46,
  175. LDAP_AFFECTS_MULTIPLE_DSAS = 0x47,
  176. LDAP_VIRTUAL_LIST_VIEW_ERROR = 0x4c,
  177. LDAP_OTHER = 0x50,
  178. LDAP_SERVER_DOWN = 0x51,
  179. LDAP_LOCAL_ERROR = 0x52,
  180. LDAP_ENCODING_ERROR = 0x53,
  181. LDAP_DECODING_ERROR = 0x54,
  182. LDAP_TIMEOUT = 0x55,
  183. LDAP_AUTH_UNKNOWN = 0x56,
  184. LDAP_FILTER_ERROR = 0x57,
  185. LDAP_USER_CANCELLED = 0x58,
  186. LDAP_PARAM_ERROR = 0x59,
  187. LDAP_NO_MEMORY = 0x5a,
  188. LDAP_CONNECT_ERROR = 0x5b,
  189. LDAP_NOT_SUPPORTED = 0x5c,
  190. LDAP_NO_RESULTS_RETURNED = 0x5e,
  191. LDAP_CONTROL_NOT_FOUND = 0x5d,
  192. LDAP_MORE_RESULTS_TO_RETURN = 0x5f,
  193. LDAP_CLIENT_LOOP = 0x60,
  194. LDAP_REFERRAL_LIMIT_EXCEEDED = 0x61
  195. } LDAP_RETCODE;
  196. //
  197. // Bind methods. We support the following methods :
  198. //
  199. // Simple Clear text password... try not to use as it's not secure.
  200. //
  201. // MSN MSN (Microsoft Network) authentication. This package
  202. // may bring up UI to prompt the user for MSN credentials.
  203. //
  204. // DPA Normandy authentication... new MSN authentication. Same
  205. // usage as MSN.
  206. //
  207. // NTLM NT domain authentication. Use NULL credentials and
  208. // we'll try to use default logged in user credentials.
  209. //
  210. // Sicily Negotiate with the server for any of: MSN, DPA, NTLM
  211. // Should be used for LDAPv2 servers only.
  212. //
  213. // Negotiate Use GSSAPI Negotiate package to negotiate security
  214. // package of either Kerberos v5 or NTLM (or any other
  215. // package the client and server negotiate). Pass in
  216. // NULL credentials to specify default logged in user.
  217. // If Negotiate package is not installed on server or
  218. // client, this will fall back to Sicily negotiation.
  219. //
  220. // For all bind methods except for Simple, you may pass in a
  221. // SEC_WINNT_AUTH_IDENTITY_W (defined in rpcdce.h) or the newer
  222. // SEC_WINNT_AUTH_IDENTITY_EXW (defined in secext.h) to specify alternate
  223. // credentials.
  224. //
  225. // All bind methods other than simple are synchronous only calls.
  226. // Calling the asynchronous bind call for any of these messages will
  227. // return LDAP_PARAM_ERROR.
  228. //
  229. // Using any other method besides simple will cause WLDAP32 to pull in
  230. // the SSPI security DLLs (SECURITY.DLL etc).
  231. //
  232. // On non-Simple methods, if you specify NULL credentials, we'll attempt to use
  233. // the default logged in user.
  234. //
  235. #define LDAP_AUTH_SIMPLE 0x80L
  236. #define LDAP_AUTH_SASL 0x83L // don't use... should go away
  237. #define LDAP_AUTH_OTHERKIND 0x86L
  238. // The SICILY type covers package negotiation to MSN servers.
  239. // Each of the supported types can also be specified without
  240. // doing the package negotiation, assuming the caller knows
  241. // what the server supports.
  242. #define LDAP_AUTH_SICILY (LDAP_AUTH_OTHERKIND | 0x0200)
  243. #define LDAP_AUTH_MSN (LDAP_AUTH_OTHERKIND | 0x0800)
  244. #define LDAP_AUTH_NTLM (LDAP_AUTH_OTHERKIND | 0x1000)
  245. #define LDAP_AUTH_DPA (LDAP_AUTH_OTHERKIND | 0x2000)
  246. // This will cause the client to use the GSSAPI negotiation
  247. // package to determine the most appropriate authentication type.
  248. // This type should be used when talking to NT5.
  249. #define LDAP_AUTH_NEGOTIATE (LDAP_AUTH_OTHERKIND | 0x0400)
  250. // backward compatible #define for older constant name.
  251. #define LDAP_AUTH_SSPI LDAP_AUTH_NEGOTIATE
  252. //
  253. // uses the DIGEST-MD5 mechanism.
  254. //
  255. #define LDAP_AUTH_DIGEST (LDAP_AUTH_OTHERKIND | 0x4000)
  256. // The external auth mechanism is used upon setting up an SSL/TLS connection
  257. // to denote that the server must use the client cert credentials presented
  258. // at the outset of the SSL/TLS connection.
  259. #define LDAP_AUTH_EXTERNAL (LDAP_AUTH_OTHERKIND | 0x0020)
  260. //
  261. // Client applications typically don't have to encode/decode LDAP filters,
  262. // but if they do, we define the operators here.
  263. //
  264. // Filter types.
  265. #define LDAP_FILTER_AND 0xa0 // context specific + constructed - SET OF Filters.
  266. #define LDAP_FILTER_OR 0xa1 // context specific + constructed - SET OF Filters.
  267. #define LDAP_FILTER_NOT 0xa2 // context specific + constructed - Filter
  268. #define LDAP_FILTER_EQUALITY 0xa3 // context specific + constructed - AttributeValueAssertion.
  269. #define LDAP_FILTER_SUBSTRINGS 0xa4 // context specific + constructed - SubstringFilter
  270. #define LDAP_FILTER_GE 0xa5 // context specific + constructed - AttributeValueAssertion.
  271. #define LDAP_FILTER_LE 0xa6 // context specific + constructed - AttributeValueAssertion.
  272. #define LDAP_FILTER_PRESENT 0x87 // context specific + primitive - AttributeType.
  273. #define LDAP_FILTER_APPROX 0xa8 // context specific + constructed - AttributeValueAssertion.
  274. #define LDAP_FILTER_EXTENSIBLE 0xa9 // context specific + constructed - MatchingRuleAssertion.
  275. // Substring filter types
  276. #define LDAP_SUBSTRING_INITIAL 0x80L // class context specific
  277. #define LDAP_SUBSTRING_ANY 0x81L // class context specific
  278. #define LDAP_SUBSTRING_FINAL 0x82L // class context specific
  279. //
  280. // Possible values for ld_deref field.
  281. // "Never" - never deref aliases. return only the alias.
  282. // "Searching" - only deref aliases when searching, not when locating
  283. // the base object of a search.
  284. // "Finding" - dereference the alias when locating the base object but
  285. // not during a search.
  286. // "Always" - always dereference aliases.
  287. //
  288. #define LDAP_DEREF_NEVER 0
  289. #define LDAP_DEREF_SEARCHING 1
  290. #define LDAP_DEREF_FINDING 2
  291. #define LDAP_DEREF_ALWAYS 3
  292. // Special values for ld_sizelimit :
  293. #define LDAP_NO_LIMIT 0
  294. // Flags for ld_options field :
  295. #define LDAP_OPT_DNS 0x00000001 // utilize DN & DNS
  296. #define LDAP_OPT_CHASE_REFERRALS 0x00000002 // chase referrals
  297. #define LDAP_OPT_RETURN_REFS 0x00000004 // return referrals to calling app
  298. //
  299. // LDAP structure per connection
  300. //
  301. #if !defined(_WIN64)
  302. #pragma pack(push, 4)
  303. #endif
  304. typedef struct ldap {
  305. struct {
  306. UINT_PTR sb_sd;
  307. UCHAR Reserved1[(10*sizeof(ULONG))+1];
  308. ULONG_PTR sb_naddr; // notzero implies CLDAP available
  309. UCHAR Reserved2[(6*sizeof(ULONG))];
  310. } ld_sb;
  311. //
  312. // Following parameters MAY match up to reference implementation of LDAP
  313. //
  314. PCHAR ld_host;
  315. ULONG ld_version;
  316. UCHAR ld_lberoptions;
  317. //
  318. // Safe to assume that these parameters are in same location as
  319. // reference implementation of LDAP API.
  320. //
  321. ULONG ld_deref;
  322. ULONG ld_timelimit;
  323. ULONG ld_sizelimit;
  324. ULONG ld_errno;
  325. PCHAR ld_matched;
  326. PCHAR ld_error;
  327. ULONG ld_msgid;
  328. UCHAR Reserved3[(6*sizeof(ULONG))+1];
  329. //
  330. // Following parameters may match up to reference implementation of LDAP API.
  331. //
  332. ULONG ld_cldaptries;
  333. ULONG ld_cldaptimeout;
  334. ULONG ld_refhoplimit;
  335. ULONG ld_options;
  336. } LDAP, * PLDAP;
  337. //
  338. // Our timeval structure is a bit different from the reference implementation
  339. // since Win32 defines a _timeval structure that is different from the LDAP
  340. // one.
  341. //
  342. typedef struct l_timeval {
  343. LONG tv_sec;
  344. LONG tv_usec;
  345. } LDAP_TIMEVAL, * PLDAP_TIMEVAL;
  346. //
  347. // The berval structure is used to pass in any arbitrary octet string. It
  348. // is useful for attributes that cannot be represented using a null
  349. // terminated string.
  350. //
  351. typedef struct berval {
  352. ULONG bv_len;
  353. PCHAR bv_val;
  354. } LDAP_BERVAL, * PLDAP_BERVAL, BERVAL, * PBERVAL, BerValue;
  355. //
  356. // The following structure has to be compatible with reference implementation.
  357. //
  358. typedef struct ldapmsg {
  359. ULONG lm_msgid; // message number for given connection
  360. ULONG lm_msgtype; // message type of the form LDAP_RES_xxx
  361. PVOID lm_ber; // ber form of message
  362. struct ldapmsg *lm_chain; // pointer to next result value
  363. struct ldapmsg *lm_next; // pointer to next message
  364. ULONG lm_time;
  365. //
  366. // new fields below not in reference implementation
  367. //
  368. PLDAP Connection; // connection from which we received response
  369. PVOID Request; // owning request (opaque structure)
  370. ULONG lm_returncode; // server's return code
  371. USHORT lm_referral; // index of referral within ref table
  372. BOOLEAN lm_chased; // has referral been chased already?
  373. BOOLEAN lm_eom; // is this the last entry for this message?
  374. BOOLEAN ConnectionReferenced; // is the Connection still valid?
  375. } LDAPMessage, *PLDAPMessage;
  376. //
  377. // Controls... there are three types :
  378. //
  379. // 1) those passed to the server
  380. // 2) those passed to the client and handled by the client API
  381. // 3) those returned by the server
  382. //
  383. typedef struct ldapcontrolA {
  384. PCHAR ldctl_oid;
  385. struct berval ldctl_value;
  386. BOOLEAN ldctl_iscritical;
  387. } LDAPControlA, *PLDAPControlA;
  388. typedef struct ldapcontrolW {
  389. PWCHAR ldctl_oid;
  390. struct berval ldctl_value;
  391. BOOLEAN ldctl_iscritical;
  392. } LDAPControlW, *PLDAPControlW;
  393. #if LDAP_UNICODE
  394. #define LDAPControl LDAPControlW
  395. #define PLDAPControl PLDAPControlW
  396. #else
  397. #define LDAPControl LDAPControlA
  398. #define PLDAPControl PLDAPControlA
  399. #endif
  400. //
  401. // Client controls section : these are the client controls that wldap32.dll
  402. // supports.
  403. //
  404. // If you specify LDAP_CONTROL_REFERRALS in a control, the value field should
  405. // point to a ULONG of the following flags :
  406. //
  407. // LDAP_CHASE_SUBORDINATE_REFERRALS
  408. // LDAP_CHASE_EXTERNAL_REFERRALS
  409. //
  410. #define LDAP_CONTROL_REFERRALS_W L"1.2.840.113556.1.4.616"
  411. #define LDAP_CONTROL_REFERRALS "1.2.840.113556.1.4.616"
  412. //
  413. // Values required for Modification command These are options for the
  414. // mod_op field of LDAPMod structure
  415. //
  416. #define LDAP_MOD_ADD 0x00
  417. #define LDAP_MOD_DELETE 0x01
  418. #define LDAP_MOD_REPLACE 0x02
  419. #define LDAP_MOD_BVALUES 0x80 // AND in this flag if berval structure used
  420. typedef struct ldapmodW {
  421. ULONG mod_op;
  422. PWCHAR mod_type;
  423. union {
  424. PWCHAR *modv_strvals;
  425. struct berval **modv_bvals;
  426. } mod_vals;
  427. } LDAPModW, *PLDAPModW;
  428. typedef struct ldapmodA {
  429. ULONG mod_op;
  430. PCHAR mod_type;
  431. union {
  432. PCHAR *modv_strvals;
  433. struct berval **modv_bvals;
  434. } mod_vals;
  435. } LDAPModA, *PLDAPModA;
  436. #if LDAP_UNICODE
  437. #define LDAPMod LDAPModW
  438. #define PLDAPMod PLDAPModW
  439. #else
  440. #define LDAPMod LDAPModA
  441. #define PLDAPMod PLDAPModA
  442. #endif
  443. #if !defined(_WIN64)
  444. #pragma pack(pop)
  445. #endif
  446. //
  447. // macros compatible with reference implementation...
  448. //
  449. #define LDAP_IS_CLDAP( ld ) ( (ld)->ld_sb.sb_naddr > 0 )
  450. #define mod_values mod_vals.modv_strvals
  451. #define mod_bvalues mod_vals.modv_bvals
  452. #define NAME_ERROR(n) ((n & 0xf0) == 0x20)
  453. //
  454. // function definitions for LDAP API
  455. //
  456. //
  457. // Create a connection block to an LDAP server. HostName can be NULL, in
  458. // which case we'll try to go off and find the "default" LDAP server.
  459. //
  460. // Note that if we have to go off and find the default server, we'll pull
  461. // in NETAPI32.DLL and ADVAPI32.DLL.
  462. //
  463. // If it returns NULL, an error occurred. Pick up error code with
  464. // GetLastError().
  465. //
  466. // ldap_open actually opens the connection at the time of the call,
  467. // whereas ldap_init only opens the connection when an operation is performed
  468. // that requires it.
  469. //
  470. // multi-thread: ldap_open*, ldap_init*, and ldap_sslinit* calls are safe.
  471. //
  472. WINLDAPAPI LDAP * LDAPAPI ldap_openW( const PWCHAR HostName, ULONG PortNumber );
  473. WINLDAPAPI LDAP * LDAPAPI ldap_openA( const PCHAR HostName, ULONG PortNumber );
  474. WINLDAPAPI LDAP * LDAPAPI ldap_initW( const PWCHAR HostName, ULONG PortNumber );
  475. WINLDAPAPI LDAP * LDAPAPI ldap_initA( const PCHAR HostName, ULONG PortNumber );
  476. WINLDAPAPI LDAP * LDAPAPI ldap_sslinitW( PWCHAR HostName, ULONG PortNumber, int secure );
  477. WINLDAPAPI LDAP * LDAPAPI ldap_sslinitA( PCHAR HostName, ULONG PortNumber, int secure );
  478. //
  479. // when calling ldap_init, you can call ldap_connect explicitly to have the
  480. // library contact the server. This is useful for checking for server
  481. // availability. This call is not required however, since the other functions
  482. // will call it internally if it hasn't already been called.
  483. //
  484. WINLDAPAPI ULONG LDAPAPI ldap_connect( LDAP *ld,
  485. struct l_timeval *timeout
  486. );
  487. #if LDAP_UNICODE
  488. #define ldap_open ldap_openW
  489. #define ldap_init ldap_initW
  490. #define ldap_sslinit ldap_sslinitW
  491. #else
  492. WINLDAPAPI LDAP * LDAPAPI ldap_open( PCHAR HostName, ULONG PortNumber );
  493. WINLDAPAPI LDAP * LDAPAPI ldap_init( PCHAR HostName, ULONG PortNumber );
  494. WINLDAPAPI LDAP * LDAPAPI ldap_sslinit( PCHAR HostName, ULONG PortNumber, int secure );
  495. #endif
  496. //
  497. // This is similar to ldap_open except it creates a connection block for
  498. // UDP based Connectionless LDAP services. No TCP session is maintained.
  499. //
  500. // If it returns NULL, an error occurred. Pick up error code with
  501. // GetLastError().
  502. //
  503. // multi-thread: cldap_open* calls are safe.
  504. //
  505. WINLDAPAPI LDAP * LDAPAPI cldap_openW( PWCHAR HostName, ULONG PortNumber );
  506. WINLDAPAPI LDAP * LDAPAPI cldap_openA( PCHAR HostName, ULONG PortNumber );
  507. #if LDAP_UNICODE
  508. #define cldap_open cldap_openW
  509. #else
  510. WINLDAPAPI LDAP * LDAPAPI cldap_open( PCHAR HostName, ULONG PortNumber );
  511. #endif
  512. //
  513. // Call unbind when you're done with the connection, it will free all
  514. // resources associated with the connection.
  515. //
  516. // There is no ldap_close... use ldap_unbind even if you haven't called
  517. // ldap_bind on the connection.
  518. //
  519. // multi-thread: ldap_unbind* calls are safe EXCEPT don't use the LDAP *
  520. // stucture after it's been freed.
  521. //
  522. WINLDAPAPI ULONG LDAPAPI ldap_unbind( LDAP *ld );
  523. WINLDAPAPI ULONG LDAPAPI ldap_unbind_s( LDAP *ld ); // calls ldap_unbind
  524. //
  525. // Calls to get and set options on connection blocks... use them rather
  526. // than modifying the LDAP block directly.
  527. //
  528. //
  529. // multi-thread: ldap_get_option is safe
  530. // multi-thread: ldap_set_option is not safe in that it affects the
  531. // connection as a whole. beware if threads share connections.
  532. WINLDAPAPI ULONG LDAPAPI ldap_get_option( LDAP *ld, int option, void *outvalue );
  533. WINLDAPAPI ULONG LDAPAPI ldap_get_optionW( LDAP *ld, int option, void *outvalue );
  534. WINLDAPAPI ULONG LDAPAPI ldap_set_option( LDAP *ld, int option, const void *invalue );
  535. WINLDAPAPI ULONG LDAPAPI ldap_set_optionW( LDAP *ld, int option, const void *invalue );
  536. #if LDAP_UNICODE
  537. #define ldap_get_option ldap_get_optionW
  538. #define ldap_set_option ldap_set_optionW
  539. #endif
  540. //
  541. // These are the values to pass to ldap_get/set_option :
  542. //
  543. #define LDAP_OPT_API_INFO 0x00
  544. #define LDAP_OPT_DESC 0x01
  545. #define LDAP_OPT_DEREF 0x02
  546. #define LDAP_OPT_SIZELIMIT 0x03
  547. #define LDAP_OPT_TIMELIMIT 0x04
  548. #define LDAP_OPT_THREAD_FN_PTRS 0x05
  549. #define LDAP_OPT_REBIND_FN 0x06
  550. #define LDAP_OPT_REBIND_ARG 0x07
  551. #define LDAP_OPT_REFERRALS 0x08
  552. #define LDAP_OPT_RESTART 0x09
  553. #define LDAP_OPT_SSL 0x0a
  554. #define LDAP_OPT_IO_FN_PTRS 0x0b
  555. #define LDAP_OPT_CACHE_FN_PTRS 0x0d
  556. #define LDAP_OPT_CACHE_STRATEGY 0x0e
  557. #define LDAP_OPT_CACHE_ENABLE 0x0f
  558. #define LDAP_OPT_REFERRAL_HOP_LIMIT 0x10
  559. #define LDAP_OPT_PROTOCOL_VERSION 0x11 // known by two names.
  560. #define LDAP_OPT_VERSION 0x11
  561. #define LDAP_OPT_API_FEATURE_INFO 0x15
  562. //
  563. // These are new ones that we've defined, not in current RFC draft.
  564. //
  565. #define LDAP_OPT_HOST_NAME 0x30
  566. #define LDAP_OPT_ERROR_NUMBER 0x31
  567. #define LDAP_OPT_ERROR_STRING 0x32
  568. #define LDAP_OPT_SERVER_ERROR 0x33
  569. #define LDAP_OPT_SERVER_EXT_ERROR 0x34
  570. #define LDAP_OPT_HOST_REACHABLE 0x3E
  571. //
  572. // These options control the keep-alive logic. Keep alives are sent as
  573. // ICMP ping messages (which currently don't go through firewalls).
  574. //
  575. // There are three values that control how this works :
  576. // PING_KEEP_ALIVE : min number of seconds since we last received a response
  577. // from the server before we send a keep-alive ping
  578. // PING_WAIT_TIME : number of milliseconds we wait for the response to
  579. // come back when we send a ping
  580. // PING_LIMIT : number of unanswered pings we send before we close the
  581. // connection.
  582. //
  583. // To disable the keep-alive logic, set any of the values (PING_KEEP_ALIVE,
  584. // PING_LIMIT, or PING_WAIT_TIME) to zero.
  585. //
  586. // The current default/min/max for these values are as follows :
  587. //
  588. // PING_KEEP_ALIVE : 120/5/maxInt seconds (may also be zero)
  589. // PING_WAIT_TIME : 2000/10/60000 milliseconds (may also be zero)
  590. // PING_LIMIT : 4/0/maxInt
  591. //
  592. #define LDAP_OPT_PING_KEEP_ALIVE 0x36
  593. #define LDAP_OPT_PING_WAIT_TIME 0x37
  594. #define LDAP_OPT_PING_LIMIT 0x38
  595. //
  596. // These won't be in the RFC. Only use these if you're going to be dependent
  597. // on our implementation.
  598. //
  599. #define LDAP_OPT_DNSDOMAIN_NAME 0x3B // return DNS name of domain
  600. #define LDAP_OPT_GETDSNAME_FLAGS 0x3D // flags for DsGetDcName
  601. #define LDAP_OPT_PROMPT_CREDENTIALS 0x3F // prompt for creds? currently
  602. // only for DPA & NTLM if no creds
  603. // are loaded
  604. #define LDAP_OPT_AUTO_RECONNECT 0x91 // enable/disable autoreconnect
  605. #define LDAP_OPT_SSPI_FLAGS 0x92 // flags to pass to InitSecurityContext
  606. //
  607. // To retrieve information on an secure connection, a pointer to a
  608. // SecPkgContext_connectionInfo structure (defined in schannel.h) must be
  609. // passed in. On success, it is filled with relevent security information.
  610. //
  611. #define LDAP_OPT_SSL_INFO 0x93
  612. // backward compatible #define for older constant name.
  613. #define LDAP_OPT_TLS LDAP_OPT_SSL
  614. #define LDAP_OPT_TLS_INFO LDAP_OPT_SSL_INFO
  615. //
  616. // Turing on either the sign or the encrypt option prior to binding using
  617. // LDAP_AUTH_NEGOTIATE will result in the ensuing LDAP session to be signed
  618. // or encrypted using Kerberos. Note that these options can't be used with SSL.
  619. //
  620. #define LDAP_OPT_SIGN 0x95
  621. #define LDAP_OPT_ENCRYPT 0x96
  622. //
  623. // The user can set a preferred SASL method prior to binding using LDAP_AUTH_NEGOTIATE
  624. // We will try to use this mechanism while binding. One example is "GSSAPI".
  625. //
  626. #define LDAP_OPT_SASL_METHOD 0x97
  627. //
  628. // Setting this option to LDAP_OPT_ON will instruct the library to only perform an
  629. // A-Record DNS lookup on the supplied host string. This option is OFF by default.
  630. //
  631. #define LDAP_OPT_AREC_EXCLUSIVE 0x98
  632. //
  633. // Retrieve the security context associated with the connection.
  634. //
  635. #define LDAP_OPT_SECURITY_CONTEXT 0x99
  636. //
  637. // Enable/Disable the built-in RootDSE cache. This option is ON by default.
  638. //
  639. #define LDAP_OPT_ROOTDSE_CACHE 0x9a
  640. //
  641. // Turns on TCP keep-alives. This is separate from the ICMP ping keep-alive
  642. // mechanism (discussed above), and enables the keep-alive mechanism built into
  643. // the TCP protocol. This has no effect when using connectionless (UDP) LDAP.
  644. // This option is OFF by default.
  645. //
  646. #define LDAP_OPT_TCP_KEEPALIVE 0x40
  647. //
  648. // Turns on support for fast concurrent binds (extended operation
  649. // 1.2.840.113556.1.4.1781). This option can be set only on a fresh
  650. // (never bound/authenticated) connection. Setting this option will
  651. // (1) switch the client into a mode where it supports simultaneous
  652. // simple binds on the connection, and (2) sends the extended operation
  653. // to the server to switch it into fast bind mode. Only simple binds
  654. // are supported in this mode.
  655. //
  656. #define LDAP_OPT_FAST_CONCURRENT_BIND 0x41
  657. #define LDAP_OPT_SEND_TIMEOUT 0x42
  658. //
  659. // End of Microsoft only options
  660. //
  661. #define LDAP_OPT_ON ((void *) 1)
  662. #define LDAP_OPT_OFF ((void *) 0)
  663. //
  664. // For chasing referrals, we extend this a bit for LDAP_OPT_REFERRALS. If
  665. // the value is not LDAP_OPT_ON or LDAP_OPT_OFF, we'll treat them as the
  666. // following :
  667. //
  668. // LDAP_CHASE_SUBORDINATE_REFERRALS : chase subordinate referrals (or
  669. // references) returned in a v3 search
  670. // LDAP_CHASE_EXTERNAL_REFERRALS : chase external referrals. These are
  671. // returned possibly on any operation except bind.
  672. //
  673. // If you OR these flags together, it's equivalent to setting referrals to
  674. // LDAP_OPT_ON.
  675. //
  676. #define LDAP_CHASE_SUBORDINATE_REFERRALS 0x00000020
  677. #define LDAP_CHASE_EXTERNAL_REFERRALS 0x00000040
  678. //
  679. // Bind is required as the first operation to v2 servers, not so for v3
  680. // servers. See above description of authentication methods.
  681. //
  682. // multi-thread: bind calls are not safe in that it affects the
  683. // connection as a whole. beware if threads share connections
  684. // and try to mulithread binds with other operations.
  685. WINLDAPAPI ULONG LDAPAPI ldap_simple_bindW( LDAP *ld, PWCHAR dn, PWCHAR passwd );
  686. WINLDAPAPI ULONG LDAPAPI ldap_simple_bindA( LDAP *ld, PCHAR dn, PCHAR passwd );
  687. WINLDAPAPI ULONG LDAPAPI ldap_simple_bind_sW( LDAP *ld, PWCHAR dn, PWCHAR passwd );
  688. WINLDAPAPI ULONG LDAPAPI ldap_simple_bind_sA( LDAP *ld, PCHAR dn, PCHAR passwd );
  689. WINLDAPAPI ULONG LDAPAPI ldap_bindW( LDAP *ld, PWCHAR dn, PWCHAR cred, ULONG method );
  690. WINLDAPAPI ULONG LDAPAPI ldap_bindA( LDAP *ld, PCHAR dn, PCHAR cred, ULONG method );
  691. WINLDAPAPI ULONG LDAPAPI ldap_bind_sW( LDAP *ld, PWCHAR dn, PWCHAR cred, ULONG method );
  692. WINLDAPAPI ULONG LDAPAPI ldap_bind_sA( LDAP *ld, PCHAR dn, PCHAR cred, ULONG method );
  693. //
  694. // The following functions can be used to pass in any arbitrary credentials
  695. // to the server. The application must be ready to interpret the response
  696. // sent back from the server.
  697. //
  698. WINLDAPAPI INT LDAPAPI ldap_sasl_bindA(
  699. LDAP *ExternalHandle,
  700. const PCHAR DistName,
  701. const PCHAR AuthMechanism,
  702. const BERVAL *cred,
  703. PLDAPControlA *ServerCtrls,
  704. PLDAPControlA *ClientCtrls,
  705. int *MessageNumber
  706. );
  707. WINLDAPAPI INT LDAPAPI ldap_sasl_bindW(
  708. LDAP *ExternalHandle,
  709. const PWCHAR DistName,
  710. const PWCHAR AuthMechanism,
  711. const BERVAL *cred,
  712. PLDAPControlW *ServerCtrls,
  713. PLDAPControlW *ClientCtrls,
  714. int *MessageNumber
  715. );
  716. WINLDAPAPI INT LDAPAPI ldap_sasl_bind_sA(
  717. LDAP *ExternalHandle,
  718. const PCHAR DistName,
  719. const PCHAR AuthMechanism,
  720. const BERVAL *cred,
  721. PLDAPControlA *ServerCtrls,
  722. PLDAPControlA *ClientCtrls,
  723. PBERVAL *ServerData
  724. );
  725. WINLDAPAPI INT LDAPAPI ldap_sasl_bind_sW(
  726. LDAP *ExternalHandle,
  727. const PWCHAR DistName,
  728. const PWCHAR AuthMechanism,
  729. const BERVAL *cred,
  730. PLDAPControlW *ServerCtrls,
  731. PLDAPControlW *ClientCtrls,
  732. PBERVAL *ServerData
  733. );
  734. #if LDAP_UNICODE
  735. #define ldap_simple_bind ldap_simple_bindW
  736. #define ldap_simple_bind_s ldap_simple_bind_sW
  737. #define ldap_bind ldap_bindW
  738. #define ldap_bind_s ldap_bind_sW
  739. #define ldap_sasl_bind ldap_sasl_bindW
  740. #define ldap_sasl_bind_s ldap_sasl_bind_sW
  741. #else
  742. WINLDAPAPI ULONG LDAPAPI ldap_simple_bind( LDAP *ld, const PCHAR dn, const PCHAR passwd );
  743. WINLDAPAPI ULONG LDAPAPI ldap_simple_bind_s( LDAP *ld, const PCHAR dn, const PCHAR passwd );
  744. WINLDAPAPI ULONG LDAPAPI ldap_bind( LDAP *ld, const PCHAR dn, const PCHAR cred, ULONG method );
  745. WINLDAPAPI ULONG LDAPAPI ldap_bind_s( LDAP *ld, const PCHAR dn, const PCHAR cred, ULONG method );
  746. #define ldap_sasl_bind ldap_sasl_bindA
  747. #define ldap_sasl_bind_s ldap_sasl_bind_sA
  748. #endif
  749. //
  750. // Synchronous and asynch search routines.
  751. //
  752. // filter follows RFC 1960 with the addition that '(' ')' '*' ' ' '\' and
  753. // '\0' are all escaped with '\'
  754. //
  755. // Scope of search. This corresponds to the "scope" parameter on search
  756. #define LDAP_SCOPE_BASE 0x00
  757. #define LDAP_SCOPE_ONELEVEL 0x01
  758. #define LDAP_SCOPE_SUBTREE 0x02
  759. //
  760. // multi-thread: ldap_search calls are not safe in that the message number
  761. // is returned rather than the return code. You have to look
  762. // at the connection block in an error case and the return code
  763. // may be overwritten by another thread inbetween.
  764. //
  765. // Use ldap_search_ext instead, as these are thread safe.
  766. //
  767. // ldap_search_s and ldap_search_ext* calls are thread safe.
  768. //
  769. WINLDAPAPI ULONG LDAPAPI ldap_searchW(
  770. LDAP *ld,
  771. const PWCHAR base, // distinguished name or ""
  772. ULONG scope, // LDAP_SCOPE_xxxx
  773. const PWCHAR filter,
  774. PWCHAR attrs[], // pointer to an array of PCHAR attribute names
  775. ULONG attrsonly // boolean on whether to only return attr names
  776. );
  777. WINLDAPAPI ULONG LDAPAPI ldap_searchA(
  778. LDAP *ld,
  779. const PCHAR base, // distinguished name or ""
  780. ULONG scope, // LDAP_SCOPE_xxxx
  781. const PCHAR filter,
  782. PCHAR attrs[], // pointer to an array of PCHAR attribute names
  783. ULONG attrsonly // boolean on whether to only return attr names
  784. );
  785. WINLDAPAPI ULONG LDAPAPI ldap_search_sW(
  786. LDAP *ld,
  787. const PWCHAR base,
  788. ULONG scope,
  789. const PWCHAR filter,
  790. PWCHAR attrs[],
  791. ULONG attrsonly,
  792. LDAPMessage **res
  793. );
  794. WINLDAPAPI ULONG LDAPAPI ldap_search_sA(
  795. LDAP *ld,
  796. const PCHAR base,
  797. ULONG scope,
  798. const PCHAR filter,
  799. PCHAR attrs[],
  800. ULONG attrsonly,
  801. LDAPMessage **res
  802. );
  803. WINLDAPAPI ULONG LDAPAPI ldap_search_stW(
  804. LDAP *ld,
  805. const PWCHAR base,
  806. ULONG scope,
  807. const PWCHAR filter,
  808. PWCHAR attrs[],
  809. ULONG attrsonly,
  810. struct l_timeval *timeout,
  811. LDAPMessage **res
  812. );
  813. WINLDAPAPI ULONG LDAPAPI ldap_search_stA(
  814. LDAP *ld,
  815. const PCHAR base,
  816. ULONG scope,
  817. const PCHAR filter,
  818. PCHAR attrs[],
  819. ULONG attrsonly,
  820. struct l_timeval *timeout,
  821. LDAPMessage **res
  822. );
  823. WINLDAPAPI ULONG LDAPAPI ldap_search_extW(
  824. LDAP *ld,
  825. const PWCHAR base,
  826. ULONG scope,
  827. const PWCHAR filter,
  828. PWCHAR attrs[],
  829. ULONG attrsonly,
  830. PLDAPControlW *ServerControls,
  831. PLDAPControlW *ClientControls,
  832. ULONG TimeLimit,
  833. ULONG SizeLimit,
  834. ULONG *MessageNumber
  835. );
  836. WINLDAPAPI ULONG LDAPAPI ldap_search_extA(
  837. LDAP *ld,
  838. const PCHAR base,
  839. ULONG scope,
  840. const PCHAR filter,
  841. PCHAR attrs[],
  842. ULONG attrsonly,
  843. PLDAPControlA *ServerControls,
  844. PLDAPControlA *ClientControls,
  845. ULONG TimeLimit,
  846. ULONG SizeLimit,
  847. ULONG *MessageNumber
  848. );
  849. WINLDAPAPI ULONG LDAPAPI ldap_search_ext_sW(
  850. LDAP *ld,
  851. const PWCHAR base,
  852. ULONG scope,
  853. const PWCHAR filter,
  854. PWCHAR attrs[],
  855. ULONG attrsonly,
  856. PLDAPControlW *ServerControls,
  857. PLDAPControlW *ClientControls,
  858. struct l_timeval *timeout,
  859. ULONG SizeLimit,
  860. LDAPMessage **res
  861. );
  862. WINLDAPAPI ULONG LDAPAPI ldap_search_ext_sA(
  863. LDAP *ld,
  864. const PCHAR base,
  865. ULONG scope,
  866. const PCHAR filter,
  867. PCHAR attrs[],
  868. ULONG attrsonly,
  869. PLDAPControlA *ServerControls,
  870. PLDAPControlA *ClientControls,
  871. struct l_timeval *timeout,
  872. ULONG SizeLimit,
  873. LDAPMessage **res
  874. );
  875. #if LDAP_UNICODE
  876. #define ldap_search ldap_searchW
  877. #define ldap_search_s ldap_search_sW
  878. #define ldap_search_st ldap_search_stW
  879. #define ldap_search_ext ldap_search_extW
  880. #define ldap_search_ext_s ldap_search_ext_sW
  881. #else
  882. WINLDAPAPI ULONG LDAPAPI ldap_search(
  883. LDAP *ld,
  884. PCHAR base, // distinguished name or ""
  885. ULONG scope, // LDAP_SCOPE_xxxx
  886. PCHAR filter,
  887. PCHAR attrs[], // pointer to an array of PCHAR attribute names
  888. ULONG attrsonly // boolean on whether to only return attr names
  889. );
  890. WINLDAPAPI ULONG LDAPAPI ldap_search_s(
  891. LDAP *ld,
  892. PCHAR base,
  893. ULONG scope,
  894. PCHAR filter,
  895. PCHAR attrs[],
  896. ULONG attrsonly,
  897. LDAPMessage **res
  898. );
  899. WINLDAPAPI ULONG LDAPAPI ldap_search_st(
  900. LDAP *ld,
  901. PCHAR base,
  902. ULONG scope,
  903. PCHAR filter,
  904. PCHAR attrs[],
  905. ULONG attrsonly,
  906. struct l_timeval *timeout,
  907. LDAPMessage **res
  908. );
  909. WINLDAPAPI ULONG LDAPAPI ldap_search_ext(
  910. LDAP *ld,
  911. PCHAR base,
  912. ULONG scope,
  913. PCHAR filter,
  914. PCHAR attrs[],
  915. ULONG attrsonly,
  916. PLDAPControlA *ServerControls,
  917. PLDAPControlA *ClientControls,
  918. ULONG TimeLimit,
  919. ULONG SizeLimit,
  920. ULONG *MessageNumber
  921. );
  922. WINLDAPAPI ULONG LDAPAPI ldap_search_ext_s(
  923. LDAP *ld,
  924. PCHAR base,
  925. ULONG scope,
  926. PCHAR filter,
  927. PCHAR attrs[],
  928. ULONG attrsonly,
  929. PLDAPControlA *ServerControls,
  930. PLDAPControlA *ClientControls,
  931. struct l_timeval *timeout,
  932. ULONG SizeLimit,
  933. LDAPMessage **res
  934. );
  935. #endif
  936. //
  937. // Extended API to check filter syntax. Returns LDAP error code if syntax
  938. // is invalid or LDAP_SUCCESS if it's ok.
  939. //
  940. WINLDAPAPI ULONG LDAPAPI
  941. ldap_check_filterW(
  942. LDAP *ld,
  943. PWCHAR SearchFilter
  944. );
  945. WINLDAPAPI ULONG LDAPAPI
  946. ldap_check_filterA(
  947. LDAP *ld,
  948. PCHAR SearchFilter
  949. );
  950. #if LDAP_UNICODE
  951. #define ldap_check_filter ldap_check_filterW
  952. #else
  953. #define ldap_check_filter ldap_check_filterA
  954. #endif
  955. //
  956. // modify an existing entry
  957. //
  958. //
  959. // multi-thread: ldap_modify calls are not safe in that the message number
  960. // is returned rather than the return code. You have to look
  961. // at the connection block in an error case and the return code
  962. // may be overwritten by another thread inbetween.
  963. //
  964. // Use ldap_modify_ext instead, as these are thread safe.
  965. //
  966. // ldap_modify_s and ldap_modify_ext* calls are thread safe.
  967. //
  968. WINLDAPAPI ULONG LDAPAPI ldap_modifyW( LDAP *ld, PWCHAR dn, LDAPModW *mods[] );
  969. WINLDAPAPI ULONG LDAPAPI ldap_modifyA( LDAP *ld, PCHAR dn, LDAPModA *mods[] );
  970. WINLDAPAPI ULONG LDAPAPI ldap_modify_sW( LDAP *ld, PWCHAR dn, LDAPModW *mods[] );
  971. WINLDAPAPI ULONG LDAPAPI ldap_modify_sA( LDAP *ld, PCHAR dn, LDAPModA *mods[] );
  972. WINLDAPAPI ULONG LDAPAPI ldap_modify_extW(
  973. LDAP *ld,
  974. const PWCHAR dn,
  975. LDAPModW *mods[],
  976. PLDAPControlW *ServerControls,
  977. PLDAPControlW *ClientControls,
  978. ULONG *MessageNumber
  979. );
  980. WINLDAPAPI ULONG LDAPAPI ldap_modify_extA(
  981. LDAP *ld,
  982. const PCHAR dn,
  983. LDAPModA *mods[],
  984. PLDAPControlA *ServerControls,
  985. PLDAPControlA *ClientControls,
  986. ULONG *MessageNumber
  987. );
  988. WINLDAPAPI ULONG LDAPAPI ldap_modify_ext_sW(
  989. LDAP *ld,
  990. const PWCHAR dn,
  991. LDAPModW *mods[],
  992. PLDAPControlW *ServerControls,
  993. PLDAPControlW *ClientControls
  994. );
  995. WINLDAPAPI ULONG LDAPAPI ldap_modify_ext_sA(
  996. LDAP *ld,
  997. const PCHAR dn,
  998. LDAPModA *mods[],
  999. PLDAPControlA *ServerControls,
  1000. PLDAPControlA *ClientControls
  1001. );
  1002. #if LDAP_UNICODE
  1003. #define ldap_modify ldap_modifyW
  1004. #define ldap_modify_s ldap_modify_sW
  1005. #define ldap_modify_ext ldap_modify_extW
  1006. #define ldap_modify_ext_s ldap_modify_ext_sW
  1007. #else
  1008. WINLDAPAPI ULONG LDAPAPI ldap_modify( LDAP *ld, PCHAR dn, LDAPModA *mods[] );
  1009. WINLDAPAPI ULONG LDAPAPI ldap_modify_s( LDAP *ld, PCHAR dn, LDAPModA *mods[] );
  1010. WINLDAPAPI ULONG LDAPAPI ldap_modify_ext(
  1011. LDAP *ld,
  1012. const PCHAR dn,
  1013. LDAPModA *mods[],
  1014. PLDAPControlA *ServerControls,
  1015. PLDAPControlA *ClientControls,
  1016. ULONG *MessageNumber
  1017. );
  1018. WINLDAPAPI ULONG LDAPAPI ldap_modify_ext_s(
  1019. LDAP *ld,
  1020. const PCHAR dn,
  1021. LDAPModA *mods[],
  1022. PLDAPControlA *ServerControls,
  1023. PLDAPControlA *ClientControls
  1024. );
  1025. #endif
  1026. //
  1027. // modrdn and modrdn2 function both as RenameObject and MoveObject.
  1028. //
  1029. // Note that to LDAP v2 servers, only rename within a given container
  1030. // is supported... therefore NewDistinguishedName is actually NewRDN.
  1031. // Here are some examples :
  1032. //
  1033. // This works to both v2 and v3 servers :
  1034. //
  1035. // DN = CN=Bob,OU=FOO,O=BAR
  1036. // NewDN = CN=Joe
  1037. //
  1038. // result is: CN=Joe,OU=FOO,O=BAR
  1039. //
  1040. // This works to only v3 and above servers :
  1041. //
  1042. // DN = CN=Bob,OU=FOO,O=BAR
  1043. // NewDN = CN=Joe,OU=FOOBAR,O=BAR
  1044. //
  1045. // result is: CN=Joe,OU=FOOBAR,O=BAR
  1046. //
  1047. // If you try the second example to a v2 server, we'll send the whole
  1048. // NewDN over as the new RDN (rather than break up the parent OU and
  1049. // child). The server will then give you back some unknown error.
  1050. //
  1051. //
  1052. // multi-thread: ldap_modrdn and ldap_modrdn2 calls are not safe in that
  1053. // the message number is returned rather than the return code.
  1054. // You have to look at the connection block in an error case
  1055. // and the return code may be overwritten by another thread
  1056. // inbetween.
  1057. //
  1058. // Use ldap_rename_ext instead, as these are thread safe.
  1059. //
  1060. WINLDAPAPI ULONG LDAPAPI ldap_modrdn2W (
  1061. LDAP *ExternalHandle,
  1062. const PWCHAR DistinguishedName,
  1063. const PWCHAR NewDistinguishedName,
  1064. INT DeleteOldRdn
  1065. );
  1066. WINLDAPAPI ULONG LDAPAPI ldap_modrdn2A (
  1067. LDAP *ExternalHandle,
  1068. const PCHAR DistinguishedName,
  1069. const PCHAR NewDistinguishedName,
  1070. INT DeleteOldRdn
  1071. );
  1072. //
  1073. // ldap_modrdn simply calls ldap_modrdn2 with a value of 1 for DeleteOldRdn.
  1074. //
  1075. WINLDAPAPI ULONG LDAPAPI ldap_modrdnW (
  1076. LDAP *ExternalHandle,
  1077. const PWCHAR DistinguishedName,
  1078. const PWCHAR NewDistinguishedName
  1079. );
  1080. WINLDAPAPI ULONG LDAPAPI ldap_modrdnA (
  1081. LDAP *ExternalHandle,
  1082. const PCHAR DistinguishedName,
  1083. const PCHAR NewDistinguishedName
  1084. );
  1085. WINLDAPAPI ULONG LDAPAPI ldap_modrdn2_sW (
  1086. LDAP *ExternalHandle,
  1087. const PWCHAR DistinguishedName,
  1088. const PWCHAR NewDistinguishedName,
  1089. INT DeleteOldRdn
  1090. );
  1091. WINLDAPAPI ULONG LDAPAPI ldap_modrdn2_sA (
  1092. LDAP *ExternalHandle,
  1093. const PCHAR DistinguishedName,
  1094. const PCHAR NewDistinguishedName,
  1095. INT DeleteOldRdn
  1096. );
  1097. WINLDAPAPI ULONG LDAPAPI ldap_modrdn_sW (
  1098. LDAP *ExternalHandle,
  1099. const PWCHAR DistinguishedName,
  1100. const PWCHAR NewDistinguishedName
  1101. );
  1102. WINLDAPAPI ULONG LDAPAPI ldap_modrdn_sA (
  1103. LDAP *ExternalHandle,
  1104. const PCHAR DistinguishedName,
  1105. const PCHAR NewDistinguishedName
  1106. );
  1107. #if LDAP_UNICODE
  1108. #define ldap_modrdn2 ldap_modrdn2W
  1109. #define ldap_modrdn ldap_modrdnW
  1110. #define ldap_modrdn2_s ldap_modrdn2_sW
  1111. #define ldap_modrdn_s ldap_modrdn_sW
  1112. #else
  1113. WINLDAPAPI ULONG LDAPAPI ldap_modrdn2 (
  1114. LDAP *ExternalHandle,
  1115. const PCHAR DistinguishedName,
  1116. const PCHAR NewDistinguishedName,
  1117. INT DeleteOldRdn
  1118. );
  1119. WINLDAPAPI ULONG LDAPAPI ldap_modrdn (
  1120. LDAP *ExternalHandle,
  1121. const PCHAR DistinguishedName,
  1122. const PCHAR NewDistinguishedName
  1123. );
  1124. WINLDAPAPI ULONG LDAPAPI ldap_modrdn2_s (
  1125. LDAP *ExternalHandle,
  1126. const PCHAR DistinguishedName,
  1127. const PCHAR NewDistinguishedName,
  1128. INT DeleteOldRdn
  1129. );
  1130. WINLDAPAPI ULONG LDAPAPI ldap_modrdn_s (
  1131. LDAP *ExternalHandle,
  1132. const PCHAR DistinguishedName,
  1133. const PCHAR NewDistinguishedName
  1134. );
  1135. #endif
  1136. //
  1137. // Extended Rename operations. These take controls and separate out the
  1138. // parent from the RDN, for clarity.
  1139. //
  1140. WINLDAPAPI ULONG LDAPAPI ldap_rename_extW(
  1141. LDAP *ld,
  1142. const PWCHAR dn,
  1143. const PWCHAR NewRDN,
  1144. const PWCHAR NewParent,
  1145. INT DeleteOldRdn,
  1146. PLDAPControlW *ServerControls,
  1147. PLDAPControlW *ClientControls,
  1148. ULONG *MessageNumber
  1149. );
  1150. WINLDAPAPI ULONG LDAPAPI ldap_rename_extA(
  1151. LDAP *ld,
  1152. const PCHAR dn,
  1153. const PCHAR NewRDN,
  1154. const PCHAR NewParent,
  1155. INT DeleteOldRdn,
  1156. PLDAPControlA *ServerControls,
  1157. PLDAPControlA *ClientControls,
  1158. ULONG *MessageNumber
  1159. );
  1160. WINLDAPAPI ULONG LDAPAPI ldap_rename_ext_sW(
  1161. LDAP *ld,
  1162. const PWCHAR dn,
  1163. const PWCHAR NewRDN,
  1164. const PWCHAR NewParent,
  1165. INT DeleteOldRdn,
  1166. PLDAPControlW *ServerControls,
  1167. PLDAPControlW *ClientControls
  1168. );
  1169. WINLDAPAPI ULONG LDAPAPI ldap_rename_ext_sA(
  1170. LDAP *ld,
  1171. const PCHAR dn,
  1172. const PCHAR NewRDN,
  1173. const PCHAR NewParent,
  1174. INT DeleteOldRdn,
  1175. PLDAPControlA *ServerControls,
  1176. PLDAPControlA *ClientControls
  1177. );
  1178. #if LDAP_UNICODE
  1179. #define ldap_rename ldap_rename_extW
  1180. #define ldap_rename_s ldap_rename_ext_sW
  1181. #else
  1182. #define ldap_rename ldap_rename_extA
  1183. #define ldap_rename_s ldap_rename_ext_sA
  1184. #endif
  1185. #if LDAP_UNICODE
  1186. #define ldap_rename_ext ldap_rename_extW
  1187. #define ldap_rename_ext_s ldap_rename_ext_sW
  1188. #else
  1189. WINLDAPAPI ULONG LDAPAPI ldap_rename_ext(
  1190. LDAP *ld,
  1191. const PCHAR dn,
  1192. const PCHAR NewRDN,
  1193. const PCHAR NewParent,
  1194. INT DeleteOldRdn,
  1195. PLDAPControlA *ServerControls,
  1196. PLDAPControlA *ClientControls,
  1197. ULONG *MessageNumber
  1198. );
  1199. WINLDAPAPI ULONG LDAPAPI ldap_rename_ext_s(
  1200. LDAP *ld,
  1201. const PCHAR dn,
  1202. const PCHAR NewRDN,
  1203. const PCHAR NewParent,
  1204. INT DeleteOldRdn,
  1205. PLDAPControlA *ServerControls,
  1206. PLDAPControlA *ClientControls
  1207. );
  1208. #endif
  1209. //
  1210. // Add an entry to the tree
  1211. //
  1212. //
  1213. // multi-thread: ldap_add calls are not safe in that the message number
  1214. // is returned rather than the return code. You have to look
  1215. // at the connection block in an error case and the return code
  1216. // may be overwritten by another thread inbetween.
  1217. //
  1218. // Use ldap_add_ext instead, as these are thread safe.
  1219. //
  1220. // ldap_add_s and ldap_add_ext* calls are thread safe.
  1221. //
  1222. WINLDAPAPI ULONG LDAPAPI ldap_addW( LDAP *ld, PWCHAR dn, LDAPModW *attrs[] );
  1223. WINLDAPAPI ULONG LDAPAPI ldap_addA( LDAP *ld, PCHAR dn, LDAPModA *attrs[] );
  1224. WINLDAPAPI ULONG LDAPAPI ldap_add_sW( LDAP *ld, PWCHAR dn, LDAPModW *attrs[] );
  1225. WINLDAPAPI ULONG LDAPAPI ldap_add_sA( LDAP *ld, PCHAR dn, LDAPModA *attrs[] );
  1226. WINLDAPAPI ULONG LDAPAPI ldap_add_extW(
  1227. LDAP *ld,
  1228. const PWCHAR dn,
  1229. LDAPModW *attrs[],
  1230. PLDAPControlW *ServerControls,
  1231. PLDAPControlW *ClientControls,
  1232. ULONG *MessageNumber
  1233. );
  1234. WINLDAPAPI ULONG LDAPAPI ldap_add_extA(
  1235. LDAP *ld,
  1236. const PCHAR dn,
  1237. LDAPModA *attrs[],
  1238. PLDAPControlA *ServerControls,
  1239. PLDAPControlA *ClientControls,
  1240. ULONG *MessageNumber
  1241. );
  1242. WINLDAPAPI ULONG LDAPAPI ldap_add_ext_sW(
  1243. LDAP *ld,
  1244. const PWCHAR dn,
  1245. LDAPModW *attrs[],
  1246. PLDAPControlW *ServerControls,
  1247. PLDAPControlW *ClientControls
  1248. );
  1249. WINLDAPAPI ULONG LDAPAPI ldap_add_ext_sA(
  1250. LDAP *ld,
  1251. const PCHAR dn,
  1252. LDAPModA *attrs[],
  1253. PLDAPControlA *ServerControls,
  1254. PLDAPControlA *ClientControls
  1255. );
  1256. #if LDAP_UNICODE
  1257. #define ldap_add ldap_addW
  1258. #define ldap_add_s ldap_add_sW
  1259. #define ldap_add_ext ldap_add_extW
  1260. #define ldap_add_ext_s ldap_add_ext_sW
  1261. #else
  1262. WINLDAPAPI ULONG LDAPAPI ldap_add( LDAP *ld, PCHAR dn, LDAPMod *attrs[] );
  1263. WINLDAPAPI ULONG LDAPAPI ldap_add_s( LDAP *ld, PCHAR dn, LDAPMod *attrs[] );
  1264. WINLDAPAPI ULONG LDAPAPI ldap_add_ext(
  1265. LDAP *ld,
  1266. const PCHAR dn,
  1267. LDAPModA *attrs[],
  1268. PLDAPControlA *ServerControls,
  1269. PLDAPControlA *ClientControls,
  1270. ULONG *MessageNumber
  1271. );
  1272. WINLDAPAPI ULONG LDAPAPI ldap_add_ext_s(
  1273. LDAP *ld,
  1274. const PCHAR dn,
  1275. LDAPModA *attrs[],
  1276. PLDAPControlA *ServerControls,
  1277. PLDAPControlA *ClientControls
  1278. );
  1279. #endif
  1280. //
  1281. // Compare the attribute for a given entry to a known value.
  1282. //
  1283. //
  1284. // multi-thread: ldap_compare calls are not safe in that the message number
  1285. // is returned rather than the return code. You have to look
  1286. // at the connection block in an error case and the return code
  1287. // may be overwritten by another thread inbetween.
  1288. //
  1289. // Use ldap_compare_ext instead, as these are thread safe.
  1290. //
  1291. // ldap_compare_s and ldap_compare_ext* calls are thread safe.
  1292. //
  1293. WINLDAPAPI ULONG LDAPAPI ldap_compareW( LDAP *ld, const PWCHAR dn, const PWCHAR attr, PWCHAR value );
  1294. WINLDAPAPI ULONG LDAPAPI ldap_compareA( LDAP *ld, const PCHAR dn, const PCHAR attr, PCHAR value );
  1295. WINLDAPAPI ULONG LDAPAPI ldap_compare_sW( LDAP *ld, const PWCHAR dn, const PWCHAR attr, PWCHAR value );
  1296. WINLDAPAPI ULONG LDAPAPI ldap_compare_sA( LDAP *ld, const PCHAR dn, const PCHAR attr, PCHAR value );
  1297. #if LDAP_UNICODE
  1298. #define ldap_compare ldap_compareW
  1299. #define ldap_compare_s ldap_compare_sW
  1300. #else
  1301. WINLDAPAPI ULONG LDAPAPI ldap_compare( LDAP *ld, const PCHAR dn, const PCHAR attr, PCHAR value );
  1302. WINLDAPAPI ULONG LDAPAPI ldap_compare_s( LDAP *ld, const PCHAR dn, const PCHAR attr, PCHAR value );
  1303. #endif
  1304. //
  1305. // Extended Compare operations. These take controls and are thread safe.
  1306. // They also allow you to specify a bval structure for the data, so that it
  1307. // isn't translated from Unicode or ANSI to UTF8. Allows for comparison of
  1308. // raw binary data.
  1309. //
  1310. // Specify either Data or Value as not NULL. If both are not NULL, the
  1311. // berval Data will be used.
  1312. //
  1313. WINLDAPAPI ULONG LDAPAPI ldap_compare_extW(
  1314. LDAP *ld,
  1315. const PWCHAR dn,
  1316. const PWCHAR Attr,
  1317. const PWCHAR Value, // either value or Data is not null, not both
  1318. struct berval *Data,
  1319. PLDAPControlW *ServerControls,
  1320. PLDAPControlW *ClientControls,
  1321. ULONG *MessageNumber
  1322. );
  1323. WINLDAPAPI ULONG LDAPAPI ldap_compare_extA(
  1324. LDAP *ld,
  1325. const PCHAR dn,
  1326. const PCHAR Attr,
  1327. const PCHAR Value, // either value or Data is not null, not both
  1328. struct berval *Data,
  1329. PLDAPControlA *ServerControls,
  1330. PLDAPControlA *ClientControls,
  1331. ULONG *MessageNumber
  1332. );
  1333. WINLDAPAPI ULONG LDAPAPI ldap_compare_ext_sW(
  1334. LDAP *ld,
  1335. const PWCHAR dn,
  1336. const PWCHAR Attr,
  1337. const PWCHAR Value, // either value or Data is not null, not both
  1338. struct berval *Data,
  1339. PLDAPControlW *ServerControls,
  1340. PLDAPControlW *ClientControls
  1341. );
  1342. WINLDAPAPI ULONG LDAPAPI ldap_compare_ext_sA(
  1343. LDAP *ld,
  1344. const PCHAR dn,
  1345. const PCHAR Attr,
  1346. const PCHAR Value, // either value or Data is not null, not both
  1347. struct berval *Data,
  1348. PLDAPControlA *ServerControls,
  1349. PLDAPControlA *ClientControls
  1350. );
  1351. #if LDAP_UNICODE
  1352. #define ldap_compare_ext ldap_compare_extW
  1353. #define ldap_compare_ext_s ldap_compare_ext_sW
  1354. #else
  1355. WINLDAPAPI ULONG LDAPAPI ldap_compare_ext(
  1356. LDAP *ld,
  1357. const PCHAR dn,
  1358. const PCHAR Attr,
  1359. const PCHAR Value, // either value or Data is not null, not both
  1360. struct berval *Data,
  1361. PLDAPControlA *ServerControls,
  1362. PLDAPControlA *ClientControls,
  1363. ULONG *MessageNumber
  1364. );
  1365. WINLDAPAPI ULONG LDAPAPI ldap_compare_ext_s(
  1366. LDAP *ld,
  1367. const PCHAR dn,
  1368. const PCHAR Attr,
  1369. const PCHAR Value, // either value or Data is not null, not both
  1370. struct berval *Data,
  1371. PLDAPControlA *ServerControls,
  1372. PLDAPControlA *ClientControls
  1373. );
  1374. #endif
  1375. //
  1376. // Delete an object out of the tree
  1377. //
  1378. //
  1379. // multi-thread: ldap_delete calls are not safe in that the message number
  1380. // is returned rather than the return code. You have to look
  1381. // at the connection block in an error case and the return code
  1382. // may be overwritten by another thread inbetween.
  1383. //
  1384. // Use ldap_delete_ext instead, as these are thread safe.
  1385. //
  1386. // ldap_delete_s and ldap_delete_ext* calls are thread safe.
  1387. //
  1388. WINLDAPAPI ULONG LDAPAPI ldap_deleteW( LDAP *ld, const PWCHAR dn );
  1389. WINLDAPAPI ULONG LDAPAPI ldap_deleteA( LDAP *ld, const PCHAR dn );
  1390. WINLDAPAPI ULONG LDAPAPI ldap_delete_sW( LDAP *ld, const PWCHAR dn );
  1391. WINLDAPAPI ULONG LDAPAPI ldap_delete_sA( LDAP *ld, const PCHAR dn );
  1392. WINLDAPAPI ULONG LDAPAPI ldap_delete_extW(
  1393. LDAP *ld,
  1394. const PWCHAR dn,
  1395. PLDAPControlW *ServerControls,
  1396. PLDAPControlW *ClientControls,
  1397. ULONG *MessageNumber
  1398. );
  1399. WINLDAPAPI ULONG LDAPAPI ldap_delete_extA(
  1400. LDAP *ld,
  1401. const PCHAR dn,
  1402. PLDAPControlA *ServerControls,
  1403. PLDAPControlA *ClientControls,
  1404. ULONG *MessageNumber
  1405. );
  1406. WINLDAPAPI ULONG LDAPAPI ldap_delete_ext_sW(
  1407. LDAP *ld,
  1408. const PWCHAR dn,
  1409. PLDAPControlW *ServerControls,
  1410. PLDAPControlW *ClientControls
  1411. );
  1412. WINLDAPAPI ULONG LDAPAPI ldap_delete_ext_sA(
  1413. LDAP *ld,
  1414. const PCHAR dn,
  1415. PLDAPControlA *ServerControls,
  1416. PLDAPControlA *ClientControls
  1417. );
  1418. #if LDAP_UNICODE
  1419. #define ldap_delete ldap_deleteW
  1420. #define ldap_delete_ext ldap_delete_extW
  1421. #define ldap_delete_s ldap_delete_sW
  1422. #define ldap_delete_ext_s ldap_delete_ext_sW
  1423. #else
  1424. WINLDAPAPI ULONG LDAPAPI ldap_delete( LDAP *ld, PCHAR dn );
  1425. WINLDAPAPI ULONG LDAPAPI ldap_delete_s( LDAP *ld, PCHAR dn );
  1426. WINLDAPAPI ULONG LDAPAPI ldap_delete_ext(
  1427. LDAP *ld,
  1428. const PCHAR dn,
  1429. PLDAPControlA *ServerControls,
  1430. PLDAPControlA *ClientControls,
  1431. ULONG *MessageNumber
  1432. );
  1433. WINLDAPAPI ULONG LDAPAPI ldap_delete_ext_s(
  1434. LDAP *ld,
  1435. const PCHAR dn,
  1436. PLDAPControlA *ServerControls,
  1437. PLDAPControlA *ClientControls
  1438. );
  1439. #endif
  1440. //
  1441. // Give up on a request. No guarentee that it got there as there is no
  1442. // response from the server.
  1443. //
  1444. // multi-thread: ldap_abandon calls are thread safe
  1445. WINLDAPAPI ULONG LDAPAPI ldap_abandon( LDAP *ld, ULONG msgid );
  1446. //
  1447. // Possible values for "all" field in ldap_result. We've enhanced it such
  1448. // that if someone passes in LDAP_MSG_RECEIVED, we'll pass all values we've
  1449. // received up to that point.
  1450. //
  1451. #define LDAP_MSG_ONE 0
  1452. #define LDAP_MSG_ALL 1
  1453. #define LDAP_MSG_RECEIVED 2
  1454. //
  1455. // Get a response from a connection. One enhancement here is that ld can
  1456. // be null, in which case we'll return responses from any server. Free
  1457. // responses here with ldap_msgfree.
  1458. //
  1459. // For connection-less LDAP, you should pass in both a LDAP connection
  1460. // handle and a msgid. This will ensure we know which request the app
  1461. // is waiting on a reply to. ( we actively resend request until we get
  1462. // a response.)
  1463. //
  1464. // multi-thread: ldap_result calls are thread safe
  1465. WINLDAPAPI ULONG LDAPAPI ldap_result(
  1466. LDAP *ld,
  1467. ULONG msgid,
  1468. ULONG all,
  1469. struct l_timeval *timeout,
  1470. LDAPMessage **res
  1471. );
  1472. WINLDAPAPI ULONG LDAPAPI ldap_msgfree( LDAPMessage *res );
  1473. //
  1474. // This parses a message and returns the error code. It optionally frees
  1475. // the message by calling ldap_msgfree.
  1476. //
  1477. // multi-thread: ldap_result2error call is thread safe
  1478. WINLDAPAPI ULONG LDAPAPI ldap_result2error(
  1479. LDAP *ld,
  1480. LDAPMessage *res,
  1481. ULONG freeit // boolean.. free the message?
  1482. );
  1483. //
  1484. // Similar to ldap_result2error, this parses responses from the server and
  1485. // returns the appropriate fields. Use this one if you want to get at the
  1486. // referrals, matchingDNs, or server controls returned.
  1487. //
  1488. // multi-thread: ldap_parse_result call is thread safe
  1489. WINLDAPAPI ULONG LDAPAPI ldap_parse_resultW (
  1490. LDAP *Connection,
  1491. LDAPMessage *ResultMessage,
  1492. ULONG *ReturnCode OPTIONAL, // returned by server
  1493. PWCHAR *MatchedDNs OPTIONAL, // free with ldap_memfree
  1494. PWCHAR *ErrorMessage OPTIONAL, // free with ldap_memfree
  1495. PWCHAR **Referrals OPTIONAL, // free with ldap_value_freeW
  1496. PLDAPControlW **ServerControls OPTIONAL, // free with ldap_free_controlsW
  1497. BOOLEAN Freeit
  1498. );
  1499. WINLDAPAPI ULONG LDAPAPI ldap_parse_resultA (
  1500. LDAP *Connection,
  1501. LDAPMessage *ResultMessage,
  1502. ULONG *ReturnCode OPTIONAL, // returned by server
  1503. PCHAR *MatchedDNs OPTIONAL, // free with ldap_memfree
  1504. PCHAR *ErrorMessage OPTIONAL, // free with ldap_memfree
  1505. PCHAR **Referrals OPTIONAL, // free with ldap_value_freeA
  1506. PLDAPControlA **ServerControls OPTIONAL, // free with ldap_free_controlsA
  1507. BOOLEAN Freeit
  1508. );
  1509. WINLDAPAPI ULONG LDAPAPI ldap_parse_extended_resultA (
  1510. LDAP *Connection,
  1511. LDAPMessage *ResultMessage, // returned by server
  1512. PCHAR *ResultOID, // free with ldap_memfree
  1513. struct berval **ResultData, // free with ldap_memfree
  1514. BOOLEAN Freeit // Don't need the message anymore
  1515. );
  1516. WINLDAPAPI ULONG LDAPAPI ldap_parse_extended_resultW (
  1517. LDAP *Connection,
  1518. LDAPMessage *ResultMessage, // returned by server
  1519. PWCHAR *ResultOID, // free with ldap_memfree
  1520. struct berval **ResultData, // free with ldap_memfree
  1521. BOOLEAN Freeit // Don't need the message anymore
  1522. );
  1523. WINLDAPAPI ULONG LDAPAPI ldap_controls_freeA (
  1524. LDAPControlA **Controls
  1525. );
  1526. WINLDAPAPI ULONG LDAPAPI ldap_control_freeA (
  1527. LDAPControlA *Controls
  1528. );
  1529. WINLDAPAPI ULONG LDAPAPI ldap_controls_freeW (
  1530. LDAPControlW **Control
  1531. );
  1532. WINLDAPAPI ULONG LDAPAPI ldap_control_freeW (
  1533. LDAPControlW *Control
  1534. );
  1535. //
  1536. // ldap_free_controls are old, use ldap_controls_free
  1537. //
  1538. WINLDAPAPI ULONG LDAPAPI ldap_free_controlsW (
  1539. LDAPControlW **Controls
  1540. );
  1541. WINLDAPAPI ULONG LDAPAPI ldap_free_controlsA (
  1542. LDAPControlA **Controls
  1543. );
  1544. #if LDAP_UNICODE
  1545. #define ldap_parse_result ldap_parse_resultW
  1546. #define ldap_controls_free ldap_controls_freeW
  1547. #define ldap_control_free ldap_control_freeW
  1548. #define ldap_free_controls ldap_free_controlsW
  1549. #define ldap_parse_extended_result ldap_parse_extended_resultW
  1550. #else
  1551. #define ldap_parse_extended_result ldap_parse_extended_resultA
  1552. WINLDAPAPI ULONG LDAPAPI ldap_parse_result (
  1553. LDAP *Connection,
  1554. LDAPMessage *ResultMessage,
  1555. ULONG *ReturnCode OPTIONAL, // returned by server
  1556. PCHAR *MatchedDNs OPTIONAL, // free with ldap_memfree
  1557. PCHAR *ErrorMessage OPTIONAL, // free with ldap_memfree
  1558. PCHAR **Referrals OPTIONAL, // free with ldap_value_free
  1559. PLDAPControlA **ServerControls OPTIONAL, // free with ldap_free_controls
  1560. BOOLEAN Freeit
  1561. );
  1562. WINLDAPAPI ULONG LDAPAPI ldap_controls_free (
  1563. LDAPControlA **Controls
  1564. );
  1565. WINLDAPAPI ULONG LDAPAPI ldap_control_free (
  1566. LDAPControlA *Control
  1567. );
  1568. WINLDAPAPI ULONG LDAPAPI ldap_free_controls (
  1569. LDAPControlA **Controls
  1570. );
  1571. #endif
  1572. //
  1573. // ldap_err2string returns a pointer to a string describing the error. This
  1574. // string should not be freed.
  1575. //
  1576. WINLDAPAPI PWCHAR LDAPAPI ldap_err2stringW( ULONG err );
  1577. WINLDAPAPI PCHAR LDAPAPI ldap_err2stringA( ULONG err );
  1578. #if LDAP_UNICODE
  1579. #define ldap_err2string ldap_err2stringW
  1580. #else
  1581. WINLDAPAPI PCHAR LDAPAPI ldap_err2string( ULONG err );
  1582. #endif
  1583. //
  1584. // ldap_perror does nothing and is here just for compatibility.
  1585. //
  1586. WINLDAPAPI void LDAPAPI ldap_perror( LDAP *ld, const PCHAR msg );
  1587. //
  1588. // Return the first entry of a message. It is freed when the message is
  1589. // freed so should not be freed explicitly.
  1590. //
  1591. WINLDAPAPI LDAPMessage *LDAPAPI ldap_first_entry( LDAP *ld, LDAPMessage *res );
  1592. //
  1593. // Return the next entry of a message. It is freed when the message is
  1594. // freed so should not be freed explicitly.
  1595. //
  1596. WINLDAPAPI LDAPMessage *LDAPAPI ldap_next_entry( LDAP *ld, LDAPMessage *entry );
  1597. //
  1598. // Count the number of search entries returned by the server in a response
  1599. // to a server request.
  1600. //
  1601. WINLDAPAPI ULONG LDAPAPI ldap_count_entries( LDAP *ld, LDAPMessage *res );
  1602. //
  1603. // A BerElement really maps out to a C++ class object that does BER encoding.
  1604. // Don't mess with it as it's opaque.
  1605. //
  1606. typedef struct berelement {
  1607. PCHAR opaque; // this is an opaque structure used just for
  1608. // compatibility with reference implementation
  1609. } BerElement;
  1610. #define NULLBER ((BerElement *) 0)
  1611. //
  1612. // For a given entry, return the first attribute. The pointer returned is
  1613. // actually a buffer in the connection block (with allowances for
  1614. // multi-threaded apps) so it should not be freed.
  1615. //
  1616. WINLDAPAPI PWCHAR LDAPAPI ldap_first_attributeW(
  1617. LDAP *ld,
  1618. LDAPMessage *entry,
  1619. BerElement **ptr
  1620. );
  1621. WINLDAPAPI PCHAR LDAPAPI ldap_first_attributeA(
  1622. LDAP *ld,
  1623. LDAPMessage *entry,
  1624. BerElement **ptr
  1625. );
  1626. #if LDAP_UNICODE
  1627. #define ldap_first_attribute ldap_first_attributeW
  1628. #else
  1629. WINLDAPAPI PCHAR LDAPAPI ldap_first_attribute(
  1630. LDAP *ld,
  1631. LDAPMessage *entry,
  1632. BerElement **ptr
  1633. );
  1634. #endif
  1635. //
  1636. // Return the next attribute... again, the attribute pointer should not be
  1637. // freed.
  1638. //
  1639. WINLDAPAPI PWCHAR LDAPAPI ldap_next_attributeW(
  1640. LDAP *ld,
  1641. LDAPMessage *entry,
  1642. BerElement *ptr
  1643. );
  1644. WINLDAPAPI PCHAR LDAPAPI ldap_next_attributeA(
  1645. LDAP *ld,
  1646. LDAPMessage *entry,
  1647. BerElement *ptr
  1648. );
  1649. #if LDAP_UNICODE
  1650. #define ldap_next_attribute ldap_next_attributeW
  1651. #else
  1652. WINLDAPAPI PCHAR LDAPAPI ldap_next_attribute(
  1653. LDAP *ld,
  1654. LDAPMessage *entry,
  1655. BerElement *ptr
  1656. );
  1657. #endif
  1658. //
  1659. // Get a given attribute's list of values. This is used during parsing of
  1660. // a search response. It returns a list of pointers to values, the list is
  1661. // null terminated.
  1662. //
  1663. // If the values are generic octet strings and not null terminated strings,
  1664. // use ldap_get_values_len instead.
  1665. //
  1666. // The returned value should be freed when your done with it by calling
  1667. // ldap_value_free.
  1668. //
  1669. WINLDAPAPI PWCHAR *LDAPAPI ldap_get_valuesW(
  1670. LDAP *ld,
  1671. LDAPMessage *entry,
  1672. const PWCHAR attr
  1673. );
  1674. WINLDAPAPI PCHAR *LDAPAPI ldap_get_valuesA(
  1675. LDAP *ld,
  1676. LDAPMessage *entry,
  1677. const PCHAR attr
  1678. );
  1679. #if LDAP_UNICODE
  1680. #define ldap_get_values ldap_get_valuesW
  1681. #else
  1682. WINLDAPAPI PCHAR *LDAPAPI ldap_get_values(
  1683. LDAP *ld,
  1684. LDAPMessage *entry,
  1685. const PCHAR attr
  1686. );
  1687. #endif
  1688. //
  1689. // Get a given attribute's list of values. This is used during parsing of
  1690. // a search response. It returns a list of berval structures to values,
  1691. // the list is null terminated.
  1692. //
  1693. // If the values are null terminated strings, it may be easier to process them
  1694. // by calling ldap_get_values instead.
  1695. //
  1696. // The returned value should be freed when your done with it by calling
  1697. // ldap_value_free_len.
  1698. //
  1699. WINLDAPAPI struct berval **LDAPAPI ldap_get_values_lenW (
  1700. LDAP *ExternalHandle,
  1701. LDAPMessage *Message,
  1702. const PWCHAR attr
  1703. );
  1704. WINLDAPAPI struct berval **LDAPAPI ldap_get_values_lenA (
  1705. LDAP *ExternalHandle,
  1706. LDAPMessage *Message,
  1707. const PCHAR attr
  1708. );
  1709. #if LDAP_UNICODE
  1710. #define ldap_get_values_len ldap_get_values_lenW
  1711. #else
  1712. WINLDAPAPI struct berval **LDAPAPI ldap_get_values_len (
  1713. LDAP *ExternalHandle,
  1714. LDAPMessage *Message,
  1715. const PCHAR attr
  1716. );
  1717. #endif
  1718. //
  1719. // Return the number of values in a list returned by ldap_get_values.
  1720. //
  1721. WINLDAPAPI ULONG LDAPAPI ldap_count_valuesW( PWCHAR *vals );
  1722. WINLDAPAPI ULONG LDAPAPI ldap_count_valuesA( PCHAR *vals );
  1723. #if LDAP_UNICODE
  1724. #define ldap_count_values ldap_count_valuesW
  1725. #else
  1726. WINLDAPAPI ULONG LDAPAPI ldap_count_values( PCHAR *vals );
  1727. #endif
  1728. //
  1729. // Return the number of values in a list returned by ldap_get_values_len.
  1730. //
  1731. WINLDAPAPI ULONG LDAPAPI ldap_count_values_len( struct berval **vals );
  1732. //
  1733. // Free structures returned by ldap_get_values.
  1734. //
  1735. WINLDAPAPI ULONG LDAPAPI ldap_value_freeW( PWCHAR *vals );
  1736. WINLDAPAPI ULONG LDAPAPI ldap_value_freeA( PCHAR *vals );
  1737. #if LDAP_UNICODE
  1738. #define ldap_value_free ldap_value_freeW
  1739. #else
  1740. WINLDAPAPI ULONG LDAPAPI ldap_value_free( PCHAR *vals );
  1741. #endif
  1742. //
  1743. // Free structures returned by ldap_get_values_len.
  1744. //
  1745. WINLDAPAPI ULONG LDAPAPI ldap_value_free_len( struct berval **vals );
  1746. //
  1747. // Get the distinguished name for a given search entry. It should be freed
  1748. // by calling ldap_memfree.
  1749. //
  1750. WINLDAPAPI PWCHAR LDAPAPI ldap_get_dnW( LDAP *ld, LDAPMessage *entry );
  1751. WINLDAPAPI PCHAR LDAPAPI ldap_get_dnA( LDAP *ld, LDAPMessage *entry );
  1752. #if LDAP_UNICODE
  1753. #define ldap_get_dn ldap_get_dnW
  1754. #else
  1755. WINLDAPAPI PCHAR LDAPAPI ldap_get_dn( LDAP *ld, LDAPMessage *entry );
  1756. #endif
  1757. //
  1758. // When using ldap_explode_dn, you should free the returned string by
  1759. // calling ldap_value_free.
  1760. //
  1761. WINLDAPAPI PWCHAR *LDAPAPI ldap_explode_dnW( const PWCHAR dn, ULONG notypes );
  1762. WINLDAPAPI PCHAR *LDAPAPI ldap_explode_dnA( const PCHAR dn, ULONG notypes );
  1763. #if LDAP_UNICODE
  1764. #define ldap_explode_dn ldap_explode_dnW
  1765. #else
  1766. WINLDAPAPI PCHAR *LDAPAPI ldap_explode_dn( const PCHAR dn, ULONG notypes );
  1767. #endif
  1768. //
  1769. // When calling ldap_dn2ufn, you should free the returned string by calling
  1770. // ldap_memfree.
  1771. //
  1772. WINLDAPAPI PWCHAR LDAPAPI ldap_dn2ufnW( const PWCHAR dn );
  1773. WINLDAPAPI PCHAR LDAPAPI ldap_dn2ufnA( const PCHAR dn );
  1774. #if LDAP_UNICODE
  1775. #define ldap_dn2ufn ldap_dn2ufnW
  1776. #else
  1777. WINLDAPAPI PCHAR LDAPAPI ldap_dn2ufn( const PCHAR dn );
  1778. #endif
  1779. //
  1780. // This is used to free strings back to the LDAP API heap. Don't pass in
  1781. // values that you've gotten from ldap_open, ldap_get_values, etc.
  1782. //
  1783. WINLDAPAPI VOID LDAPAPI ldap_memfreeW( PWCHAR Block );
  1784. WINLDAPAPI VOID LDAPAPI ldap_memfreeA( PCHAR Block );
  1785. WINLDAPAPI VOID LDAPAPI ber_bvfree( struct berval *bv );
  1786. #if LDAP_UNICODE
  1787. #define ldap_memfree ldap_memfreeW
  1788. #else
  1789. WINLDAPAPI VOID LDAPAPI ldap_memfree( PCHAR Block );
  1790. #endif
  1791. //
  1792. // The function ldap_ufn2dn attempts to "normalize" a user specified DN
  1793. // to make it "proper". It follows RFC 1781 (add CN= if not present,
  1794. // add OU= if none present, etc). If it runs into any problems at all
  1795. // while normalizing, it simply returns a copy of what was passed in.
  1796. //
  1797. // It allocates the output string from the LDAP memory pool. If the pDn
  1798. // comes back as non-NULL, you should free it when you're done with a call
  1799. // to ldap_memfree.
  1800. //
  1801. WINLDAPAPI ULONG LDAPAPI ldap_ufn2dnW (
  1802. const PWCHAR ufn,
  1803. PWCHAR *pDn
  1804. );
  1805. WINLDAPAPI ULONG LDAPAPI ldap_ufn2dnA (
  1806. const PCHAR ufn,
  1807. PCHAR *pDn
  1808. );
  1809. #if LDAP_UNICODE
  1810. #define ldap_ufn2dn ldap_ufn2dnW
  1811. #else
  1812. WINLDAPAPI ULONG LDAPAPI ldap_ufn2dn (
  1813. const PCHAR ufn,
  1814. PCHAR *pDn
  1815. );
  1816. #endif
  1817. #define LBER_USE_DER 0x01
  1818. #define LBER_USE_INDEFINITE_LEN 0x02
  1819. #define LBER_TRANSLATE_STRINGS 0x04
  1820. //
  1821. // Call to initialize the LDAP library. Pass in a version structure with
  1822. // lv_size set to sizeof( LDAP_VERSION ), lv_major set to LAPI_MAJOR_VER1,
  1823. // and lv_minor set to LAPI_MINOR_VER1. Return value will be either
  1824. // LDAP_SUCCESS if OK or LDAP_OPERATIONS_ERROR if can't be supported.
  1825. //
  1826. #define LAPI_MAJOR_VER1 1
  1827. #define LAPI_MINOR_VER1 1
  1828. typedef struct ldap_version_info {
  1829. ULONG lv_size;
  1830. ULONG lv_major;
  1831. ULONG lv_minor;
  1832. } LDAP_VERSION_INFO, *PLDAP_VERSION_INFO;
  1833. WINLDAPAPI ULONG LDAPAPI ldap_startup (
  1834. PLDAP_VERSION_INFO version,
  1835. HANDLE *Instance
  1836. );
  1837. //
  1838. // Calls to retrieve basic information about the API and specific implementations
  1839. // being used. The caller has to pass the LDAP_OPT_API_INFO option along with
  1840. // a pointer to the following structure to retrieve information about this library.
  1841. // It is the caller's responsibility to free the individual strings and string
  1842. // arrays in the structure using ldap_memfree() and ldap_value_free() respectively.
  1843. //
  1844. #define LDAP_API_INFO_VERSION 1
  1845. #define LDAP_API_VERSION 2004
  1846. #define LDAP_VERSION_MIN 2
  1847. #define LDAP_VERSION_MAX 3
  1848. #define LDAP_VENDOR_NAME "Microsoft Corporation."
  1849. #define LDAP_VENDOR_NAME_W L"Microsoft Corporation."
  1850. #define LDAP_VENDOR_VERSION 510
  1851. typedef struct ldapapiinfoA {
  1852. int ldapai_info_version; /* version of this struct: LDAP_API_INFO_VERSION */
  1853. int ldapai_api_version; /* revision of API supported */
  1854. int ldapai_protocol_version; /* highest LDAP version supported */
  1855. char **ldapai_extensions; /* names of API extensions */
  1856. char *ldapai_vendor_name; /* name of supplier */
  1857. int ldapai_vendor_version; /* supplier-specific version times 100 */
  1858. } LDAPAPIInfoA;
  1859. typedef struct ldapapiinfoW {
  1860. int ldapai_info_version; /* version of this struct: LDAP_API_INFO_VERSION */
  1861. int ldapai_api_version; /* revision of API supported */
  1862. int ldapai_protocol_version; /* highest LDAP version supported */
  1863. PWCHAR *ldapai_extensions; /* names of API extensions */
  1864. PWCHAR ldapai_vendor_name; /* name of supplier */
  1865. int ldapai_vendor_version; /* supplier-specific version times 100 */
  1866. } LDAPAPIInfoW;
  1867. #define LDAP_FEATURE_INFO_VERSION 1
  1868. typedef struct ldap_apifeature_infoA {
  1869. int ldapaif_info_version; /* version of this struct : LDAP_FEATURE_INFO_VERSION */
  1870. char *ldapaif_name; /* name of supported feature */
  1871. int ldapaif_version; /* revision of supported feature */
  1872. } LDAPAPIFeatureInfoA;
  1873. typedef struct ldap_apifeature_infoW {
  1874. int ldapaif_info_version; /* version of this struct : LDAP_FEATURE_INFO_VERSION */
  1875. PWCHAR ldapaif_name; /* name of supported feature */
  1876. int ldapaif_version; /* revision of supported feature */
  1877. } LDAPAPIFeatureInfoW;
  1878. #if LDAP_UNICODE
  1879. #define LDAPAPIInfo LDAPAPIInfoW
  1880. #define LDAPAPIFeatureInfo LDAPAPIFeatureInfoW
  1881. #else
  1882. #define LDAPAPIInfo LDAPAPIInfoA
  1883. #define LDAPAPIFeatureInfo LDAPAPIFeatureInfoA
  1884. #endif
  1885. //
  1886. // ldap_cleanup unloads the library when the refcount of opens goes to zero.
  1887. // (i.e. if a DLL calls it within a program that is also using it, it won't
  1888. // free all resources)
  1889. //
  1890. WINLDAPAPI ULONG LDAPAPI ldap_cleanup (
  1891. HANDLE hInstance
  1892. );
  1893. //
  1894. // Extended API to support allowing opaque blobs of data in search filters.
  1895. // This API takes any filter element and converts it to a safe text string that
  1896. // can safely be passed in a search filter.
  1897. // An example of using this is :
  1898. //
  1899. // filter is something like guid=4826BF6CF0123444
  1900. // this will put out on the wire guid of binary 0x4826BF6CF0123444
  1901. //
  1902. // call ldap_escape_filter_element with sourceFilterElement pointing to
  1903. // raw data, sourceCount set appropriately to length of data.
  1904. //
  1905. // if destFilterElement is NULL, then return value is length required for
  1906. // output buffer.
  1907. //
  1908. // if destFilterElement is not NULL, then the function will copy the source
  1909. // into the dest buffer and ensure that it is of a safe format.
  1910. //
  1911. // then simply insert the dest buffer into your search filter after the
  1912. // "attributetype=".
  1913. //
  1914. // this will put out on the wire guid of binary 0x004826BF6CF000123444
  1915. //
  1916. // Note : don't call this for attribute values that are really strings, as
  1917. // we won't do any conversion from what you passed in to UTF-8. Should only
  1918. // be used for attributes that really are raw binary.
  1919. //
  1920. WINLDAPAPI ULONG LDAPAPI ldap_escape_filter_elementW (
  1921. PCHAR sourceFilterElement,
  1922. ULONG sourceLength,
  1923. PWCHAR destFilterElement,
  1924. ULONG destLength
  1925. );
  1926. WINLDAPAPI ULONG LDAPAPI ldap_escape_filter_elementA (
  1927. PCHAR sourceFilterElement,
  1928. ULONG sourceLength,
  1929. PCHAR destFilterElement,
  1930. ULONG destLength
  1931. );
  1932. #if LDAP_UNICODE
  1933. #define ldap_escape_filter_element ldap_escape_filter_elementW
  1934. #else
  1935. WINLDAPAPI ULONG LDAPAPI ldap_escape_filter_element (
  1936. PCHAR sourceFilterElement,
  1937. ULONG sourceLength,
  1938. PCHAR destFilterElement,
  1939. ULONG destLength
  1940. );
  1941. #endif
  1942. //
  1943. // Misc extensions for additional debugging.
  1944. //
  1945. // Note that these do nothing on free builds.
  1946. //
  1947. WINLDAPAPI ULONG LDAPAPI ldap_set_dbg_flags( ULONG NewFlags );
  1948. typedef ULONG (_cdecl *DBGPRINT)( PCH Format, ... );
  1949. WINLDAPAPI VOID LDAPAPI ldap_set_dbg_routine( DBGPRINT DebugPrintRoutine );
  1950. //
  1951. // These routines are possibly useful by other modules. Note that Win95
  1952. // doesn't by default have the UTF-8 codepage loaded. So a good way to
  1953. // convert from UTF-8 to Unicode.
  1954. //
  1955. WINLDAPAPI int LDAPAPI
  1956. LdapUTF8ToUnicode(
  1957. LPCSTR lpSrcStr,
  1958. int cchSrc,
  1959. LPWSTR lpDestStr,
  1960. int cchDest
  1961. );
  1962. WINLDAPAPI
  1963. int LDAPAPI
  1964. LdapUnicodeToUTF8(
  1965. LPCWSTR lpSrcStr,
  1966. int cchSrc,
  1967. LPSTR lpDestStr,
  1968. int cchDest
  1969. );
  1970. //
  1971. // LDAPv3 features :
  1972. //
  1973. // Sort Keys... these are used to ask the server to sort the results
  1974. // before sending the results back. LDAPv3 only and optional to implement
  1975. // on the server side. Check supportedControl for an OID of
  1976. // "1.2.840.113556.1.4.473" to see if the server supports it.
  1977. //
  1978. #define LDAP_SERVER_SORT_OID "1.2.840.113556.1.4.473"
  1979. #define LDAP_SERVER_SORT_OID_W L"1.2.840.113556.1.4.473"
  1980. #define LDAP_SERVER_RESP_SORT_OID "1.2.840.113556.1.4.474"
  1981. #define LDAP_SERVER_RESP_SORT_OID_W L"1.2.840.113556.1.4.474"
  1982. typedef struct ldapsearch LDAPSearch, *PLDAPSearch;
  1983. typedef struct ldapsortkeyW {
  1984. PWCHAR sk_attrtype;
  1985. PWCHAR sk_matchruleoid;
  1986. BOOLEAN sk_reverseorder;
  1987. } LDAPSortKeyW, *PLDAPSortKeyW;
  1988. typedef struct ldapsortkeyA {
  1989. PCHAR sk_attrtype;
  1990. PCHAR sk_matchruleoid;
  1991. BOOLEAN sk_reverseorder;
  1992. } LDAPSortKeyA, *PLDAPSortKeyA;
  1993. #if LDAP_UNICODE
  1994. #define LDAPSortKey LDAPSortKeyW
  1995. #define PLDAPSortKey PLDAPSortKeyW
  1996. #else
  1997. #define LDAPSortKey LDAPSortKeyA
  1998. #define PLDAPSortKey PLDAPSortKeyA
  1999. #endif
  2000. //
  2001. // This API formats a list of sort keys into a search control. Call
  2002. // ldap_control_free when you're finished with the control.
  2003. //
  2004. // Use this one rather than ldap_encode_sort_control as this is per RFC.
  2005. //
  2006. WINLDAPAPI ULONG LDAPAPI ldap_create_sort_controlA (
  2007. PLDAP ExternalHandle,
  2008. PLDAPSortKeyA *SortKeys,
  2009. UCHAR IsCritical,
  2010. PLDAPControlA *Control
  2011. );
  2012. WINLDAPAPI ULONG LDAPAPI ldap_create_sort_controlW (
  2013. PLDAP ExternalHandle,
  2014. PLDAPSortKeyW *SortKeys,
  2015. UCHAR IsCritical,
  2016. PLDAPControlW *Control
  2017. );
  2018. //
  2019. // This API parses the sort control returned by the server. Use ldap_memfree
  2020. // to free the attribute value, if it's returned.
  2021. //
  2022. WINLDAPAPI ULONG LDAPAPI ldap_parse_sort_controlA (
  2023. PLDAP ExternalHandle,
  2024. PLDAPControlA *Control,
  2025. ULONG *Result,
  2026. PCHAR *Attribute
  2027. );
  2028. WINLDAPAPI ULONG LDAPAPI ldap_parse_sort_controlW (
  2029. PLDAP ExternalHandle,
  2030. PLDAPControlW *Control,
  2031. ULONG *Result,
  2032. PWCHAR *Attribute
  2033. );
  2034. #if LDAP_UNICODE
  2035. #define ldap_create_sort_control ldap_create_sort_controlW
  2036. #define ldap_parse_sort_control ldap_parse_sort_controlW
  2037. #else
  2038. WINLDAPAPI ULONG LDAPAPI ldap_create_sort_control (
  2039. PLDAP ExternalHandle,
  2040. PLDAPSortKeyA *SortKeys,
  2041. UCHAR IsCritical,
  2042. PLDAPControlA *Control
  2043. );
  2044. WINLDAPAPI ULONG LDAPAPI ldap_parse_sort_control (
  2045. PLDAP ExternalHandle,
  2046. PLDAPControlA *Control,
  2047. ULONG *Result,
  2048. PCHAR *Attribute
  2049. );
  2050. #endif
  2051. //
  2052. // This API formats a list of sort keys into a search control. Call
  2053. // ldap_memfree for both Control->ldctl_value.bv_val and
  2054. // Control->currentControl->ldctl_oid when you're finished with the control.
  2055. //
  2056. // This is the old sort API that will be shortly pulled. Please use
  2057. // ldap_create_sort_control defined above.
  2058. //
  2059. WINLDAPAPI ULONG LDAPAPI ldap_encode_sort_controlW (
  2060. PLDAP ExternalHandle,
  2061. PLDAPSortKeyW *SortKeys,
  2062. PLDAPControlW Control,
  2063. BOOLEAN Criticality
  2064. );
  2065. WINLDAPAPI ULONG LDAPAPI ldap_encode_sort_controlA (
  2066. PLDAP ExternalHandle,
  2067. PLDAPSortKeyA *SortKeys,
  2068. PLDAPControlA Control,
  2069. BOOLEAN Criticality
  2070. );
  2071. #if LDAP_UNICODE
  2072. #define ldap_encode_sort_control ldap_encode_sort_controlW
  2073. #else
  2074. WINLDAPAPI ULONG LDAPAPI ldap_encode_sort_control (
  2075. PLDAP ExternalHandle,
  2076. PLDAPSortKeyA *SortKeys,
  2077. PLDAPControlA Control,
  2078. BOOLEAN Criticality
  2079. );
  2080. #endif
  2081. //
  2082. // LDAPv3: This is the RFC defined API for the simple paging of results
  2083. // control. Use ldap_control_free to free the control allocated by
  2084. // ldap_create_page_control.
  2085. //
  2086. WINLDAPAPI ULONG LDAPAPI ldap_create_page_controlW(
  2087. PLDAP ExternalHandle,
  2088. ULONG PageSize,
  2089. struct berval *Cookie,
  2090. UCHAR IsCritical,
  2091. PLDAPControlW *Control
  2092. );
  2093. WINLDAPAPI ULONG LDAPAPI ldap_create_page_controlA(
  2094. PLDAP ExternalHandle,
  2095. ULONG PageSize,
  2096. struct berval *Cookie,
  2097. UCHAR IsCritical,
  2098. PLDAPControlA *Control
  2099. );
  2100. WINLDAPAPI ULONG LDAPAPI ldap_parse_page_controlW (
  2101. PLDAP ExternalHandle,
  2102. PLDAPControlW *ServerControls,
  2103. ULONG *TotalCount,
  2104. struct berval **Cookie // Use ber_bvfree to free
  2105. );
  2106. WINLDAPAPI ULONG LDAPAPI ldap_parse_page_controlA (
  2107. PLDAP ExternalHandle,
  2108. PLDAPControlA *ServerControls,
  2109. ULONG *TotalCount,
  2110. struct berval **Cookie // Use ber_bvfree to free
  2111. );
  2112. #if LDAP_UNICODE
  2113. #define ldap_create_page_control ldap_create_page_controlW
  2114. #define ldap_parse_page_control ldap_parse_page_controlW
  2115. #else
  2116. WINLDAPAPI ULONG LDAPAPI ldap_create_page_control(
  2117. PLDAP ExternalHandle,
  2118. ULONG PageSize,
  2119. struct berval *Cookie,
  2120. UCHAR IsCritical,
  2121. PLDAPControlA *Control
  2122. );
  2123. WINLDAPAPI ULONG LDAPAPI ldap_parse_page_control (
  2124. PLDAP ExternalHandle,
  2125. PLDAPControlA *ServerControls,
  2126. ULONG *TotalCount,
  2127. struct berval **Cookie // Use ber_bvfree to free
  2128. );
  2129. #endif
  2130. //
  2131. // LDAPv3: This is the interface for simple paging of results. To ensure
  2132. // that the server supports it, check the supportedControl property off of
  2133. // the root for an OID of 1.2.840.113556.1.4.319. If it is there, then it
  2134. // supports this feature.
  2135. //
  2136. // If you're going to specify sort keys, see section above on sort keys on
  2137. // now to tell if they're supported by the server.
  2138. //
  2139. // You first call ldap_search_init_page. If it returns a non-NULL LDAPSearch
  2140. // block, then it worked ok. Otherwise call LdapGetLastError to find error.
  2141. //
  2142. // With a valid LDAPSearch block (there are opaque), call ldap_get_next_page
  2143. // or ldap_get_next_page_s. If you call ldap_get_next_page, you MUST call
  2144. // ldap_get_paged_count for each set of results that you get for that message.
  2145. // This allows the library to save off the cookie that the server sent to
  2146. // resume the search.
  2147. //
  2148. // Other than calling ldap_get_paged_count, the results you get back from
  2149. // ldap_get_next_page can be treated as any other search result, and should
  2150. // be freed when you're done by calling ldap_msgfree.
  2151. //
  2152. // When the end of the search is hit, you'll get a return code of
  2153. // LDAP_NO_RESULTS_RETURNED. At this point, (or any point after LDAPSearch
  2154. // structure has been allocated), you call ldap_search_abandon_page. You
  2155. // need to call this even after you get a return code of
  2156. // LDAP_NO_RESULTS_RETURNED.
  2157. //
  2158. // If you call ldap_get_next_page_s, you don't need to call
  2159. // ldap_get_paged_count.
  2160. //
  2161. #define LDAP_PAGED_RESULT_OID_STRING "1.2.840.113556.1.4.319"
  2162. #define LDAP_PAGED_RESULT_OID_STRING_W L"1.2.840.113556.1.4.319"
  2163. WINLDAPAPI PLDAPSearch LDAPAPI ldap_search_init_pageW(
  2164. PLDAP ExternalHandle,
  2165. const PWCHAR DistinguishedName,
  2166. ULONG ScopeOfSearch,
  2167. const PWCHAR SearchFilter,
  2168. PWCHAR AttributeList[],
  2169. ULONG AttributesOnly,
  2170. PLDAPControlW *ServerControls,
  2171. PLDAPControlW *ClientControls,
  2172. ULONG PageTimeLimit,
  2173. ULONG TotalSizeLimit,
  2174. PLDAPSortKeyW *SortKeys
  2175. );
  2176. WINLDAPAPI PLDAPSearch LDAPAPI ldap_search_init_pageA(
  2177. PLDAP ExternalHandle,
  2178. const PCHAR DistinguishedName,
  2179. ULONG ScopeOfSearch,
  2180. const PCHAR SearchFilter,
  2181. PCHAR AttributeList[],
  2182. ULONG AttributesOnly,
  2183. PLDAPControlA *ServerControls,
  2184. PLDAPControlA *ClientControls,
  2185. ULONG PageTimeLimit,
  2186. ULONG TotalSizeLimit,
  2187. PLDAPSortKeyA *SortKeys
  2188. );
  2189. #if LDAP_UNICODE
  2190. #define ldap_search_init_page ldap_search_init_pageW
  2191. #else
  2192. WINLDAPAPI PLDAPSearch LDAPAPI ldap_search_init_page(
  2193. PLDAP ExternalHandle,
  2194. const PCHAR DistinguishedName,
  2195. ULONG ScopeOfSearch,
  2196. const PCHAR SearchFilter,
  2197. PCHAR AttributeList[],
  2198. ULONG AttributesOnly,
  2199. PLDAPControl *ServerControls,
  2200. PLDAPControl *ClientControls,
  2201. ULONG PageTimeLimit,
  2202. ULONG TotalSizeLimit,
  2203. PLDAPSortKey *SortKeys
  2204. );
  2205. #endif
  2206. WINLDAPAPI ULONG LDAPAPI ldap_get_next_page(
  2207. PLDAP ExternalHandle,
  2208. PLDAPSearch SearchHandle,
  2209. ULONG PageSize,
  2210. ULONG *MessageNumber
  2211. );
  2212. WINLDAPAPI ULONG LDAPAPI ldap_get_next_page_s(
  2213. PLDAP ExternalHandle,
  2214. PLDAPSearch SearchHandle,
  2215. struct l_timeval *timeout,
  2216. ULONG PageSize,
  2217. ULONG *TotalCount,
  2218. LDAPMessage **Results
  2219. );
  2220. WINLDAPAPI ULONG LDAPAPI ldap_get_paged_count(
  2221. PLDAP ExternalHandle,
  2222. PLDAPSearch SearchBlock,
  2223. ULONG *TotalCount,
  2224. PLDAPMessage Results
  2225. );
  2226. WINLDAPAPI ULONG LDAPAPI ldap_search_abandon_page(
  2227. PLDAP ExternalHandle,
  2228. PLDAPSearch SearchBlock
  2229. );
  2230. //
  2231. // The Virtual List View (VLV) functions are used to simulate an address book
  2232. // like client scenario where the user can request a small window of results
  2233. // within a larger result set. The advantage of this method is that the client
  2234. // does not have to store all of the results sent back from the server. This
  2235. // also acts as a superset of simple paging.
  2236. //
  2237. #define LDAP_CONTROL_VLVREQUEST "2.16.840.1.113730.3.4.9"
  2238. #define LDAP_CONTROL_VLVREQUEST_W L"2.16.840.1.113730.3.4.9"
  2239. #define LDAP_CONTROL_VLVRESPONSE "2.16.840.1.113730.3.4.10"
  2240. #define LDAP_CONTROL_VLVRESPONSE_W L"2.16.840.1.113730.3.4.10"
  2241. //
  2242. // This library supports the version 01 of the internet draft
  2243. // draft-smith-ldap-c-api-ext-vlv-01.txt
  2244. //
  2245. #define LDAP_API_FEATURE_VIRTUAL_LIST_VIEW 1001
  2246. #define LDAP_VLVINFO_VERSION 1
  2247. typedef struct ldapvlvinfo {
  2248. int ldvlv_version; // version of this struct (1)
  2249. ULONG ldvlv_before_count;
  2250. ULONG ldvlv_after_count;
  2251. ULONG ldvlv_offset; // used if ldvlv_attrvalue is NULL
  2252. ULONG ldvlv_count; // used if ldvlv_attrvalue is NULL
  2253. PBERVAL ldvlv_attrvalue;
  2254. PBERVAL ldvlv_context;
  2255. VOID *ldvlv_extradata; // for use by application
  2256. } LDAPVLVInfo, *PLDAPVLVInfo;
  2257. WINLDAPAPI INT LDAPAPI ldap_create_vlv_controlW (
  2258. PLDAP ExternalHandle,
  2259. PLDAPVLVInfo VlvInfo,
  2260. UCHAR IsCritical,
  2261. PLDAPControlW *Control
  2262. );
  2263. WINLDAPAPI INT LDAPAPI ldap_create_vlv_controlA (
  2264. PLDAP ExternalHandle,
  2265. PLDAPVLVInfo VlvInfo,
  2266. UCHAR IsCritical,
  2267. PLDAPControlA *Control
  2268. );
  2269. WINLDAPAPI INT LDAPAPI ldap_parse_vlv_controlW (
  2270. PLDAP ExternalHandle,
  2271. PLDAPControlW *Control,
  2272. PULONG TargetPos,
  2273. PULONG ListCount,
  2274. PBERVAL *Context,
  2275. PINT ErrCode
  2276. );
  2277. WINLDAPAPI INT LDAPAPI ldap_parse_vlv_controlA (
  2278. PLDAP ExternalHandle,
  2279. PLDAPControlA *Control,
  2280. PULONG TargetPos,
  2281. PULONG ListCount,
  2282. PBERVAL *Context,
  2283. PINT ErrCode
  2284. );
  2285. #if LDAP_UNICODE
  2286. #define ldap_create_vlv_control ldap_create_vlv_controlW
  2287. #define ldap_parse_vlv_control ldap_parse_vlv_controlW
  2288. #else
  2289. #define ldap_create_vlv_control ldap_create_vlv_controlA
  2290. #define ldap_parse_vlv_control ldap_parse_vlv_controlA
  2291. #endif
  2292. //
  2293. // The StartTLS APIs are used for establishing Transport Layer Security on
  2294. // the fly.
  2295. //
  2296. #define LDAP_START_TLS_OID "1.3.6.1.4.1.1466.20037"
  2297. #define LDAP_START_TLS_OID_W L"1.3.6.1.4.1.1466.20037"
  2298. //
  2299. // This API is called by users to initiate Transport Level Security on an
  2300. // LDAP connection. If the server accepts our proposal and initiates TLS,
  2301. // this API will return LDAP_SUCCESS.
  2302. //
  2303. // If the server fails the request for whatever reason, the API returns LDAP_OTHER
  2304. // and the ServerReturnValue will contain the error code from the server.
  2305. //
  2306. // It is possible that the server returns a referral - either in response to the
  2307. // StartTLS request or during the subsequent encrypted session. For security
  2308. // reasons, we have decided to NOT chase referrals by default. In the former case
  2309. // the referral message is returned as an LDAPMessage to the user.
  2310. //
  2311. // The operation has a default timeout of about 30 seconds.
  2312. //
  2313. WINLDAPAPI ULONG LDAPAPI ldap_start_tls_sW (
  2314. IN PLDAP ExternalHandle,
  2315. OUT PULONG ServerReturnValue,
  2316. OUT LDAPMessage **result,
  2317. IN PLDAPControlW *ServerControls,
  2318. IN PLDAPControlW *ClientControls
  2319. );
  2320. WINLDAPAPI ULONG LDAPAPI ldap_start_tls_sA (
  2321. IN PLDAP ExternalHandle,
  2322. OUT PULONG ServerReturnValue,
  2323. OUT LDAPMessage **result,
  2324. IN PLDAPControlA *ServerControls,
  2325. IN PLDAPControlA *ClientControls
  2326. );
  2327. //
  2328. // This API is called by the user to stop Transport Level Security on an open
  2329. // LDAP connection on which TLS has already been started.
  2330. //
  2331. // If the operation succeeds, the user can resume normal plaintext LDAP
  2332. // operations on the connection.
  2333. //
  2334. // If the operation fails, the user MUST close the connection by calling
  2335. // ldap_unbind as the TLS state of the connection will be indeterminate.
  2336. //
  2337. // The operation has a default timeout of about 30 seconds.
  2338. //
  2339. WINLDAPAPI BOOLEAN LDAPAPI ldap_stop_tls_s (
  2340. IN PLDAP ExternalHandle
  2341. );
  2342. #if LDAP_UNICODE
  2343. #define ldap_start_tls_s ldap_start_tls_sW
  2344. #else
  2345. #define ldap_start_tls_s ldap_start_tls_sA
  2346. #endif
  2347. //
  2348. // This OID is used in a Refresh Extended operation as defined in
  2349. // RFC 2589: LDAP v3 Extensions for Dynamic Directory Services
  2350. //
  2351. #define LDAP_TTL_EXTENDED_OP_OID "1.3.6.1.4.1.1466.101.119.1"
  2352. #define LDAP_TTL_EXTENDED_OP_OID_W L"1.3.6.1.4.1.1466.101.119.1"
  2353. //
  2354. // These functions return subordinate referrals (references) that are returned
  2355. // in search responses. There are two types of referrals. External referrals
  2356. // where the naming context doesn't reside on the server (e.g. server says "I
  2357. // don't have the data, look over there") and Subordinate referrals (or
  2358. // references) where some data has been returned and the referrals are passed
  2359. // to other naming contexts below the current one (e.g. servers says "Here's
  2360. // some data from the tree I hold, go look here, there, and over there for
  2361. // more data that is further down in the tree.").
  2362. //
  2363. // These routines handle the latter. For external references, use
  2364. // ldap_parse_result.
  2365. //
  2366. // Return the first reference from a message. It is freed when the message is
  2367. // freed so should not be freed explicitly.
  2368. //
  2369. WINLDAPAPI LDAPMessage *LDAPAPI ldap_first_reference( LDAP *ld, LDAPMessage *res );
  2370. //
  2371. // Return the next entry of a message. It is freed when the message is
  2372. // freed so should not be freed explicitly.
  2373. //
  2374. WINLDAPAPI LDAPMessage *LDAPAPI ldap_next_reference( LDAP *ld, LDAPMessage *entry );
  2375. //
  2376. // Count the number of subordinate references returned by the server in a
  2377. // response to a search request.
  2378. //
  2379. WINLDAPAPI ULONG LDAPAPI ldap_count_references( LDAP *ld, LDAPMessage *res );
  2380. //
  2381. // We return the list of subordinate referrals in a search response message.
  2382. //
  2383. WINLDAPAPI ULONG LDAPAPI ldap_parse_referenceW (
  2384. LDAP *Connection,
  2385. LDAPMessage *ResultMessage,
  2386. PWCHAR **Referrals // free with ldap_value_freeW
  2387. );
  2388. WINLDAPAPI ULONG LDAPAPI ldap_parse_referenceA (
  2389. LDAP *Connection,
  2390. LDAPMessage *ResultMessage,
  2391. PCHAR **Referrals // free with ldap_value_freeA
  2392. );
  2393. #if LDAP_UNICODE
  2394. #define ldap_parse_reference ldap_parse_referenceW
  2395. #else
  2396. WINLDAPAPI ULONG LDAPAPI ldap_parse_reference (
  2397. LDAP *Connection,
  2398. LDAPMessage *ResultMessage,
  2399. PCHAR **Referrals // free with ldap_value_free
  2400. );
  2401. #endif
  2402. //
  2403. // These APIs allow a client to send an extended request (free for all) to
  2404. // an LDAPv3 (or above) server. The functionality is fairly open... you can
  2405. // send any request you'd like. Note that since we don't know if you'll
  2406. // be receiving a single or multiple responses, you'll have to explicitly tell
  2407. // us when you're done with the request by calling ldap_close_extended_op.
  2408. //
  2409. // These are thread safe.
  2410. //
  2411. WINLDAPAPI ULONG LDAPAPI ldap_extended_operationW(
  2412. LDAP *ld,
  2413. const PWCHAR Oid,
  2414. struct berval *Data,
  2415. PLDAPControlW *ServerControls,
  2416. PLDAPControlW *ClientControls,
  2417. ULONG *MessageNumber
  2418. );
  2419. WINLDAPAPI ULONG LDAPAPI ldap_extended_operationA(
  2420. LDAP *ld,
  2421. const PCHAR Oid,
  2422. struct berval *Data,
  2423. PLDAPControlA *ServerControls,
  2424. PLDAPControlA *ClientControls,
  2425. ULONG *MessageNumber
  2426. );
  2427. WINLDAPAPI ULONG LDAPAPI ldap_extended_operation_sA (
  2428. LDAP *ExternalHandle,
  2429. PCHAR Oid,
  2430. struct berval *Data,
  2431. PLDAPControlA *ServerControls,
  2432. PLDAPControlA *ClientControls,
  2433. PCHAR *ReturnedOid,
  2434. struct berval **ReturnedData
  2435. );
  2436. WINLDAPAPI ULONG LDAPAPI ldap_extended_operation_sW (
  2437. LDAP *ExternalHandle,
  2438. PWCHAR Oid,
  2439. struct berval *Data,
  2440. PLDAPControlW *ServerControls,
  2441. PLDAPControlW *ClientControls,
  2442. PWCHAR *ReturnedOid,
  2443. struct berval **ReturnedData
  2444. );
  2445. #if LDAP_UNICODE
  2446. #define ldap_extended_operation ldap_extended_operationW
  2447. #define ldap_extended_operation_s ldap_extended_operation_sW
  2448. #else
  2449. WINLDAPAPI ULONG LDAPAPI ldap_extended_operation(
  2450. LDAP *ld,
  2451. const PCHAR Oid,
  2452. struct berval *Data,
  2453. PLDAPControlA *ServerControls,
  2454. PLDAPControlA *ClientControls,
  2455. ULONG *MessageNumber
  2456. );
  2457. #define ldap_extended_operation_s ldap_extended_operation_sA
  2458. #endif
  2459. WINLDAPAPI ULONG LDAPAPI ldap_close_extended_op(
  2460. LDAP *ld,
  2461. ULONG MessageNumber
  2462. );
  2463. //
  2464. // Some enhancements that will probably never make it into the RFC related
  2465. // to callouts to allow external caching of connections.
  2466. //
  2467. // Call ldap_set_option( conn, LDAP_OPT_REFERRAL_CALLBACK, &referralRoutines )
  2468. // where referralRoutines is the address of an LDAP_REFERRAL_CALLBACK
  2469. // structure with your routines. They may be NULL, in which case we'll
  2470. // obviously not make the calls.
  2471. //
  2472. // Any connections that are created will inherit the current callbacks from
  2473. // the primary connection that the request was initiated on.
  2474. //
  2475. #define LDAP_OPT_REFERRAL_CALLBACK 0x70
  2476. //
  2477. // This first routine is called when we're about to chase a referral. We
  2478. // callout to it to see if there is already a connection cached that we
  2479. // can use. If so, the callback routine returns the pointer to the
  2480. // connection to use in ConnectionToUse. If not, it sets
  2481. // *ConnectionToUse to NULL.
  2482. //
  2483. // For a return code, it should return 0 if we should continue to chase the
  2484. // referral. If it returns a non-zero return code, we'll treat that as the
  2485. // error code for chasing the referral. This allows caching of host names
  2486. // that are not reachable, if we decide to add that in the future.
  2487. //
  2488. typedef ULONG (_cdecl QUERYFORCONNECTION)(
  2489. PLDAP PrimaryConnection,
  2490. PLDAP ReferralFromConnection,
  2491. PWCHAR NewDN,
  2492. PCHAR HostName,
  2493. ULONG PortNumber,
  2494. PVOID SecAuthIdentity, // if null, use CurrentUser below
  2495. PVOID CurrentUserToken, // pointer to current user's LUID
  2496. PLDAP *ConnectionToUse
  2497. );
  2498. //
  2499. // This next function is called when we've created a new connection while
  2500. // chasing a referral. Note that it gets assigned the same callback functions
  2501. // as the PrimaryConnection. If the return code is FALSE, then the call
  2502. // back function doesn't want to cache the connection and it will be
  2503. // destroyed after the operation is complete. If TRUE is returned, we'll
  2504. // assume that the callee has taken ownership of the connection and it will
  2505. // not be destroyed after the operation is complete.
  2506. //
  2507. // If the ErrorCodeFromBind field is not 0, then the bind operation to
  2508. // that server failed.
  2509. //
  2510. typedef BOOLEAN (_cdecl NOTIFYOFNEWCONNECTION) (
  2511. PLDAP PrimaryConnection,
  2512. PLDAP ReferralFromConnection,
  2513. PWCHAR NewDN,
  2514. PCHAR HostName,
  2515. PLDAP NewConnection,
  2516. ULONG PortNumber,
  2517. PVOID SecAuthIdentity, // if null, use CurrentUser below
  2518. PVOID CurrentUser, // pointer to current user's LUID
  2519. ULONG ErrorCodeFromBind
  2520. );
  2521. //
  2522. // This next function is called when we've successfully called off to the
  2523. // QueryForConnection call and received a connection OR when we called off
  2524. // to the NotifyOfNewConnection call and it returned TRUE. We call this
  2525. // function when we're dereferencing the connection after we're done with it.
  2526. //
  2527. // Return code is currently ignored, but the function should return
  2528. // LDAP_SUCCESS if all went well.
  2529. //
  2530. typedef ULONG (_cdecl DEREFERENCECONNECTION)(
  2531. PLDAP PrimaryConnection,
  2532. PLDAP ConnectionToDereference
  2533. );
  2534. typedef struct LdapReferralCallback {
  2535. ULONG SizeOfCallbacks; // set to sizeof( LDAP_REFERRAL_CALLBACK )
  2536. QUERYFORCONNECTION *QueryForConnection;
  2537. NOTIFYOFNEWCONNECTION *NotifyRoutine;
  2538. DEREFERENCECONNECTION *DereferenceRoutine;
  2539. } LDAP_REFERRAL_CALLBACK, *PLDAP_REFERRAL_CALLBACK;
  2540. //
  2541. // Thread Safe way to get last error code returned by LDAP API is to call
  2542. // LdapGetLastError();
  2543. //
  2544. WINLDAPAPI ULONG LDAPAPI LdapGetLastError( VOID );
  2545. //
  2546. // Translate from LdapError to closest Win32 error code.
  2547. //
  2548. WINLDAPAPI ULONG LDAPAPI LdapMapErrorToWin32( ULONG LdapError );
  2549. //
  2550. // This is an arrangement for specifying client certificates while establishing
  2551. // an SSL connection.
  2552. // Simply Call ldap_set_option( conn, LDAP_OPT_CLIENT_CERTIFICATE, &CertRoutine )
  2553. // where CertRoutine is the address of your callback routine. If it is NULL,
  2554. // we will obviously not make the call.
  2555. //
  2556. #define LDAP_OPT_CLIENT_CERTIFICATE 0x80
  2557. //
  2558. // This callback is invoked when the server demands a client certificate for
  2559. // authorization. The application should examine the list of Certificate Authorities
  2560. // the server trusts and supply an appropriate client certificate. wldap32.dll
  2561. // subsequently passes these credentials to the SSL server as part of the
  2562. // handshake. If the application desires that anonymous credentials be used,
  2563. // it must return FALSE instead of a certificate. Any certificate must be freed
  2564. // by the application after the connection has been completed. Note that the
  2565. // application MUST perform an EXTERNAL bind subsequent to connection
  2566. // establishment for these credentials to be used by the server.
  2567. //
  2568. typedef BOOLEAN (_cdecl QUERYCLIENTCERT) (
  2569. IN PLDAP Connection,
  2570. IN PSecPkgContext_IssuerListInfoEx trusted_CAs,
  2571. IN OUT PCCERT_CONTEXT *ppCertificate
  2572. );
  2573. //
  2574. // We are also giving an opportunity for the client to verify the certificate
  2575. // of the server. The client registers a callback which is invoked after the
  2576. // secure connection is setup. The server certificate is presented to the
  2577. // client who invokes it and decides it it is acceptable. To register this
  2578. // callback, simply call ldap_set_option( conn, LDAP_OPT_SERVER_CERTIFICATE, &CertRoutine )
  2579. //
  2580. #define LDAP_OPT_SERVER_CERTIFICATE 0x81
  2581. //
  2582. // This function is called after the secure connection has been established. The
  2583. // certificate of the server is supplied for examination by the client. If the
  2584. // client approves it, it returns TRUE else, it returns false and the secure
  2585. // connection is torn down.
  2586. //
  2587. typedef BOOLEAN (_cdecl VERIFYSERVERCERT) (
  2588. PLDAP Connection,
  2589. PCCERT_CONTEXT pServerCert
  2590. );
  2591. //
  2592. // Given an LDAP message, return the connection pointer where the message
  2593. // came from. It can return NULL if the connection has already been freed.
  2594. //
  2595. WINLDAPAPI LDAP * LDAPAPI ldap_conn_from_msg (
  2596. LDAP *PrimaryConn,
  2597. LDAPMessage *res
  2598. );
  2599. //
  2600. // Do we reference the connection for each message so that we can safely get
  2601. // the connection pointer back by calling ldap_conn_from_msg?
  2602. //
  2603. #define LDAP_OPT_REF_DEREF_CONN_PER_MSG 0x94
  2604. #ifdef __cplusplus
  2605. }
  2606. #endif
  2607. #endif // LDAP_CLIENT_DEFINED
  2608.