Source code of Windows XP (NT5)
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.

298 lines
7.7 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1999
  5. //
  6. // File: csldap.h
  7. //
  8. // Contents: Cert Server wrapper routines
  9. //
  10. //---------------------------------------------------------------------------
  11. #ifndef __CSLDAP_H__
  12. #define __CSLDAP_H__
  13. #define csecLDAPTIMEOUT (2 * 60) // two minute default search timeout
  14. #define wszDSBASECRLATTRIBUTE L"certificateRevocationList"
  15. #define wszDSDELTACRLATTRIBUTE L"deltaRevocationList"
  16. #define wszDSUSERCERTATTRIBUTE L"userCertificate"
  17. #define wszDSCROSSCERTPAIRATTRIBUTE L"crossCertificatePair"
  18. #define wszDSKRACERTATTRIBUTE wszDSUSERCERTATTRIBUTE
  19. #define wszDSCACERTATTRIBUTE L"cACertificate"
  20. #define wszDSBASECRLATTRIBUTE L"certificateRevocationList"
  21. #define wszDSAUTHORITYCRLATTRIBUTE L"authorityRevocationList"
  22. #define wszDSOBJECTCLASSATTRIBUTE L"objectClass"
  23. #define wszDSFLAGSATTRIBUTE L"flags"
  24. #define wszDSBASESEARCH L"?base"
  25. #define wszDSONESEARCH L"?one"
  26. #define wszDSTOPCLASSNAME L"top"
  27. #define wszDSPERSONCLASSNAME L"person"
  28. #define wszDSORGPERSONCLASSNAME L"organizationalPerson"
  29. #define wszDSUSERCLASSNAME L"user"
  30. #define wszDSCONTAINERCLASSNAME L"container"
  31. #define wszDSENROLLMENTSERVICECLASSNAME L"pKIEnrollmentService"
  32. #define wszDSMACHINECLASSNAME L"machine"
  33. #define wszDSTEMPLATELASSNAME L"pKICertificateTemplate"
  34. #define wszDSKRACLASSNAME L"msPKI-PrivateKeyRecoveryAgent"
  35. #define wszDSCDPCLASSNAME L"cRLDistributionPoint"
  36. #define wszDSOIDCLASSNAME L"msPKI-Enterprise-Oid"
  37. #define wszDSCACLASSNAME L"certificationAuthority"
  38. #define wszDSAIACLASSNAME wszDSCACLASSNAME
  39. #define wszDSCDPCLASS L"?" wszDSOBJECTCLASSATTRIBUTE L"=" wszDSCDPCLASSNAME
  40. #define wszDSCACLASS L"?" wszDSOBJECTCLASSATTRIBUTE L"=" wszDSCACLASSNAME
  41. #define wszDSUSERCLASS L"?" wszDSOBJECTCLASSATTRIBUTE L"=*"
  42. #define wszDSKRACLASS L"?" wszDSOBJECTCLASSATTRIBUTE L"=" wszDSKRACLASSNAME
  43. #define wszDSAIACLASS L"?" wszDSOBJECTCLASSATTRIBUTE L"=" wszDSAIACLASSNAME
  44. #define wszDSSEARCHBASECRLATTRIBUTE \
  45. L"?" \
  46. wszDSBASECRLATTRIBUTE \
  47. wszDSBASESEARCH \
  48. wszDSCDPCLASS
  49. #define wszDSSEARCHDELTACRLATTRIBUTE \
  50. L"?" \
  51. wszDSDELTACRLATTRIBUTE \
  52. wszDSBASESEARCH \
  53. wszDSCDPCLASS
  54. #define wszDSSEARCHUSERCERTATTRIBUTE \
  55. L"?" \
  56. wszDSUSERCERTATTRIBUTE \
  57. wszDSBASESEARCH \
  58. wszDSUSERCLASS
  59. #define wszDSSEARCHCACERTATTRIBUTE \
  60. L"?" \
  61. wszDSCACERTATTRIBUTE \
  62. wszDSBASESEARCH \
  63. wszDSCACLASS
  64. #define wszDSSEARCHKRACERTATTRIBUTE \
  65. L"?" \
  66. wszDSUSERCERTATTRIBUTE \
  67. wszDSONESEARCH \
  68. wszDSKRACLASS
  69. #define wszDSSEARCHCROSSCERTPAIRATTRIBUTE \
  70. L"?" \
  71. wszDSCROSSCERTPAIRATTRIBUTE \
  72. wszDSONESEARCH \
  73. wszDSAIACLASS
  74. #define wszDSSEARCHAIACERTATTRIBUTE \
  75. L"?" \
  76. wszDSCACERTATTRIBUTE \
  77. wszDSONESEARCH \
  78. wszDSAIACLASS
  79. #define wszDSKRAQUERYTEMPLATE \
  80. L"ldap:///CN=KRA," \
  81. L"CN=Public Key Services," \
  82. L"CN=Services," \
  83. wszFCSAPARM_CONFIGDN \
  84. wszDSSEARCHKRACERTATTRIBUTE
  85. #define wszDSAIAQUERYTEMPLATE \
  86. L"ldap:///CN=AIA," \
  87. L"CN=Public Key Services," \
  88. L"CN=Services," \
  89. wszFCSAPARM_CONFIGDN \
  90. wszDSSEARCHAIACERTATTRIBUTE
  91. // Default URL Template Values:
  92. extern WCHAR const g_wszzLDAPIssuerCertURLTemplate[];
  93. extern WCHAR const g_wszzLDAPKRACertURLTemplate[];
  94. extern WCHAR const g_wszzLDAPRevocationURLTemplate[];
  95. extern WCHAR const g_wszASPRevocationURLTemplate[];
  96. extern WCHAR const g_wszLDAPNTAuthURLTemplate[];
  97. extern WCHAR const g_wszLDAPRootTrustURLTemplate[];
  98. extern WCHAR const g_wszCDPDNTemplate[];
  99. extern WCHAR const g_wszAIADNTemplate[];
  100. extern WCHAR const g_wszKRADNTemplate[];
  101. extern WCHAR const g_wszHTTPRevocationURLTemplate[];
  102. extern WCHAR const g_wszFILERevocationURLTemplate[];
  103. extern WCHAR const g_wszHTTPIssuerCertURLTemplate[];
  104. extern WCHAR const g_wszFILEIssuerCertURLTemplate[];
  105. // Default Server Controls:
  106. extern LDAPControl *g_rgLdapControls[];
  107. HRESULT
  108. myGetAuthoritativeDomainDn(
  109. IN LDAP *pld,
  110. OPTIONAL OUT BSTR *pstrDomainDN,
  111. OPTIONAL OUT BSTR *pstrConfigDN);
  112. HRESULT
  113. myDomainFromDn(
  114. IN WCHAR const *pwszDN,
  115. OUT WCHAR **ppwszDomainDNS);
  116. HRESULT
  117. myLdapOpen(
  118. OUT LDAP **ppld,
  119. OPTIONAL OUT BSTR *pstrDomainDN,
  120. OPTIONAL OUT BSTR *pstrConfigDN);
  121. VOID
  122. myLdapClose(
  123. OPTIONAL IN LDAP *pld,
  124. OPTIONAL IN BSTR strDomainDN,
  125. OPTIONAL IN BSTR strConfigDN);
  126. BOOL
  127. myLdapRebindRequired(
  128. IN ULONG ldaperrParm,
  129. OPTIONAL IN LDAP *pld);
  130. HRESULT
  131. myLdapGetDSHostName(
  132. IN LDAP *pld,
  133. OUT WCHAR **ppwszHostName);
  134. HRESULT
  135. myLdapCreateContainer(
  136. IN LDAP *pld,
  137. IN WCHAR const *pwszDN,
  138. IN BOOL fSkipObject, // Does the DN contain a leaf object name
  139. IN DWORD cMaxLevel, // create this many nested containers as needed
  140. IN PSECURITY_DESCRIPTOR pContainerSD,
  141. OPTIONAL OUT WCHAR **ppwszError);
  142. #define LPC_CAOBJECT 0x00000000
  143. #define LPC_KRAOBJECT 0x00000001
  144. #define LPC_USEROBJECT 0x00000002
  145. #define LPC_MACHINEOBJECT 0x00000003
  146. #define LPC_OBJECTMASK 0x0000000f
  147. #define LPC_CREATECONTAINER 0x00000100
  148. #define LPC_CREATEOBJECT 0x00000200
  149. HRESULT
  150. myLdapPublishCertToDS(
  151. IN LDAP *pld,
  152. IN CERT_CONTEXT const *pccPublish,
  153. IN WCHAR const *pwszURL,
  154. IN WCHAR const *pwszAttribute,
  155. IN DWORD dwObjectType, // LPC_*
  156. OUT DWORD *pdwDisposition,
  157. OPTIONAL OUT WCHAR **ppwszError);
  158. HRESULT
  159. myLdapPublishCRLToDS(
  160. IN LDAP *pld,
  161. IN CRL_CONTEXT const *pCRLPublish,
  162. IN WCHAR const *pwszURL,
  163. IN WCHAR const *pwszAttribute,
  164. OUT DWORD *pdwDisposition,
  165. OPTIONAL OUT WCHAR **ppwszError);
  166. HRESULT
  167. myLdapCreateCAObject(
  168. IN LDAP *pld,
  169. IN WCHAR const *pwszDN,
  170. OPTIONAL IN BYTE const *pbCert,
  171. IN DWORD cbCert,
  172. IN PSECURITY_DESCRIPTOR pSD,
  173. OUT DWORD *pdwDisposition,
  174. OPTIONAL OUT WCHAR **ppwszError);
  175. HRESULT
  176. myLdapCreateCDPObject(
  177. IN LDAP *pld,
  178. IN WCHAR const *pwszDN,
  179. IN PSECURITY_DESCRIPTOR pSD,
  180. OUT DWORD *pdwDisposition,
  181. OPTIONAL OUT WCHAR **ppwszError);
  182. HRESULT
  183. myLdapCreateUserObject(
  184. IN LDAP *pld,
  185. IN WCHAR const *pwszDN,
  186. OPTIONAL IN BYTE const *pbCert,
  187. IN DWORD cbCert,
  188. IN PSECURITY_DESCRIPTOR pSD,
  189. IN DWORD dwObjectType, // LPC_* (but LPC_CREATE* is ignored)
  190. OUT DWORD *pdwDisposition,
  191. OPTIONAL OUT WCHAR **ppwszError);
  192. HRESULT
  193. myLdapCreateOIDObject(
  194. IN LDAP *pld,
  195. IN WCHAR const *pwszDN,
  196. IN DWORD dwType,
  197. IN WCHAR const *pwszObjId,
  198. OUT DWORD *pdwDisposition,
  199. OPTIONAL OUT WCHAR **ppwszError);
  200. HRESULT
  201. myLdapOIDIsMatchingLangId(
  202. IN WCHAR const *pwszDisplayName,
  203. IN DWORD dwLanguageId,
  204. OUT BOOL *pfLangIdExists);
  205. HRESULT
  206. myLdapAddOIDDisplayNameToAttribute(
  207. IN LDAP *pld,
  208. OPTIONAL IN WCHAR **ppwszDisplayNames,
  209. IN DWORD dwLanguageId,
  210. IN WCHAR const *pwszDisplayName,
  211. IN WCHAR const *pwszDN,
  212. IN WCHAR const *pwszAttribute,
  213. OUT DWORD *pdwDisposition,
  214. OPTIONAL OUT WCHAR **ppwszError);
  215. HRESULT
  216. myHLdapError(
  217. OPTIONAL IN LDAP *pld,
  218. IN ULONG ldaperrParm,
  219. OPTIONAL OUT WCHAR **ppwszError);
  220. HRESULT
  221. myHLdapError2(
  222. OPTIONAL IN LDAP *pld,
  223. IN ULONG ldaperrParm,
  224. IN ULONG ldaperrParmQuiet,
  225. OPTIONAL OUT WCHAR **ppwszError);
  226. HRESULT
  227. myHLdapError3(
  228. OPTIONAL IN LDAP *pld,
  229. IN ULONG ldaperrParm,
  230. IN ULONG ldaperrParmQuiet,
  231. IN ULONG ldaperrParmQuiet2,
  232. OPTIONAL OUT WCHAR **ppwszError);
  233. HRESULT
  234. myHLdapLastError(
  235. OPTIONAL IN LDAP *pld,
  236. OPTIONAL OUT WCHAR **ppwszError);
  237. HRESULT
  238. AddCertToAttribute(
  239. IN LDAP *pld,
  240. IN CERT_CONTEXT const *pccPublish,
  241. IN WCHAR const *pwszDN,
  242. IN WCHAR const *pwszAttribute,
  243. OUT DWORD *pdwDisposition,
  244. OPTIONAL OUT WCHAR **ppwszError);
  245. HRESULT myLDAPSetStringAttribute(
  246. IN LDAP *pld,
  247. IN WCHAR const *pwszDN,
  248. IN WCHAR const *pwszAttribute,
  249. IN WCHAR const *pwszValue,
  250. OUT DWORD *pdwDisposition,
  251. OPTIONAL OUT WCHAR **ppwszError);
  252. #endif // __CSLDAP_H__