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.

252 lines
6.1 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. }LDAP_SEARCH_PREF, *PLDAP_SEARCH_PREF;
  39. //
  40. // LDAP search structure; Contains all the information pertaining to the
  41. // current search
  42. //
  43. typedef struct _ldap_searchinfo {
  44. ADS_LDP *_pConnection;
  45. LPWSTR _pszADsPathContext;
  46. LPWSTR _pszLdapServer;
  47. LPWSTR _pszBindContextDn;
  48. LPWSTR _pszSearchFilter;
  49. LPWSTR *_ppszAttrs;
  50. LPWSTR _pszAttrNameBuffer;
  51. LDAPMessage **_pSearchResults;
  52. DWORD _cSearchResults;
  53. DWORD _dwCurrResult;
  54. DWORD _dwMaxResultGot;
  55. ULONG _currMsgId;
  56. LDAPMessage *_pCurrentRow;
  57. void *_pFirstAttr;
  58. LDAP_SEARCH_PREF _SearchPref;
  59. PLDAPSearch _hPagedSearch;
  60. DWORD _dwPort;
  61. PLDAPControl *_ServerControls;
  62. PLDAPControl *_ClientControls;
  63. HRESULT _hrLastSearch;
  64. BOOL _fAbandon;
  65. PBERVAL _pBerVal;
  66. DWORD _dwVLVOffset; // VirtualListViewResponse
  67. DWORD _dwVLVCount; // ""
  68. PBERVAL _pVLVContextID; // ""
  69. PBERVAL _pBerValAttribScoped; // attribute-scoped query control value
  70. //
  71. // We use bitfields to store the booleans to try to cut down on the size
  72. // of this structure. Keep them together to permit the compiler to pack them
  73. // into the minimum space without added padding.
  74. //
  75. BOOL _fLastResult:1;
  76. BOOL _fLastPage:1;
  77. BOOL _fBefFirstRow:1;
  78. BOOL _fADsPathPresent:1;
  79. BOOL _fADsPathReturned:1;
  80. BOOL _fADsPathOnly:1; // TRUE = user requested only ADsPath attrib
  81. BOOL _fMoreDirSync:1;
  82. BOOL _fNonFatalErrors:1; // TRUE = non-fatal error occurred, need to warn
  83. }LDAP_SEARCHINFO, *PLDAP_SEARCHINFO;
  84. HRESULT
  85. ADsSetSearchPreference(
  86. IN PADS_SEARCHPREF_INFO pSearchPrefs,
  87. IN DWORD dwNumPrefs,
  88. OUT LDAP_SEARCH_PREF * pLdapPref,
  89. IN LPWSTR pszLDAPServer,
  90. IN LPWSTR pszLDAPDn,
  91. IN CCredentials& Credentials,
  92. IN DWORD dwPort
  93. );
  94. HRESULT
  95. ADsExecuteSearch(
  96. IN LDAP_SEARCH_PREF LdapPref,
  97. IN LPWSTR pszADsPath,
  98. IN LPWSTR pszLdapServer,
  99. IN LPWSTR pszLdapDn,
  100. IN LPWSTR pszSearchFilter,
  101. IN LPWSTR * pAttributeNames,
  102. IN DWORD dwNumberAttributes,
  103. OUT PADS_SEARCH_HANDLE phSearchHandle
  104. );
  105. HRESULT
  106. ADsAbandonSearch(
  107. IN ADS_SEARCH_HANDLE hSearchHandle
  108. );
  109. HRESULT
  110. ADsCloseSearchHandle (
  111. IN ADS_SEARCH_HANDLE hSearchHandle
  112. );
  113. HRESULT
  114. ADsGetFirstRow(
  115. IN ADS_SEARCH_HANDLE hSearchHandle,
  116. IN CCredentials& CCredentials
  117. );
  118. HRESULT
  119. ADsGetNextRow(
  120. IN ADS_SEARCH_HANDLE hSearchHandle,
  121. IN CCredentials& CCredentials
  122. );
  123. HRESULT
  124. ADsGetPreviousRow(
  125. IN ADS_SEARCH_HANDLE hSearchHandle,
  126. IN CCredentials& CCredentials
  127. );
  128. HRESULT
  129. ADsGetColumn(
  130. IN ADS_SEARCH_HANDLE hSearchHandle,
  131. IN LPWSTR pszColumnName,
  132. IN CCredentials& CCredentials,
  133. DWORD dwPort,
  134. OUT PADS_SEARCH_COLUMN pColumn
  135. );
  136. HRESULT
  137. ADsGetNextColumnName(
  138. IN ADS_SEARCH_HANDLE hSearchHandle,
  139. OUT LPWSTR * ppszColumnName
  140. );
  141. HRESULT
  142. ADsFreeColumn(
  143. IN PADS_SEARCH_COLUMN pColumn
  144. );
  145. HRESULT
  146. ADsGetResults(
  147. IN PLDAP_SEARCHINFO phSearchInfo
  148. );
  149. HRESULT
  150. ADsGetMoreResults(
  151. IN PLDAP_SEARCHINFO phSearchInfo
  152. );
  153. HRESULT
  154. AddSearchControls(
  155. PLDAP_SEARCHINFO phSearchInfo,
  156. CCredentials& Credentials
  157. );
  158. void
  159. FreeSortKeys(
  160. IN PLDAPSortKey pSortKeys,
  161. IN DWORD dwSortKeys
  162. );
  163. HRESULT
  164. CopyLDAPVLVInfo(
  165. PLDAPVLVInfo pVLVInfoSource,
  166. PLDAPVLVInfo *ppVLVInfoTarget
  167. );
  168. void
  169. FreeLDAPVLVInfo(
  170. IN PLDAPVLVInfo pVLVInfo
  171. );
  172. HRESULT
  173. StoreVLVInfo(
  174. LDAPMessage *pLDAPMsg,
  175. PLDAP_SEARCHINFO phSearchInfo
  176. );
  177. HRESULT
  178. StoreAttribScopedInfo(
  179. LDAPMessage *pLDAPMsg,
  180. PLDAP_SEARCHINFO phSearchInfo
  181. );
  182. HRESULT
  183. StoreDirSyncCookie(
  184. IN LDAPMessage *pLDAPMsg,
  185. IN PLDAP_SEARCHINFO phSearchInfo
  186. );
  187. HRESULT
  188. BerEncodeReplicationCookie(
  189. PBYTE pCookie,
  190. DWORD dwLen,
  191. PBERVAL *ppBerVal
  192. );
  193. HRESULT
  194. BerEncodeAttribScopedControlValue(
  195. LPCWSTR pAttribScoped,
  196. PBERVAL *ppBerVal
  197. );
  198. HRESULT
  199. ADsGetMoreResultsDirSync(
  200. IN PLDAP_SEARCHINFO phSearchInfo,
  201. IN CCredentials& Credentials
  202. );
  203. //
  204. // Helper routine to initialize search preferences.
  205. //
  206. void
  207. LdapInitializeSearchPreferences(
  208. LDAP_SEARCH_PREF *pSearchPrefs,
  209. BOOL fCacheResults
  210. );
  211. //
  212. // This routine is used in Umi search support.
  213. //
  214. HRESULT
  215. ADsHelperGetCurrentRowMessage(
  216. IN ADS_SEARCH_HANDLE hSearchHandle,
  217. OUT PADSLDP *ppAdsLdp,
  218. OUT LDAPMessage **ppLdapMsg
  219. );
  220. #endif // _SRCHUTIL_H_INCLUDED_