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.

120 lines
3.2 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Windows NT Active Directory Service domain trust verification WMI provider
  4. //
  5. // Microsoft Windows
  6. // Copyright (C) Microsoft Corporation, 1992 - 2000
  7. //
  8. // File: domain.h
  9. //
  10. // Contents: domain class definition
  11. //
  12. // Classes: CDomainInfo
  13. //
  14. // History: 27-Mar-00 EricB created
  15. //
  16. //-----------------------------------------------------------------------------
  17. #ifndef DOMAIN_H
  18. #define DOMAIN_H
  19. extern PCWSTR CSTR_PROP_LOCAL_DNS_NAME;
  20. extern PCWSTR CSTR_PROP_LOCAL_FLAT_NAME;
  21. extern PCWSTR CSTR_PROP_LOCAL_SID;
  22. extern PCWSTR CSTR_PROP_LOCAL_TREE_NAME;
  23. extern PCWSTR CSTR_PROP_LOCAL_DC_NAME;
  24. #ifndef MAXDWORD
  25. #define MAXDWORD ((DWORD) -1)
  26. #endif
  27. class CTrustPrv; // forward declaration;
  28. //+----------------------------------------------------------------------------
  29. //
  30. // class CDomainInfo
  31. //
  32. // Domain Information with list of all of the domain's Trusts
  33. //
  34. //-----------------------------------------------------------------------------
  35. class CDomainInfo
  36. {
  37. public:
  38. CDomainInfo(void);
  39. ~CDomainInfo(void);
  40. friend class CTrustPrv;
  41. void SetDnsName(PWSTR pszName) {m_strDomainDnsName = pszName;}
  42. PCWSTR GetDnsName(void) {return m_strDomainDnsName;}
  43. void SetFlatName(PWSTR pszFlatName) {m_strDomainFlatName = pszFlatName;}
  44. PCWSTR GetFlatName(void) {return m_strDomainFlatName;}
  45. BOOL SetSid(PSID pSid);
  46. PCWSTR GetSid(void) {return m_strSid;}
  47. void SetForestName(PWSTR pszName) {m_strForestName = pszName;}
  48. PCWSTR GetForestName(void) {return m_strForestName;}
  49. void SetDcName(PWSTR pszName) {m_strDcName = pszName;}
  50. PCWSTR GetDcName(void) {return m_strDcName;}
  51. HRESULT Init(IWbemClassObject * pClassDef); // Call once to initialize this object
  52. void Reset(void); // Reset the internal cache
  53. HRESULT EnumerateTrusts(void); // Enumerate Outgoing trusts for the local domain
  54. size_t Size(void) const {return m_vectTrustInfo.size();} // Get the number of trusts
  55. CTrustInfo * FindTrust(PCWSTR strTrust); // Find trust's index
  56. CTrustInfo * GetTrustByIndex(size_t index); // Get trust info by Index
  57. BOOL IsTrustListStale(LARGE_INTEGER liMaxAge);
  58. protected:
  59. HRESULT CreateAndSendInst(IWbemObjectSink * pResponseHandler);
  60. // Object's Status
  61. BOOL IsEnumerated(void) const {return m_liLastEnumed.QuadPart != 0;}
  62. private:
  63. //
  64. // Microsoft_LocalDomainInfo properties:
  65. //
  66. CString m_strDomainFlatName;
  67. CString m_strDomainDnsName;
  68. CString m_strForestName;
  69. CString m_strSid;
  70. CString m_strDcName;
  71. // TODO: FSMO holder info???
  72. // internal variables.
  73. //
  74. CComPtr<IWbemClassObject> m_sipClassDefLocalDomain;
  75. vector<CTrustInfo *> m_vectTrustInfo; // array of trusts
  76. LARGE_INTEGER m_liLastEnumed;
  77. };
  78. class CSmartPolicyHandle
  79. {
  80. public:
  81. CSmartPolicyHandle(void) : m_hPolicy(NULL) {};
  82. ~CSmartPolicyHandle(void)
  83. {
  84. if( m_hPolicy )
  85. {
  86. LsaClose(m_hPolicy);
  87. m_hPolicy = NULL;
  88. }
  89. };
  90. LSA_HANDLE * operator&()
  91. {
  92. return &m_hPolicy;
  93. }
  94. operator LSA_HANDLE() const
  95. {
  96. return m_hPolicy;
  97. }
  98. private:
  99. LSA_HANDLE m_hPolicy;
  100. };
  101. #endif //DOMAIN_H