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.

282 lines
7.2 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. //
  4. // Microsoft Windows
  5. // Copyright (C) Microsoft Corporation, 1992 - 1995
  6. //
  7. // File: srchutil.hxx
  8. //
  9. // Contents: Microsoft ADs LDAP Provider search utility functions
  10. //
  11. //
  12. // History: 03-02-97 ShankSh Created.
  13. //
  14. //----------------------------------------------------------------------------
  15. #ifndef _SRCHUTIL_H_INCLUDED_
  16. #define _SRCHUTIL_H_INCLUDED_
  17. typedef struct _ldap_search_pref {
  18. BOOL _fAttrsOnly;
  19. BOOL _fAsynchronous;
  20. DWORD _dwSearchScope;
  21. DWORD _dwSizeLimit;
  22. DWORD _dwTimeLimit;
  23. DWORD _dwPagedTimeLimit;
  24. struct l_timeval _timeout;
  25. DWORD _dwPageSize;
  26. DWORD _dwDerefAliases;
  27. DWORD _dwChaseReferrals;
  28. PLDAPSortKey _pSortKeys;
  29. DWORD _nSortKeys;
  30. BOOL _fCacheResults;
  31. BOOL _fDirSync;
  32. PADS_PROV_SPECIFIC _pProvSpecific;
  33. BOOL _fTombStone;
  34. PLDAPVLVInfo _pVLVInfo; // VLV search
  35. LPWSTR _pAttribScoped; // attribute-scoped query
  36. BOOL _fSecurityDescriptorControl; // security descriptor retrieval
  37. SECURITY_INFORMATION _SecurityDescriptorMask; // ""
  38. DWORD _dwDirSyncFlag; // replication flag for the dirsync control
  39. BOOL _fExtendedDNControl; // extended dn control
  40. DWORD _dwExtendedDnOption; // extended dn control option
  41. }LDAP_SEARCH_PREF, *PLDAP_SEARCH_PREF;
  42. //
  43. // LDAP search structure; Contains all the information pertaining to the
  44. // current search
  45. //
  46. typedef struct _ldap_searchinfo {
  47. ADS_LDP *_pConnection;
  48. LPWSTR _pszADsPathContext;
  49. LPWSTR _pszLdapServer;
  50. LPWSTR _pszBindContextDn;
  51. LPWSTR _pszSearchFilter;
  52. LPWSTR *_ppszAttrs;
  53. LPWSTR _pszAttrNameBuffer;
  54. LDAPMessage **_pSearchResults;
  55. DWORD _cSearchResults;
  56. DWORD _dwCurrResult;
  57. DWORD _dwMaxResultGot;
  58. ULONG _currMsgId;
  59. LDAPMessage *_pCurrentRow;
  60. void *_pFirstAttr;
  61. LDAP_SEARCH_PREF _SearchPref;
  62. PLDAPSearch _hPagedSearch;
  63. DWORD _dwPort;
  64. PLDAPControl *_ServerControls;
  65. PLDAPControl *_ClientControls;
  66. HRESULT _hrLastSearch;
  67. BOOL _fAbandon;
  68. PBERVAL _pBerVal;
  69. DWORD _dwVLVOffset; // VirtualListViewResponse
  70. DWORD _dwVLVCount; // ""
  71. PBERVAL _pVLVContextID; // ""
  72. PBERVAL _pBerValAttribScoped; // attribute-scoped query control value
  73. PBERVAL _pBerValExtendedDN; // extended dn control value
  74. //
  75. // We use bitfields to store the booleans to try to cut down on the size
  76. // of this structure. Keep them together to permit the compiler to pack them
  77. // into the minimum space without added padding.
  78. //
  79. BOOL _fLastResult:1;
  80. BOOL _fLastPage:1;
  81. BOOL _fBefFirstRow:1;
  82. BOOL _fADsPathPresent:1;
  83. BOOL _fADsPathReturned:1;
  84. BOOL _fADsPathOnly:1; // TRUE = user requested only ADsPath attrib
  85. BOOL _fMoreDirSync:1;
  86. BOOL _fNonFatalErrors:1; // TRUE = non-fatal error occurred, need to warn
  87. BOOL _fDNPresent:1; // TRUE = dirsync control specified and user wants distinguishedName
  88. BOOL _fDNReturned:1; // TRUE = distringuished already returned
  89. }LDAP_SEARCHINFO, *PLDAP_SEARCHINFO;
  90. HRESULT
  91. ADsSetSearchPreference(
  92. IN PADS_SEARCHPREF_INFO pSearchPrefs,
  93. IN DWORD dwNumPrefs,
  94. OUT LDAP_SEARCH_PREF * pLdapPref,
  95. IN LPWSTR pszLDAPServer,
  96. IN LPWSTR pszLDAPDn,
  97. IN CCredentials& Credentials,
  98. IN DWORD dwPort
  99. );
  100. HRESULT
  101. ADsExecuteSearch(
  102. IN LDAP_SEARCH_PREF LdapPref,
  103. IN LPWSTR pszADsPath,
  104. IN LPWSTR pszLdapServer,
  105. IN LPWSTR pszLdapDn,
  106. IN LPWSTR pszSearchFilter,
  107. IN LPWSTR * pAttributeNames,
  108. IN DWORD dwNumberAttributes,
  109. OUT PADS_SEARCH_HANDLE phSearchHandle
  110. );
  111. HRESULT
  112. ADsAbandonSearch(
  113. IN ADS_SEARCH_HANDLE hSearchHandle
  114. );
  115. HRESULT
  116. ADsCloseSearchHandle (
  117. IN ADS_SEARCH_HANDLE hSearchHandle
  118. );
  119. HRESULT
  120. ADsGetFirstRow(
  121. IN ADS_SEARCH_HANDLE hSearchHandle,
  122. IN CCredentials& CCredentials
  123. );
  124. HRESULT
  125. ADsGetNextRow(
  126. IN ADS_SEARCH_HANDLE hSearchHandle,
  127. IN CCredentials& CCredentials
  128. );
  129. HRESULT
  130. ADsGetPreviousRow(
  131. IN ADS_SEARCH_HANDLE hSearchHandle,
  132. IN CCredentials& CCredentials
  133. );
  134. HRESULT
  135. ADsGetColumn(
  136. IN ADS_SEARCH_HANDLE hSearchHandle,
  137. IN LPWSTR pszColumnName,
  138. IN CCredentials& CCredentials,
  139. DWORD dwPort,
  140. OUT PADS_SEARCH_COLUMN pColumn
  141. );
  142. HRESULT
  143. ADsGetNextColumnName(
  144. IN ADS_SEARCH_HANDLE hSearchHandle,
  145. OUT LPWSTR * ppszColumnName
  146. );
  147. HRESULT
  148. ADsFreeColumn(
  149. IN PADS_SEARCH_COLUMN pColumn
  150. );
  151. HRESULT
  152. ADsGetResults(
  153. IN PLDAP_SEARCHINFO phSearchInfo
  154. );
  155. HRESULT
  156. ADsGetMoreResults(
  157. IN PLDAP_SEARCHINFO phSearchInfo
  158. );
  159. HRESULT
  160. AddSearchControls(
  161. PLDAP_SEARCHINFO phSearchInfo,
  162. CCredentials& Credentials
  163. );
  164. void
  165. FreeSortKeys(
  166. IN PLDAPSortKey pSortKeys,
  167. IN DWORD dwSortKeys
  168. );
  169. HRESULT
  170. CopyLDAPVLVInfo(
  171. PLDAPVLVInfo pVLVInfoSource,
  172. PLDAPVLVInfo *ppVLVInfoTarget
  173. );
  174. void
  175. FreeLDAPVLVInfo(
  176. IN PLDAPVLVInfo pVLVInfo
  177. );
  178. HRESULT
  179. StoreVLVInfo(
  180. LDAPMessage *pLDAPMsg,
  181. PLDAP_SEARCHINFO phSearchInfo
  182. );
  183. HRESULT
  184. StoreAttribScopedInfo(
  185. LDAPMessage *pLDAPMsg,
  186. PLDAP_SEARCHINFO phSearchInfo
  187. );
  188. HRESULT
  189. StoreDirSyncCookie(
  190. IN LDAPMessage *pLDAPMsg,
  191. IN PLDAP_SEARCHINFO phSearchInfo
  192. );
  193. HRESULT
  194. BerEncodeReplicationCookie(
  195. PBYTE pCookie,
  196. DWORD dwLen,
  197. PBERVAL *ppBerVal,
  198. DWORD dwFlag
  199. );
  200. HRESULT
  201. BerEncodeAttribScopedControlValue(
  202. LPCWSTR pAttribScoped,
  203. PBERVAL *ppBerVal
  204. );
  205. HRESULT
  206. BerEncodeExtendedDNControlValue(
  207. DWORD dwOption,
  208. PBERVAL *ppBerVal
  209. );
  210. HRESULT
  211. BerEncodingQuotaControl(
  212. PBYTE pSid,
  213. DWORD dwSidLength,
  214. PBERVAL *ppBerVal
  215. );
  216. HRESULT
  217. ADsGetMoreResultsDirSync(
  218. IN PLDAP_SEARCHINFO phSearchInfo,
  219. IN CCredentials& Credentials
  220. );
  221. //
  222. // Helper routine to initialize search preferences.
  223. //
  224. void
  225. LdapInitializeSearchPreferences(
  226. LDAP_SEARCH_PREF *pSearchPrefs,
  227. BOOL fCacheResults
  228. );
  229. //
  230. // Helper routine to get the normal dn from extended dn part
  231. //
  232. HRESULT
  233. HelpGetNormalDN(
  234. LPWSTR pszDn,
  235. LPWSTR* ppszTempDn
  236. );
  237. //
  238. // This routine is used in Umi search support.
  239. //
  240. HRESULT
  241. ADsHelperGetCurrentRowMessage(
  242. IN ADS_SEARCH_HANDLE hSearchHandle,
  243. OUT PADSLDP *ppAdsLdp,
  244. OUT LDAPMessage **ppLdapMsg
  245. );
  246. #endif // _SRCHUTIL_H_INCLUDED_