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.

187 lines
3.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 2000.
  5. //
  6. // File: umisrch.hxx
  7. //
  8. // Contents: Header for file containing an IDirectorySearch wrapper that
  9. // is used in UMI land for enumeration and queries.
  10. //
  11. // History: 03-20-00 AjayR Created.
  12. //
  13. //----------------------------------------------------------------------------
  14. #ifndef __CUMISRCH_H__
  15. #define __CUMISRCH_H__
  16. //
  17. // Helper routines to make sure that the properties are the correct type.
  18. //
  19. inline
  20. HRESULT
  21. VerifyValidLongProperty(PUMI_PROPERTY_VALUES pPropVals) {
  22. if (!pPropVals || !pPropVals->pPropArray || (pPropVals->uCount != 1)) {
  23. RRETURN(E_FAIL);
  24. }
  25. if (pPropVals->pPropArray[0].uType != UMI_TYPE_I4) {
  26. RRETURN(E_FAIL);
  27. }
  28. else {
  29. RRETURN(S_OK);
  30. }
  31. }
  32. inline
  33. HRESULT
  34. VerifyValidBoolProperty(PUMI_PROPERTY_VALUES pPropVals) {
  35. if (!pPropVals || !pPropVals->pPropArray || (pPropVals->uCount != 1)) {
  36. RRETURN(E_FAIL);
  37. }
  38. if (pPropVals->pPropArray[0].uType != UMI_TYPE_BOOL) {
  39. RRETURN(E_FAIL);
  40. }
  41. else {
  42. RRETURN(S_OK);
  43. }
  44. }
  45. class CUmiSearchHelper {
  46. public:
  47. //
  48. // Helper routines to support IUmiCursor
  49. //
  50. HRESULT
  51. CUmiSearchHelper::Reset();
  52. HRESULT
  53. CUmiSearchHelper::Next(
  54. ULONG uNumRequested,
  55. ULONG *puNumReturned,
  56. LPVOID *ppObjects
  57. );
  58. HRESULT
  59. CUmiSearchHelper::Previous(
  60. ULONG uFlags,
  61. LPVOID *pObj
  62. );
  63. //
  64. // Other public methods.
  65. //
  66. CUmiSearchHelper::CUmiSearchHelper();
  67. CUmiSearchHelper::~CUmiSearchHelper();
  68. HRESULT
  69. CUmiSearchHelper::SetIID(REFIID riid);
  70. static
  71. HRESULT
  72. CUmiSearchHelper::CreateSearchHelper(
  73. IUmiQuery *pUmiQuery,
  74. IUmiConnection *pConnection,
  75. IUnknown *pUnk, // the container that is executing the query.
  76. LPCWSTR pszADsPath,
  77. LPCWSTR pszLdapServer,
  78. LPCWSTR pszLdapDn,
  79. CCredentials cCredentials,
  80. DWORD dwPort,
  81. CUmiSearchHelper FAR * FAR * ppSrchObj
  82. );
  83. //
  84. // Internal/protected routines
  85. //
  86. protected:
  87. HRESULT
  88. CUmiSearchHelper::InitializeSearchContext();
  89. HRESULT
  90. CUmiSearchHelper::GetNextObject(IUnknown **pUmiObject);
  91. HRESULT
  92. CUmiSearchHelper::ProcessSQLQuery(
  93. LPCWSTR pszQueryText,
  94. LPWSTR *ppszFilter,
  95. PADS_SORTKEY *pSortKey
  96. );
  97. //
  98. // Member variables.
  99. //
  100. ADS_SEARCH_HANDLE _hSearchHandle;
  101. IUmiConnection* _pConnection;
  102. IUnknown* _pContainer;
  103. IUmiQuery *_pQuery;
  104. BOOL _fSearchExecuted;
  105. BOOL _fResetAllowed;
  106. LDAP_SEARCH_PREF _searchPrefs;
  107. LPWSTR _pszADsPath;
  108. LPWSTR _pszLdapServer;
  109. LPWSTR _pszLdapDn;
  110. CCredentials* _pCreds;
  111. DWORD _dwPort;
  112. IID *_pIID;
  113. };
  114. //
  115. // Code below is needed for a helper stack class.
  116. //
  117. typedef struct _stacklist {
  118. LPWSTR pszElement;
  119. DWORD dwElementType;
  120. struct _stacklist *pNext;
  121. } STACKLIST, *PSTACKLIST;
  122. //
  123. // Types of things that can be pushed.
  124. //
  125. #define QUERY_STACK_ITEM_LITERAL 1
  126. #define QUERY_STACK_ITEM_OPERATOR 2
  127. class CQueryStack {
  128. public:
  129. CQueryStack::CQueryStack();
  130. CQueryStack::~CQueryStack();
  131. HRESULT
  132. CQueryStack::Push(
  133. LPWSTR pszString,
  134. DWORD dwType
  135. );
  136. HRESULT
  137. CQueryStack::Pop(
  138. LPWSTR *ppszString,
  139. DWORD *pdwType
  140. );
  141. BOOL
  142. CQueryStack::IsEmpty();
  143. protected:
  144. static
  145. HRESULT
  146. CQueryStack::AllocateStackEntry(
  147. LPWSTR pszString,
  148. DWORD dwType,
  149. STACKLIST **ppStackEntry
  150. );
  151. static
  152. void
  153. CQueryStack::FreeStackEntry(
  154. PSTACKLIST pStackEntry
  155. );
  156. PSTACKLIST _pStackList;
  157. DWORD _dwElementCount;
  158. };
  159. #endif // __CUMISRCH_H__