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.

457 lines
15 KiB

  1. /***********************************************************************
  2. *
  3. * _LDAPCNT.H
  4. *
  5. * Header file for code in LDAPCONT.C
  6. *
  7. * Copyright 1996 Microsoft Corporation. All Rights Reserved.
  8. *
  9. ***********************************************************************/
  10. /*
  11. * ABContainer for LDAP object. (i.e. IAB::OpenEntry() with an
  12. * lpEntryID of NULL).
  13. */
  14. #undef INTERFACE
  15. #define INTERFACE struct _LDAPCONT
  16. #undef MAPIMETHOD_
  17. #define MAPIMETHOD_(type, method) MAPIMETHOD_DECLARE(type, method, LDAPCONT_)
  18. MAPI_IUNKNOWN_METHODS(IMPL)
  19. MAPI_IMAPIPROP_METHODS(IMPL)
  20. MAPI_IMAPICONTAINER_METHODS(IMPL)
  21. MAPI_IABCONTAINER_METHODS(IMPL)
  22. #undef MAPIMETHOD_
  23. #define MAPIMETHOD_(type, method) MAPIMETHOD_TYPEDEF(type, method, LDAPCONT_)
  24. MAPI_IUNKNOWN_METHODS(IMPL)
  25. MAPI_IMAPIPROP_METHODS(IMPL)
  26. MAPI_IMAPICONTAINER_METHODS(IMPL)
  27. MAPI_IABCONTAINER_METHODS(IMPL)
  28. #undef MAPIMETHOD_
  29. #define MAPIMETHOD_(type, method) STDMETHOD_(type, method)
  30. DECLARE_MAPI_INTERFACE(LDAPCONT_) {
  31. BEGIN_INTERFACE
  32. MAPI_IUNKNOWN_METHODS(IMPL)
  33. MAPI_IMAPIPROP_METHODS(IMPL)
  34. MAPI_IMAPICONTAINER_METHODS(IMPL)
  35. MAPI_IABCONTAINER_METHODS(IMPL)
  36. };
  37. typedef struct _LDAPCONT {
  38. MAILUSER_BASE_MEMBERS(LDAPCONT)
  39. ULONG ulType;
  40. } LDAPCONT, *LPLDAPCONT;
  41. #define CBLDAP sizeof(LDAPCONT)
  42. #define LDAPCONT_cInterfaces 3
  43. /*============================================================================
  44. * LDAPVUE (table view class) functions
  45. *
  46. * Function prototypes for functions to override in the LDAPVUE vtable.
  47. */
  48. STDMETHODIMP
  49. LDAPVUE_FindRow(
  50. LPVUE lpvue,
  51. LPSRestriction lpres,
  52. BOOKMARK bkOrigin,
  53. ULONG ulFlags );
  54. STDMETHODIMP
  55. LDAPVUE_Restrict(
  56. LPVUE lpvue,
  57. LPSRestriction lpres,
  58. ULONG ulFlags );
  59. // Definitions
  60. #define LDAP_AUTH_METHOD_ANONYMOUS LDAP_AUTH_ANONYMOUS // Anonymous binding
  61. #define LDAP_AUTH_METHOD_SIMPLE LDAP_AUTH_PASSWORD // LDAP_AUTH_SIMPLE binding
  62. #define LDAP_AUTH_METHOD_SICILY LDAP_AUTH_MEMBER_SYSTEM // Use Sicily (challenge-response) authentication
  63. #define LDAP_USERNAME_LEN 256 // Maximum length for username/DN
  64. #define LDAP_PASSWORD_LEN 256 // Maximum length for password
  65. #define LDAP_ERROR 0xffffffff // Generic LDAP error code.
  66. #define COUNTRY_STR_LEN 2 // Size of country string for ldap_search base
  67. #define LDAP_SEARCH_SIZE_LIMIT 100 // Maximum number of entries to return from a search
  68. #define LDAP_SEARCH_TIME_LIMIT 60 // Maximum number of seconds for server to spend on a search
  69. #define LDAP_SEARCH_TIMER_ID 1 // ID of timer used for asynch LDAP searches
  70. #define LDAP_BIND_TIMER_ID 2 // ID of timer used for asynch LDAP bind
  71. #define LDAP_SEARCH_TIMER_DELAY 100 // Number of milliseconds to wait between polls for asynch LDAP searches
  72. #define SEARCH_CANCEL_DIALOG_DELAY 2000// Number of milliseconds to wait before displaying cancel dialog
  73. #define MAX_ULONG 0xffffffff
  74. #define LDAP_DEFAULT_PORT 389
  75. // structure for getting proc addresses of api functions
  76. typedef struct _APIFCN
  77. {
  78. PVOID * ppFcnPtr;
  79. LPCSTR pszName;
  80. } APIFCN;
  81. // structure to hold MAPI property to LDAP attibute mapping
  82. typedef struct _ATTRMAP
  83. {
  84. ULONG ulPropTag; // MAPI property tag
  85. const TCHAR * pszAttr; // LDAP attribute name
  86. } ATTRMAP;
  87. // structure to hold LDAP server parameters
  88. // as read in from the registry through the account manager
  89. //
  90. typedef struct _LDAPSERVERPARAMS
  91. {
  92. DWORD dwSearchSizeLimit;
  93. DWORD dwSearchTimeLimit;
  94. DWORD dwAuthMethod;
  95. LPTSTR lpszUserName;
  96. LPTSTR lpszPassword;
  97. LPTSTR lpszURL; // URL for server information
  98. LPTSTR lpszLogoPath; // path to the logo bitmap for this server
  99. BOOL fResolve; // Resolve against this server if TRUE
  100. LPTSTR lpszBase; // Search Base
  101. LPTSTR lpszName; // Actual server name or IP address
  102. DWORD dwID; // Unique server ID (order specifier)
  103. DWORD dwPort; // Port to connect to - 389 is default but this could be different
  104. DWORD dwUseBindDN;
  105. DWORD dwUseSSL;
  106. DWORD dwPagedResult;
  107. LPTSTR lpszAdvancedSearchAttr; // List of searchable attributes for advanced searching
  108. DWORD dwIsNTDS; // used to determine if this is an NTDS or not ..
  109. IF_WIN32(BOOL fSimpleSearch;) // If specified, we use a very very simple filter ...
  110. IF_WIN16(DWORD fSimpleSearch;) // BOOL is defined as DWORD
  111. // in WIN32 while it is UINT in WIN16.
  112. } LDAPSERVERPARAMS, FAR* LPLDAPSERVERPARAMS;
  113. BOOL fUseSynchronousSearch;
  114. #define LSP_ShowAnim 0x00000001
  115. #define LSP_ResolveMultiple 0x00000002
  116. #define LSP_UseSynchronousBind 0x00000004
  117. #define LSP_InitDll 0x00000008
  118. #define LSP_AbandonSearch 0x00000010
  119. #define LSP_SimpleSearch 0x00000020
  120. #define LSP_UseSynchronousSearch 0x00000040
  121. #define LSP_PagedResults 0x00000080
  122. #define LSP_NoPagedResults 0x00000100
  123. #define LSP_IsNTDS 0x00000200
  124. #define LSP_IsNotNTDS 0x00000400
  125. // structure to pass data back from IDD_DIALOG_LDAPCANCEL handler
  126. typedef struct _LDAPSEARCHPARAMS
  127. {
  128. ULONG ulTimeout;
  129. ULONG ulTimeElapsed;
  130. ULONG ulMsgID;
  131. ULONG ulResult;
  132. ULONG ulError;
  133. LDAP** ppLDAP;
  134. LPTSTR szBase;
  135. ULONG ulScope;
  136. LPTSTR szFilter;
  137. LPTSTR szNTFilter;
  138. LPTSTR* ppszAttrs;
  139. ULONG ulAttrsonly;
  140. LDAPMessage** lplpResult;
  141. LPTSTR lpszServer;
  142. ULONG ulEntryIndex;
  143. UINT unTimerID;
  144. LPADRLIST lpAdrList;
  145. LPFlagList lpFlagList;
  146. HWND hDlgCancel;
  147. ULONG ulFlags;
  148. ULONG ulLDAPValue;
  149. LPTSTR lpszBindDN;
  150. DWORD dwAuthType;
  151. struct berval * pCookie;
  152. BOOL bUnicode;
  153. } LDAPSEARCHPARAMS, * PLDAPSEARCHPARAMS;
  154. typedef struct _SERVER_NAME {
  155. LPTSTR lpszName;
  156. DWORD dwOrder;
  157. /*UNALIGNED */struct _SERVER_NAME * lpNext;
  158. } SERVER_NAME, *LPSERVER_NAME;
  159. // Creates an LDAP URL by deconstructing the LDAP entryid and using information from
  160. // it to fill in gaps in the URL
  161. void CreateLDAPURLFromEntryID(ULONG cbEntryID, LPENTRYID lpEntryID, LPTSTR * lppBuf, BOOL * lpbIsNTDSEntry);
  162. // LDAP function typedefs
  163. // ldap_open
  164. typedef LDAP* (__cdecl LDAPOPEN)( LPTSTR HostName, ULONG PortNumber );
  165. typedef LDAPOPEN FAR *LPLDAPOPEN;
  166. //ldap_connect
  167. typedef ULONG (__cdecl LDAPCONNECT)( LDAP *ld, LDAP_TIMEVAL *timeout);
  168. typedef LDAPCONNECT FAR *LPLDAPCONNECT;
  169. //ldap_init
  170. typedef LDAP* (__cdecl LDAPINIT)( LPTSTR HostName, ULONG PortNumber );
  171. typedef LDAPINIT FAR *LPLDAPINIT;
  172. // ldap_sslinit
  173. typedef LDAP* (__cdecl LDAPSSLINIT)( LPTSTR HostName, ULONG PortNumber , int Secure);
  174. typedef LDAPSSLINIT FAR *LPLDAPSSLINIT;
  175. // ldap_set_option
  176. typedef ULONG (__cdecl LDAPSETOPTION)( LDAP *ld, int option, void *invalue );
  177. typedef LDAPSETOPTION FAR *LPLDAPSETOPTION;
  178. // ldap_bind_s
  179. typedef ULONG (__cdecl LDAPBINDS)(LDAP *ld, LPTSTR dn, LPTSTR cred, ULONG method);
  180. typedef LDAPBINDS FAR *LPLDAPBINDS;
  181. // ldap_bind
  182. typedef ULONG (__cdecl LDAPBIND)( LDAP *ld, LPTSTR dn, LPTSTR cred, ULONG method );
  183. typedef LDAPBIND FAR *LPLDAPBIND;
  184. //ldap_unbind
  185. typedef ULONG (__cdecl LDAPUNBIND)(LDAP* ld);
  186. typedef LDAPUNBIND FAR *LPLDAPUNBIND;
  187. // ldap_search
  188. typedef ULONG (__cdecl LDAPSEARCH)(
  189. LDAP *ld,
  190. LPTSTR base,
  191. ULONG scope,
  192. LPTSTR filter,
  193. LPTSTR attrs[],
  194. ULONG attrsonly
  195. );
  196. typedef LDAPSEARCH FAR *LPLDAPSEARCH;
  197. // ldap_search_s
  198. typedef ULONG (__cdecl LDAPSEARCHS)(
  199. LDAP *ld,
  200. LPTSTR base,
  201. ULONG scope,
  202. LPTSTR filter,
  203. LPTSTR attrs[],
  204. ULONG attrsonly,
  205. LDAPMessage **res
  206. );
  207. typedef LDAPSEARCHS FAR *LPLDAPSEARCHS;
  208. // ldap_search_st
  209. typedef ULONG (__cdecl LDAPSEARCHST)(
  210. LDAP *ld,
  211. LPTSTR base,
  212. ULONG scope,
  213. LPTSTR filter,
  214. LPTSTR attrs[],
  215. ULONG attrsonly,
  216. struct l_timeval *timeout,
  217. LDAPMessage **res
  218. );
  219. typedef LDAPSEARCHST FAR *LPLDAPSEARCHST;
  220. // ldap_abandon
  221. typedef ULONG (__cdecl LDAPABANDON)( LDAP *ld, ULONG msgid );
  222. typedef LDAPABANDON FAR *LPLDAPABANDON;
  223. // ldap_result
  224. typedef ULONG (__cdecl LDAPRESULT)(
  225. LDAP *ld,
  226. ULONG msgid,
  227. ULONG all,
  228. struct l_timeval *timeout,
  229. LDAPMessage **res
  230. );
  231. typedef LDAPRESULT FAR *LPLDAPRESULT;
  232. // ldap_result2error
  233. typedef ULONG (__cdecl LDAPRESULT2ERROR)(
  234. LDAP *ld,
  235. LDAPMessage *res,
  236. ULONG freeit // boolean.. free the message?
  237. );
  238. typedef LDAPRESULT2ERROR FAR *LPLDAPRESULT2ERROR;
  239. // ldap_msgfree
  240. typedef ULONG (__cdecl LDAPMSGFREE)(LDAPMessage *res);
  241. typedef LDAPMSGFREE FAR *LPLDAPMSGFREE;
  242. // ldap_first_entry
  243. typedef LDAPMessage* (__cdecl LDAPFIRSTENTRY)(LDAP *ld, LDAPMessage *res);
  244. typedef LDAPFIRSTENTRY FAR *LPLDAPFIRSTENTRY;
  245. // ldap_next_entry
  246. typedef LDAPMessage* (__cdecl LDAPNEXTENTRY)(LDAP *ld, LDAPMessage *entry);
  247. typedef LDAPNEXTENTRY FAR *LPLDAPNEXTENTRY;
  248. // ldap_count_entries
  249. typedef ULONG (__cdecl LDAPCOUNTENTRIES)(LDAP *ld, LDAPMessage *res);
  250. typedef LDAPCOUNTENTRIES FAR *LPLDAPCOUNTENTRIES;
  251. // ldap_first_attribute
  252. typedef LPTSTR (__cdecl LDAPFIRSTATTR)(
  253. LDAP *ld,
  254. LDAPMessage *entry,
  255. BerElement **ptr
  256. );
  257. typedef LDAPFIRSTATTR FAR *LPLDAPFIRSTATTR;
  258. // ldap_next_attribute
  259. typedef LPTSTR (__cdecl LDAPNEXTATTR)(
  260. LDAP *ld,
  261. LDAPMessage *entry,
  262. BerElement *ptr
  263. );
  264. typedef LDAPNEXTATTR FAR *LPLDAPNEXTATTR;
  265. // ldap_get_values
  266. typedef LPTSTR* (__cdecl LDAPGETVALUES)(
  267. LDAP *ld,
  268. LDAPMessage *entry,
  269. LPTSTR attr
  270. );
  271. typedef LDAPGETVALUES FAR *LPLDAPGETVALUES;
  272. // ldap_get_values_len
  273. typedef struct berval** (__cdecl LDAPGETVALUESLEN)(
  274. LDAP *ExternalHandle,
  275. LDAPMessage *Message,
  276. LPTSTR attr
  277. );
  278. typedef LDAPGETVALUESLEN FAR *LPLDAPGETVALUESLEN;
  279. // ldap_count_values
  280. typedef ULONG (__cdecl LDAPCOUNTVALUES)(LPTSTR *vals);
  281. typedef LDAPCOUNTVALUES FAR *LPLDAPCOUNTVALUES;
  282. // ldap_count_values_len
  283. typedef ULONG (__cdecl LDAPCOUNTVALUESLEN)(struct berval **vals);
  284. typedef LDAPCOUNTVALUESLEN FAR *LPLDAPCOUNTVALUESLEN;
  285. // ldap_value_free
  286. typedef ULONG (__cdecl LDAPVALUEFREE)(LPTSTR *vals);
  287. typedef LDAPVALUEFREE FAR *LPLDAPVALUEFREE;
  288. // ldap_value_free_len
  289. typedef ULONG (__cdecl LDAPVALUEFREELEN)(struct berval **vals);
  290. typedef LDAPVALUEFREELEN FAR *LPLDAPVALUEFREELEN;
  291. // ldap_get_dn
  292. typedef LPTSTR (__cdecl LDAPGETDN)(LDAP *ld, LDAPMessage *entry);
  293. typedef LDAPGETDN FAR *LPLDAPGETDN;
  294. // ldap_memfree
  295. typedef VOID (__cdecl LDAPMEMFREE)(LPTSTR Block);
  296. typedef LDAPMEMFREE FAR *LPLDAPMEMFREE;
  297. // ldap_err2string
  298. typedef LPTSTR (__cdecl LDAPERR2STRING)(ULONG err);
  299. typedef LDAPERR2STRING FAR *LPLDAPERR2STRING;
  300. //ldap_create_page_control
  301. typedef ULONG (__cdecl LDAPCREATEPAGECONTROL)(
  302. LDAP * pExternalHandle,
  303. ULONG PageSize,
  304. struct berval *Cookie,
  305. UCHAR IsCritical,
  306. PLDAPControlA *Control);
  307. typedef LDAPCREATEPAGECONTROL FAR *LPLDAPCREATEPAGECONTROL;
  308. //ldap_search_ext_s
  309. typedef ULONG (__cdecl LDAPSEARCHEXT_S)(
  310. LDAP *ld,
  311. LPTSTR base,
  312. ULONG scope,
  313. LPTSTR filter,
  314. LPTSTR attrs[],
  315. ULONG attrsonly,
  316. PLDAPControlA *ServerControls,
  317. PLDAPControlA *ClientControls,
  318. struct l_timeval *timeout,
  319. ULONG SizeLimit,
  320. LDAPMessage **res);
  321. typedef LDAPSEARCHEXT_S FAR * LPLDAPSEARCHEXT_S;
  322. typedef ULONG (__cdecl LDAPSEARCHEXT)(
  323. LDAP *ld,
  324. LPTSTR base,
  325. ULONG scope,
  326. LPTSTR filter,
  327. LPTSTR attrs[],
  328. ULONG attrsonly,
  329. PLDAPControlA *ServerControls,
  330. PLDAPControlA *ClientControls,
  331. ULONG TimeLimit,
  332. ULONG SizeLimit,
  333. ULONG *MessageNumber);
  334. typedef LDAPSEARCHEXT FAR * LPLDAPSEARCHEXT;
  335. //ldap_parse_result
  336. typedef ULONG (__cdecl LDAPPARSERESULT)(
  337. LDAP *Connection,
  338. LDAPMessage *ResultMessage,
  339. ULONG *ReturnCode OPTIONAL,
  340. PWCHAR *MatchedDNs OPTIONAL,
  341. PWCHAR *ErrorMessage OPTIONAL,
  342. PWCHAR **Referrals OPTIONAL,
  343. PLDAPControl **ServerControls OPTIONAL,
  344. BOOLEAN Freeit);
  345. typedef LDAPPARSERESULT FAR *LPLDAPPARSERESULT;
  346. //ldap_parse_page_control
  347. typedef ULONG (__cdecl LDAPPARSEPAGECONTROL)(
  348. PLDAP ExternalHandle,
  349. PLDAPControlA *ServerControls,
  350. ULONG *TotalCount,
  351. struct berval **Cookie // Use ber_bvfree to free
  352. );
  353. typedef LDAPPARSEPAGECONTROL FAR * LPLDAPPARSEPAGECONTROL;
  354. typedef ULONG (__cdecl LDAPCONTROLFREE)(
  355. LDAPControl *Control);
  356. typedef LDAPCONTROLFREE FAR * LPLDAPCONTROLFREE;
  357. typedef ULONG (__cdecl LDAPCONTROLSFREE)(
  358. LDAPControl **Control);
  359. typedef LDAPCONTROLSFREE FAR * LPLDAPCONTROLSFREE;
  360. // Public functions in ldapcont.c
  361. BOOL InitLDAPClientLib(void);
  362. ULONG DeinitLDAPClientLib(void);
  363. HRESULT LDAPResolveName(LPADRBOOK lpAddrBook,
  364. LPADRLIST lpAdrList,
  365. LPFlagList lpFlagList,
  366. LPAMBIGUOUS_TABLES lpAmbiguousTables,
  367. ULONG ulFlags);
  368. HRESULT LDAP_OpenMAILUSER(LPIAB lpIAB,
  369. ULONG cbEntryID,
  370. LPENTRYID lpEntryID,
  371. LPCIID lpInterface,
  372. ULONG ulFlags,
  373. ULONG * lpulObjType,
  374. LPUNKNOWN * lppUnk);
  375. BOOL GetLDAPServerParams(LPTSTR lpszServer, LPLDAPSERVERPARAMS lspParams);
  376. HRESULT SetLDAPServerParams(LPTSTR lpszServer, LPLDAPSERVERPARAMS lspParams);
  377. void FreeLDAPServerParams(LDAPSERVERPARAMS Params);
  378. DWORD GetLDAPNextServerID(DWORD dwSet);
  379. BOOL GetApiProcAddresses(HMODULE hModDLL,APIFCN * pApiProcList,UINT nApiProcs);
  380. void UninitAccountManager(void);
  381. HRESULT InitAccountManager(LPIAB lpIAB, IImnAccountManager2 ** lppAccountManager, GUID * pguidUser);
  382. HRESULT AddToServerList(UNALIGNED LPSERVER_NAME * lppServerNames, LPTSTR szBuf, DWORD dwOrder);
  383. HRESULT EnumerateLDAPtoServerList(IImnAccountManager2 * lpAccountManager,
  384. LPSERVER_NAME * lppServerNames, LPULONG lpcServers);
  385. extern const LPTSTR szAllLDAPServersValueName;