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.

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