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.

205 lines
5.6 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. CDnsWrap& dns = CDnsWrap::DnsObject();
  154. pClass->SpawnInstance(0, &NewInst);
  155. // setting object path for parent in association
  156. CObjPath objPathParent;
  157. objPathParent.SetClass(PVD_CLASS_DOMAIN);
  158. objPathParent.AddProperty(
  159. PVD_DOMAIN_SERVER_NAME,
  160. dns.GetServerName().data() );
  161. objPathParent.AddProperty(
  162. PVD_DOMAIN_CONTAINER_NAME,
  163. ParentDomain.wstrZoneName.data() );
  164. objPathParent.AddProperty(
  165. PVD_DOMAIN_FQDN,
  166. ParentDomain.wstrNodeName.data() );
  167. NewInst.SetProperty(
  168. objPathParent.GetObjectPathString(),
  169. PVD_ASSOC_PARENT);
  170. //setting object path for child in association
  171. wstring wzFQDN = pNode->GetNodeName();
  172. wzFQDN += PVD_DNS_LOCAL_SERVER + ParentDomain.wstrNodeName;
  173. CObjPath opChild = objPathParent;
  174. opChild.SetProperty(
  175. PVD_DOMAIN_FQDN,
  176. wzFQDN.data() );
  177. NewInst.SetProperty(
  178. opChild.GetObjectPathString(),
  179. PVD_ASSOC_CHILD );
  180. InstMgr.Indicate(NewInst.data());
  181. return WBEM_S_NO_ERROR;
  182. }