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.

310 lines
7.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows NT Security
  4. // Copyright (C) Microsoft Corporation, 1997 - 1999
  5. //
  6. // File: ldapstor.h
  7. //
  8. // Contents: LDAP Certificate Store Provider definitions
  9. //
  10. // History: 16-Oct-97 kirtd Created
  11. // 01-Jan-02 philh Changed to internally use UNICODE Urls
  12. //
  13. //----------------------------------------------------------------------------
  14. #if !defined(__LDAPSTOR_H__)
  15. #define __LDAPSTOR_H__
  16. #include <ldapsp.h>
  17. #define SECURITY_WIN32
  18. #include <security.h>
  19. //
  20. // Store provider open store function name
  21. //
  22. #define LDAP_OPEN_STORE_PROV_FUNC "LdapProvOpenStore"
  23. //
  24. // BERVAL array definitions
  25. //
  26. #define MIN_BERVAL 10
  27. #define GROW_BERVAL 50
  28. //
  29. // User DS Store URL format
  30. //
  31. #define USER_DS_STORE_URL_PREFIX L"ldap:///"
  32. #define USER_DS_STORE_URL_SEPARATOR L"?"
  33. //
  34. // Store timeout (15 seconds)
  35. //
  36. #define LDAP_STORE_TIMEOUT 15000
  37. //
  38. // GetUserNameExA function pointer prototype
  39. //
  40. typedef BOOLEAN (SEC_ENTRY *PFN_GETUSERNAMEEXW) (
  41. EXTENDED_NAME_FORMAT NameFormat,
  42. LPWSTR lpNameBuffer,
  43. PULONG nSize
  44. );
  45. //
  46. // CLdapStore. This class implements all callbacks for the Ldap Store
  47. // provider. A pointer to an instance of this class is used as the hStoreProv
  48. // parameter for the callback functions implemented
  49. //
  50. class CLdapStore
  51. {
  52. public:
  53. //
  54. // Construction
  55. //
  56. CLdapStore (
  57. OUT BOOL& rfResult
  58. );
  59. ~CLdapStore ();
  60. //
  61. // Store functions
  62. //
  63. BOOL OpenStore (
  64. LPCSTR pszStoreProv,
  65. DWORD dwMsgAndCertEncodingType,
  66. HCRYPTPROV hCryptProv,
  67. DWORD dwFlags,
  68. const void* pvPara,
  69. HCERTSTORE hCertStore,
  70. PCERT_STORE_PROV_INFO pStoreProvInfo
  71. );
  72. VOID CloseStore (DWORD dwFlags);
  73. BOOL DeleteCert (PCCERT_CONTEXT pCertContext, DWORD dwFlags);
  74. BOOL DeleteCrl (PCCRL_CONTEXT pCrlContext, DWORD dwFlags);
  75. BOOL DeleteCtl (PCCTL_CONTEXT pCtlContext, DWORD dwFlags);
  76. BOOL SetCertProperty (
  77. PCCERT_CONTEXT pCertContext,
  78. DWORD dwPropId,
  79. DWORD dwFlags,
  80. const void* pvPara
  81. );
  82. BOOL SetCrlProperty (
  83. PCCRL_CONTEXT pCertContext,
  84. DWORD dwPropId,
  85. DWORD dwFlags,
  86. const void* pvPara
  87. );
  88. BOOL SetCtlProperty (
  89. PCCTL_CONTEXT pCertContext,
  90. DWORD dwPropId,
  91. DWORD dwFlags,
  92. const void* pvPara
  93. );
  94. BOOL WriteCert (PCCERT_CONTEXT pCertContext, DWORD dwFlags);
  95. BOOL WriteCrl (PCCRL_CONTEXT pCertContext, DWORD dwFlags);
  96. BOOL WriteCtl (PCCTL_CONTEXT pCertContext, DWORD dwFlags);
  97. BOOL StoreControl (DWORD dwFlags, DWORD dwCtrlType, LPVOID pvCtrlPara);
  98. BOOL Commit (DWORD dwFlags);
  99. BOOL Resync ();
  100. private:
  101. //
  102. // Object lock
  103. //
  104. CRITICAL_SECTION m_StoreLock;
  105. //
  106. // LDAP URL
  107. //
  108. LDAP_URL_COMPONENTS m_UrlComponents;
  109. //
  110. // LDAP binding
  111. //
  112. LDAP* m_pBinding;
  113. //
  114. // Cache store reference
  115. //
  116. HCERTSTORE m_hCacheStore;
  117. //
  118. // Open Store flags
  119. //
  120. DWORD m_dwOpenFlags;
  121. //
  122. // Dirty flag
  123. //
  124. BOOL m_fDirty;
  125. //
  126. // Private methods
  127. //
  128. BOOL FillCacheStore (BOOL fClearCache);
  129. BOOL InternalCommit (DWORD dwFlags);
  130. BOOL WriteCheckSetDirtyWithLock (
  131. LPCSTR pszContextOid,
  132. LPVOID pvContext,
  133. DWORD dwFlags
  134. );
  135. };
  136. //
  137. // Ldap Store Provider functions
  138. //
  139. BOOL WINAPI LdapProvOpenStore (
  140. IN LPCSTR pszStoreProv,
  141. IN DWORD dwMsgAndCertEncodingType,
  142. IN HCRYPTPROV hCryptProv,
  143. IN DWORD dwFlags,
  144. IN const void* pvPara,
  145. IN HCERTSTORE hCertStore,
  146. IN OUT PCERT_STORE_PROV_INFO pStoreProvInfo
  147. );
  148. void WINAPI LdapProvCloseStore (
  149. IN HCERTSTOREPROV hStoreProv,
  150. IN DWORD dwFlags
  151. );
  152. BOOL WINAPI LdapProvDeleteCert (
  153. IN HCERTSTOREPROV hStoreProv,
  154. IN PCCERT_CONTEXT pCertContext,
  155. IN DWORD dwFlags
  156. );
  157. BOOL WINAPI LdapProvDeleteCrl (
  158. IN HCERTSTOREPROV hStoreProv,
  159. IN PCCRL_CONTEXT pCrlContext,
  160. IN DWORD dwFlags
  161. );
  162. BOOL WINAPI LdapProvDeleteCtl (
  163. IN HCERTSTOREPROV hStoreProv,
  164. IN PCCTL_CONTEXT pCtlContext,
  165. IN DWORD dwFlags
  166. );
  167. BOOL WINAPI LdapProvSetCertProperty (
  168. IN HCERTSTOREPROV hStoreProv,
  169. IN PCCERT_CONTEXT pCertContext,
  170. IN DWORD dwPropId,
  171. IN DWORD dwFlags,
  172. IN const void* pvData
  173. );
  174. BOOL WINAPI LdapProvSetCrlProperty (
  175. IN HCERTSTOREPROV hStoreProv,
  176. IN PCCRL_CONTEXT pCrlContext,
  177. IN DWORD dwPropId,
  178. IN DWORD dwFlags,
  179. IN const void* pvData
  180. );
  181. BOOL WINAPI LdapProvSetCtlProperty (
  182. IN HCERTSTOREPROV hStoreProv,
  183. IN PCCTL_CONTEXT pCtlContext,
  184. IN DWORD dwPropId,
  185. IN DWORD dwFlags,
  186. IN const void* pvData
  187. );
  188. BOOL WINAPI LdapProvWriteCert (
  189. IN HCERTSTOREPROV hStoreProv,
  190. IN PCCERT_CONTEXT pCertContext,
  191. IN DWORD dwFlags
  192. );
  193. BOOL WINAPI LdapProvWriteCrl (
  194. IN HCERTSTOREPROV hStoreProv,
  195. IN PCCRL_CONTEXT pCrlContext,
  196. IN DWORD dwFlags
  197. );
  198. BOOL WINAPI LdapProvWriteCtl (
  199. IN HCERTSTOREPROV hStoreProv,
  200. IN PCCTL_CONTEXT pCtlContext,
  201. IN DWORD dwFlags
  202. );
  203. BOOL WINAPI LdapProvStoreControl (
  204. IN HCERTSTOREPROV hStoreProv,
  205. IN DWORD dwFlags,
  206. IN DWORD dwCtrlType,
  207. IN LPVOID pvCtrlPara
  208. );
  209. //
  210. // Ldap Store Provider Function table
  211. //
  212. static void* const rgpvLdapProvFunc[] = {
  213. // CERT_STORE_PROV_CLOSE_FUNC 0
  214. LdapProvCloseStore,
  215. // CERT_STORE_PROV_READ_CERT_FUNC 1
  216. NULL,
  217. // CERT_STORE_PROV_WRITE_CERT_FUNC 2
  218. LdapProvWriteCert,
  219. // CERT_STORE_PROV_DELETE_CERT_FUNC 3
  220. LdapProvDeleteCert,
  221. // CERT_STORE_PROV_SET_CERT_PROPERTY_FUNC 4
  222. LdapProvSetCertProperty,
  223. // CERT_STORE_PROV_READ_CRL_FUNC 5
  224. NULL,
  225. // CERT_STORE_PROV_WRITE_CRL_FUNC 6
  226. LdapProvWriteCrl,
  227. // CERT_STORE_PROV_DELETE_CRL_FUNC 7
  228. LdapProvDeleteCrl,
  229. // CERT_STORE_PROV_SET_CRL_PROPERTY_FUNC 8
  230. LdapProvSetCrlProperty,
  231. // CERT_STORE_PROV_READ_CTL_FUNC 9
  232. NULL,
  233. // CERT_STORE_PROV_WRITE_CTL_FUNC 10
  234. LdapProvWriteCtl,
  235. // CERT_STORE_PROV_DELETE_CTL_FUNC 11
  236. LdapProvDeleteCtl,
  237. // CERT_STORE_PROV_SET_CTL_PROPERTY_FUNC 12
  238. LdapProvSetCtlProperty,
  239. // CERT_STORE_PROV_CONTROL_FUNC 13
  240. LdapProvStoreControl
  241. };
  242. #define LDAP_PROV_FUNC_COUNT (sizeof(rgpvLdapProvFunc) / \
  243. sizeof(rgpvLdapProvFunc[0]))
  244. #endif