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.

91 lines
2.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1999
  5. //
  6. // File: DSQuery.h
  7. //
  8. // Contents: Query object for DS snapin
  9. //
  10. // History: 04-dec-96 jimharr Created
  11. //
  12. //--------------------------------------------------------------------------
  13. #ifndef __QUERY_H__
  14. #define __QUERY_H__
  15. #define QUERY_PAGESIZE 50
  16. //
  17. // CDSSearch
  18. //
  19. class CDSSearch
  20. {
  21. public:
  22. CDSSearch();
  23. ~CDSSearch();
  24. // INTERFACES
  25. public:
  26. HRESULT Init(IDirectorySearch * pObj);
  27. HRESULT Init(PCWSTR pszPath, const CDSCmdCredentialObject& refCredObject);
  28. HRESULT DoQuery(BOOL bAttrOnly = FALSE);
  29. HRESULT GetNextRow ();
  30. HRESULT GetColumn(LPWSTR Attribute,
  31. PADS_SEARCH_COLUMN pColumnData);
  32. HRESULT FreeColumn(PADS_SEARCH_COLUMN pColumnData)
  33. {
  34. return m_pObj->FreeColumn(pColumnData);
  35. };
  36. HRESULT SetAttributeList (LPTSTR *pszAttribs, INT cAttrs);
  37. HRESULT SetSearchScope (ADS_SCOPEENUM scope);
  38. HRESULT SetFilterString (LPWSTR pszFilter)
  39. {
  40. if (!pszFilter)
  41. {
  42. return E_INVALIDARG;
  43. }
  44. if (m_pwszFilter)
  45. {
  46. delete[] m_pwszFilter;
  47. m_pwszFilter = NULL;
  48. }
  49. //Security Review:This is fine.
  50. m_pwszFilter = new WCHAR[wcslen(pszFilter) + 1];
  51. if (!m_pwszFilter)
  52. {
  53. return E_OUTOFMEMORY;
  54. }
  55. //Security Review:Correct buffer is allocated above.
  56. wcscpy(m_pwszFilter, pszFilter);
  57. return S_OK;
  58. };
  59. HRESULT GetNextColumnName(LPWSTR *ppszColumnName);
  60. VOID FreeColumnName(LPWSTR pszColumnName)
  61. {
  62. FreeADsMem(pszColumnName);
  63. }
  64. //Attributes
  65. public:
  66. IDirectorySearch * m_pObj;
  67. ADS_SEARCH_HANDLE m_SearchHandle;
  68. protected:
  69. LPWSTR m_pwszFilter;
  70. LPWSTR * m_ppszAttr;
  71. DWORD m_CountAttr;
  72. ADS_SCOPEENUM m_scope;
  73. private:
  74. void _Reset();
  75. BOOL m_bInitialized;
  76. };
  77. #endif //__DSQUERY_H__