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.

201 lines
3.8 KiB

  1. #ifndef IMPLMAIN_HPP_INCLUDED
  2. #define IMPLMAIN_HPP_INCLUDED
  3. class CloneSecurityPrincipal
  4. :
  5. public ICloneSecurityPrincipal,
  6. public ISupportErrorInfo,
  7. public IADsError,
  8. public IADsSID
  9. {
  10. // this is the only entity with access to the ctor of this class
  11. friend class ClassFactory<CloneSecurityPrincipal>;
  12. public:
  13. // IUnknown methods
  14. virtual
  15. HRESULT __stdcall
  16. QueryInterface(const IID& riid, void **ppv);
  17. virtual
  18. ULONG __stdcall
  19. AddRef();
  20. virtual
  21. ULONG __stdcall
  22. Release();
  23. // IDispatch methods
  24. virtual
  25. HRESULT __stdcall
  26. GetTypeInfoCount(UINT *pcti);
  27. virtual
  28. HRESULT __stdcall
  29. GetTypeInfo(UINT cti, LCID, ITypeInfo **ppti);
  30. virtual
  31. HRESULT __stdcall
  32. GetIDsOfNames(
  33. REFIID riid,
  34. OLECHAR **prgpsz,
  35. UINT cNames,
  36. LCID lcid,
  37. DISPID *prgids);
  38. virtual
  39. HRESULT __stdcall
  40. Invoke(
  41. DISPID id,
  42. REFIID riid,
  43. LCID lcid,
  44. WORD wFlags,
  45. DISPPARAMS *params,
  46. VARIANT *pVarResult,
  47. EXCEPINFO *pei,
  48. UINT *puArgErr);
  49. // ISupportErrorInfo methods
  50. virtual
  51. HRESULT __stdcall
  52. InterfaceSupportsErrorInfo(const IID& iid);
  53. // ICloneSecurityPrincipal methods
  54. virtual
  55. HRESULT __stdcall
  56. Connect(
  57. BSTR srcDomainController,
  58. BSTR srcDomain,
  59. BSTR dstDomainController,
  60. BSTR dstDomain);
  61. virtual
  62. HRESULT __stdcall
  63. CopyDownlevelUserProperties(
  64. BSTR srcSamName,
  65. BSTR dstSamName,
  66. long flags);
  67. virtual
  68. HRESULT __stdcall
  69. AddSidHistory(
  70. BSTR srcPrincipalSamName,
  71. BSTR dstPrincipalSamName,
  72. long flags);
  73. virtual
  74. HRESULT __stdcall
  75. GetMembersSIDs(
  76. BSTR dstGroupDN,
  77. VARIANT* pVal);
  78. // IADsSID methods
  79. virtual
  80. HRESULT __stdcall
  81. SetAs(
  82. long lFormat,
  83. VARIANT varData);
  84. virtual
  85. HRESULT __stdcall
  86. GetAs(
  87. long lFormat,
  88. VARIANT* pVar);
  89. // IADsError methods
  90. virtual
  91. HRESULT __stdcall
  92. GetErrorMsg(
  93. long hrErr,
  94. BSTR* Msg);
  95. private:
  96. // only our friend class factory can instantiate us.
  97. CloneSecurityPrincipal();
  98. // only Release can cause us to be deleted
  99. virtual
  100. ~CloneSecurityPrincipal();
  101. // not implemented: no copying allowed
  102. CloneSecurityPrincipal(const CloneSecurityPrincipal&);
  103. const CloneSecurityPrincipal& operator=(const CloneSecurityPrincipal&);
  104. HRESULT
  105. DoAddSidHistory(
  106. const String& srcPrincipalSamName,
  107. const String& dstPrincipalSamName,
  108. long flags);
  109. HRESULT
  110. DoCopyDownlevelUserProperties(
  111. const String& srcSamName,
  112. const String& dstSamName,
  113. long flags);
  114. // represents the authenticated connection to the source and destination
  115. // domain controllers, including ds bindings
  116. class Connection
  117. {
  118. friend class CloneSecurityPrincipal;
  119. public:
  120. Connection();
  121. // disconnects, unbinds.
  122. ~Connection();
  123. HRESULT
  124. Connect(
  125. const String& srcDC,
  126. const String& srcDomain,
  127. const String& dstDC,
  128. const String& dstDomain);
  129. bool
  130. IsConnected() const;
  131. private:
  132. Computer* dstComputer;
  133. SAM_HANDLE dstDomainSamHandle;
  134. HANDLE dstDsBindHandle;
  135. PLDAP m_pldap;
  136. Computer* srcComputer;
  137. String srcDcDnsName;
  138. SAM_HANDLE srcDomainSamHandle;
  139. // not implemented: no copying allowed
  140. Connection(const Connection&);
  141. const Connection& operator=(const Connection&);
  142. void
  143. Disconnect();
  144. };
  145. Connection* connection;
  146. ComServerReference dllref;
  147. long refcount;
  148. ITypeInfo** m_ppTypeInfo;
  149. // used by IADsSID
  150. PSID m_pSID;
  151. };
  152. #endif // IMPLMAIN_HPP_INCLUDED