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.

204 lines
5.1 KiB

  1. /////////////////////////////////////////////////////////////////////
  2. //
  3. // CopyRight ( c ) 1999 Microsoft Corporation
  4. //
  5. // Module Name: DnsDomainDomainContainment.cpp
  6. //
  7. // Description:
  8. // Implementation of CDnsDomainDomainContainment class
  9. //
  10. // Author:
  11. // Henry Wang ( henrywa ) March 8, 2000
  12. //
  13. //
  14. //////////////////////////////////////////////////////////////////////
  15. #include "DnsWmi.h"
  16. /////////////////////////////////////////////////////////////////////////////
  17. //++
  18. //
  19. // Description:
  20. // create an instance of CDnsDomainDomainContainment
  21. //
  22. // Arguments:
  23. // wszName [IN] class name
  24. // pNamespace [IN] wmi namespace
  25. // szType [IN] child class name of resource record class
  26. //
  27. // Return Value:
  28. // WBEM_S_NO_ERROR
  29. //
  30. //--
  31. /////////////////////////////////////////////////////////////////////////////
  32. CDnsBase*
  33. CDnsDomainDomainContainment::CreateThis(
  34. const WCHAR * wszName,
  35. CWbemServices * pNamespace,
  36. const char * szType
  37. )
  38. {
  39. return new CDnsDomainDomainContainment(wszName, pNamespace);
  40. }
  41. CDnsDomainDomainContainment::CDnsDomainDomainContainment()
  42. {
  43. }
  44. CDnsDomainDomainContainment::CDnsDomainDomainContainment(
  45. const WCHAR* wszName,
  46. CWbemServices *pNamespace)
  47. :CDnsBase(wszName, pNamespace)
  48. {
  49. }
  50. CDnsDomainDomainContainment::~CDnsDomainDomainContainment()
  51. {
  52. }
  53. /////////////////////////////////////////////////////////////////////////////
  54. //++
  55. //
  56. //
  57. // Description:
  58. // enum instances of domain and domain association
  59. //
  60. // Arguments:
  61. // lFlags [IN] WMI flag
  62. // pCtx [IN] WMI context
  63. // pHandler [IN] WMI sink pointer
  64. //
  65. // Return Value:
  66. // WBEM_S_NO_ERROR
  67. //
  68. //--
  69. /////////////////////////////////////////////////////////////////////////////
  70. SCODE
  71. CDnsDomainDomainContainment::EnumInstance(
  72. long lFlags,
  73. IWbemContext * pCtx,
  74. IWbemObjectSink * pHandler)
  75. {
  76. // get top level zones
  77. list<CDomainNode> objList;
  78. CDnsWrap& dns = CDnsWrap::DnsObject();
  79. SCODE sc = dns.dnsEnumDomainForServer(&objList);
  80. list<CDomainNode>::iterator i;
  81. CWbemInstanceMgr InstMgr(
  82. pHandler);
  83. // enumerate all domaindomain for all zones
  84. for(i=objList.begin(); i!=objList.end(); ++i)
  85. {
  86. sc = dns.dnsEnumRecordsForDomainEx(
  87. *i,
  88. NULL,
  89. InstanceFilter,
  90. TRUE,
  91. DNS_TYPE_ALL,
  92. DNS_RPC_VIEW_ALL_DATA,
  93. m_pClass,
  94. InstMgr);
  95. }
  96. return sc;
  97. }
  98. SCODE
  99. CDnsDomainDomainContainment::GetObject(
  100. CObjPath & ObjectPath,
  101. long lFlags,
  102. IWbemContext * pCtx,
  103. IWbemObjectSink * pHandler
  104. )
  105. {
  106. return WBEM_S_NO_ERROR;
  107. }
  108. SCODE CDnsDomainDomainContainment::ExecuteMethod(
  109. CObjPath & objPath,
  110. WCHAR * wzMethodName,
  111. long lFlag,
  112. IWbemClassObject * pInArgs,
  113. IWbemObjectSink * pHandler
  114. )
  115. {
  116. return WBEM_S_NO_ERROR;
  117. }
  118. /////////////////////////////////////////////////////////////////////////////
  119. //++
  120. //
  121. // Description:
  122. // call back function to enum domain instance.
  123. // if pNode represents a domain node, create a wmi domain instance
  124. //
  125. // Arguments:
  126. // CDomainNode [IN] Parent domain
  127. // pFilter [IN] pointer to object that contains the criteria to filter
  128. // which instance should be send to wmi
  129. // not used here
  130. // pNode [IN] pointer to Dns Rpc Node object
  131. // pClass [IN] wmi class used to create instance
  132. // InstMgr [IN] a ref to Instance manager obj that is
  133. // responsible to send mutiple instance
  134. // back to wmi at once
  135. //
  136. // Return Value:
  137. // WBEM_S_NO_ERROR
  138. //
  139. //--
  140. /////////////////////////////////////////////////////////////////////////////
  141. SCODE
  142. CDnsDomainDomainContainment::InstanceFilter(
  143. CDomainNode & ParentDomain,
  144. PVOID pFilter,
  145. CDnsRpcNode * pNode,
  146. IWbemClassObject * pClass,
  147. CWbemInstanceMgr & InstMgr
  148. )
  149. {
  150. CWbemClassObject NewInst;
  151. if(!pNode->IsDomainNode())
  152. return WBEM_S_NO_ERROR;
  153. // CObjPath* pFilterObj = (CObjPath*) pFilter;
  154. CDnsWrap& dns = CDnsWrap::DnsObject();
  155. pClass->SpawnInstance(0, &NewInst);
  156. // setting object path for parent in association
  157. CObjPath objPathParent;
  158. objPathParent.SetClass(PVD_CLASS_DOMAIN);
  159. objPathParent.AddProperty(
  160. PVD_DOMAIN_SERVER_NAME,
  161. dns.GetServerName().data()
  162. );
  163. objPathParent.AddProperty(
  164. PVD_DOMAIN_CONTAINER_NAME,
  165. ParentDomain.wstrZoneName.data()
  166. );
  167. objPathParent.AddProperty(
  168. PVD_DOMAIN_FQDN,
  169. ParentDomain.wstrNodeName.data()
  170. );
  171. NewInst.SetProperty(
  172. objPathParent.GetObjectPathString(),
  173. PVD_ASSOC_PARENT);
  174. //setting object path for child in association
  175. wstring wzFQDN = pNode->GetNodeName();
  176. wzFQDN += PVD_DNS_LOCAL_SERVER + ParentDomain.wstrNodeName;
  177. CObjPath opChild = objPathParent;
  178. opChild.SetProperty(
  179. PVD_DOMAIN_FQDN,
  180. wzFQDN.data()
  181. );
  182. NewInst.SetProperty(
  183. opChild.GetObjectPathString(),
  184. PVD_ASSOC_CHILD
  185. );
  186. InstMgr.Indicate(NewInst.data());
  187. return WBEM_S_NO_ERROR;
  188. }