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.

236 lines
5.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows NT Security
  4. // Copyright (C) Microsoft Corporation, 1997 - 1999
  5. //
  6. // File: ldapsp.h
  7. //
  8. // Contents: LDAP Scheme Provider definitions
  9. //
  10. // History: 28-Jul-97 kirtd Created
  11. // 01-Jan-02 philh Changed to internally use UNICODE Urls
  12. //
  13. //----------------------------------------------------------------------------
  14. #if !defined(__LDAPSP_H__)
  15. #define __LDAPSP_H__
  16. #include <orm.h>
  17. #include <winldap.h>
  18. #include <dsgetdc.h>
  19. //
  20. // The minimum time to allow for LDAP timeouts
  21. //
  22. #define LDAP_MIN_TIMEOUT_SECONDS 10
  23. //
  24. // LDAP Scheme Provider Entry Points
  25. //
  26. #define LDAP_SCHEME "ldap"
  27. BOOL WINAPI LdapRetrieveEncodedObject (
  28. IN LPCWSTR pwszUrl,
  29. IN LPCSTR pszObjectOid,
  30. IN DWORD dwRetrievalFlags,
  31. IN DWORD dwTimeout,
  32. OUT PCRYPT_BLOB_ARRAY pObject,
  33. OUT PFN_FREE_ENCODED_OBJECT_FUNC* ppfnFreeObject,
  34. OUT LPVOID* ppvFreeContext,
  35. IN HCRYPTASYNC hAsyncRetrieve,
  36. IN PCRYPT_CREDENTIALS pCredentials,
  37. IN PCRYPT_RETRIEVE_AUX_INFO pAuxInfo
  38. );
  39. VOID WINAPI LdapFreeEncodedObject (
  40. IN LPCSTR pszObjectOid,
  41. IN PCRYPT_BLOB_ARRAY pObject,
  42. IN LPVOID pvFreeContext
  43. );
  44. BOOL WINAPI LdapCancelAsyncRetrieval (
  45. IN HCRYPTASYNC hAsyncRetrieve
  46. );
  47. //
  48. // LDAP Scheme Provider Notes. The LDAP API model has synchronous with
  49. // timeout and asynchronous via polling mechanisms.
  50. //
  51. //
  52. // LDAP Synchronous Object Retriever
  53. //
  54. class CLdapSynchronousRetriever : public IObjectRetriever
  55. {
  56. public:
  57. //
  58. // Construction
  59. //
  60. CLdapSynchronousRetriever ();
  61. ~CLdapSynchronousRetriever ();
  62. //
  63. // IRefCountedObject methods
  64. //
  65. virtual VOID AddRef ();
  66. virtual VOID Release ();
  67. //
  68. // IObjectRetriever methods
  69. //
  70. virtual BOOL RetrieveObjectByUrl (
  71. LPCWSTR pwszUrl,
  72. LPCSTR pszObjectOid,
  73. DWORD dwRetrievalFlags,
  74. DWORD dwTimeout,
  75. LPVOID* ppvObject,
  76. PFN_FREE_ENCODED_OBJECT_FUNC* ppfnFreeObject,
  77. LPVOID* ppvFreeContext,
  78. HCRYPTASYNC hAsyncRetrieve,
  79. PCRYPT_CREDENTIALS pCredentials,
  80. LPVOID pvVerify,
  81. PCRYPT_RETRIEVE_AUX_INFO pAuxInfo
  82. );
  83. virtual BOOL CancelAsyncRetrieval ();
  84. private:
  85. //
  86. // Reference count
  87. //
  88. ULONG m_cRefs;
  89. };
  90. //
  91. // LDAP Scheme Provider Support API
  92. //
  93. typedef struct _LDAP_URL_COMPONENTS {
  94. LPWSTR pwszHost;
  95. ULONG Port;
  96. LPWSTR pwszDN;
  97. ULONG cAttr;
  98. LPWSTR* apwszAttr;
  99. ULONG Scope;
  100. LPWSTR pwszFilter;
  101. } LDAP_URL_COMPONENTS, *PLDAP_URL_COMPONENTS;
  102. BOOL
  103. LdapCrackUrl (
  104. LPCWSTR pwszUrl,
  105. PLDAP_URL_COMPONENTS pLdapUrlComponents
  106. );
  107. BOOL
  108. LdapParseCrackedHost (
  109. LPWSTR pwszHost,
  110. PLDAP_URL_COMPONENTS pLdapUrlComponents
  111. );
  112. BOOL
  113. LdapParseCrackedDN (
  114. LPWSTR pwszDN,
  115. PLDAP_URL_COMPONENTS pLdapUrlComponents
  116. );
  117. BOOL
  118. LdapParseCrackedAttributeList (
  119. LPWSTR pwszAttrList,
  120. PLDAP_URL_COMPONENTS pLdapUrlComponents
  121. );
  122. BOOL
  123. LdapParseCrackedScopeAndFilter (
  124. LPWSTR pwszScope,
  125. LPWSTR pwszFilter,
  126. PLDAP_URL_COMPONENTS pLdapUrlComponents
  127. );
  128. VOID
  129. LdapFreeUrlComponents (
  130. PLDAP_URL_COMPONENTS pLdapUrlComponents
  131. );
  132. VOID
  133. LdapDisplayUrlComponents (
  134. PLDAP_URL_COMPONENTS pLdapUrlComponents
  135. );
  136. #define LDAP_BIND_AUTH_SSPI_ENABLE_FLAG 0x1
  137. #define LDAP_BIND_AUTH_SIMPLE_ENABLE_FLAG 0x2
  138. BOOL
  139. LdapGetBindings (
  140. LPWSTR pwszHost,
  141. ULONG Port,
  142. DWORD dwRetrievalFlags,
  143. DWORD dwBindFlags,
  144. DWORD dwTimeout,
  145. PCRYPT_CREDENTIALS pCredentials,
  146. LDAP** ppld
  147. );
  148. VOID
  149. LdapFreeBindings (
  150. LDAP* pld
  151. );
  152. BOOL
  153. LdapSendReceiveUrlRequest (
  154. LDAP* pld,
  155. PLDAP_URL_COMPONENTS pLdapUrlComponents,
  156. DWORD dwRetrievalFlags,
  157. DWORD dwTimeout,
  158. PCRYPT_BLOB_ARRAY pcba,
  159. PCRYPT_RETRIEVE_AUX_INFO pAuxInfo
  160. );
  161. BOOL
  162. LdapConvertLdapResultMessage (
  163. LDAP* pld,
  164. PLDAPMessage plm,
  165. DWORD dwRetrievalFlags,
  166. PCRYPT_BLOB_ARRAY pcba,
  167. PCRYPT_RETRIEVE_AUX_INFO pAuxInfo
  168. );
  169. VOID
  170. LdapFreeCryptBlobArray (
  171. PCRYPT_BLOB_ARRAY pcba
  172. );
  173. BOOL
  174. LdapHasWriteAccess (
  175. LDAP* pld,
  176. PLDAP_URL_COMPONENTS pLdapUrlComponents,
  177. DWORD dwTimeout
  178. );
  179. BOOL
  180. LdapSSPIOrSimpleBind (
  181. LDAP* pld,
  182. SEC_WINNT_AUTH_IDENTITY_W* pAuthIdentity,
  183. DWORD dwRetrievalFlags,
  184. DWORD dwBindFlags
  185. );
  186. ULONG
  187. I_CryptNetLdapMapErrorToWin32(
  188. LDAP* pld,
  189. ULONG LdapError
  190. );
  191. #endif