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.

260 lines
6.2 KiB

  1. /////////////////////////////////////////////////////////////////////
  2. //
  3. // CopyRight ( c ) 1999 Microsoft Corporation
  4. //
  5. // Module Name: Dnsroothints.cpp
  6. //
  7. // Description:
  8. // Implementation of CDnsRootHints class
  9. //
  10. // Author:
  11. // Henry Wang ( henrywa ) March 8, 2000
  12. //
  13. //
  14. //////////////////////////////////////////////////////////////////////
  15. #include "DnsWmi.h"
  16. //////////////////////////////////////////////////////////////////////
  17. // Construction/Destruction
  18. //////////////////////////////////////////////////////////////////////
  19. /////////////////////////////////////////////////////////////////////////////
  20. //++
  21. //
  22. // Description:
  23. // create an instance of CDnsRootHints
  24. //
  25. // Arguments:
  26. // wszName [IN] class name
  27. // pNamespace [IN] wmi namespace
  28. // szType [IN] child class name of resource record class
  29. //
  30. // Return Value:
  31. // WBEM_S_NO_ERROR
  32. //
  33. //--
  34. /////////////////////////////////////////////////////////////////////////////
  35. CDnsBase*
  36. CDnsRootHints::CreateThis(
  37. const WCHAR * wszName,
  38. CWbemServices * pNamespace,
  39. const char * szType
  40. )
  41. {
  42. return new CDnsRootHints(wszName, pNamespace);
  43. }
  44. CDnsRootHints::CDnsRootHints()
  45. {
  46. }
  47. CDnsRootHints::CDnsRootHints(
  48. const WCHAR* wszName,
  49. CWbemServices *pNamespace)
  50. :CDnsBase(wszName, pNamespace)
  51. {
  52. }
  53. CDnsRootHints::~CDnsRootHints()
  54. {
  55. }
  56. /////////////////////////////////////////////////////////////////////////////
  57. //++
  58. //
  59. // Description:
  60. // enum instances of dns roothints
  61. //
  62. // Arguments:
  63. // lFlags [IN] WMI flag
  64. // pCtx [IN] WMI context
  65. // pHandler [IN] WMI sink pointer
  66. //
  67. // Return Value:
  68. // WBEM_S_NO_ERROR
  69. //
  70. //--
  71. /////////////////////////////////////////////////////////////////////////////
  72. SCODE CDnsRootHints::EnumInstance(
  73. long lFlags,
  74. IWbemContext *pCtx,
  75. IWbemObjectSink FAR* pHandler)
  76. {
  77. CDnsWrap& dns = CDnsWrap::DnsObject();
  78. CWbemClassObject InstNew;
  79. m_pClass->SpawnInstance(0, &InstNew);
  80. InstNew.SetProperty(
  81. dns.GetServerName(),
  82. PVD_DOMAIN_SERVER_NAME);
  83. InstNew.SetProperty(
  84. PVD_DNS_ROOTHINTS,
  85. PVD_DOMAIN_FQDN);
  86. InstNew.SetProperty(
  87. PVD_DNS_ROOTHINTS,
  88. PVD_DOMAIN_CONTAINER_NAME);
  89. pHandler->Indicate(1, &InstNew);
  90. return WBEM_S_NO_ERROR;
  91. }
  92. /////////////////////////////////////////////////////////////////////////////
  93. //++
  94. //
  95. // Description:
  96. // retrieve roothints object pointed by the given object path
  97. //
  98. // Arguments:
  99. // ObjectPath [IN] object path to object
  100. // lFlags [IN] WMI flag
  101. // pCtx [IN] WMI context
  102. // pHandler [IN] WMI sink pointer
  103. //
  104. // Return Value:
  105. //--
  106. /////////////////////////////////////////////////////////////////////////////
  107. SCODE CDnsRootHints::GetObject(
  108. CObjPath& ObjectPath,
  109. long lFlags,
  110. IWbemContext *pCtx,
  111. IWbemObjectSink FAR* pHandler
  112. )
  113. {
  114. CDnsWrap& dns = CDnsWrap::DnsObject();
  115. wstring wstrServer = ObjectPath.GetStringValueForProperty(
  116. PVD_DOMAIN_SERVER_NAME);
  117. // dww - 6/14/99
  118. // Changed to make see if ValidateServerName does not return WBEM_S_NO_ERROR.
  119. //
  120. if(WBEM_S_NO_ERROR != dns.ValidateServerName(wstrServer.data()))
  121. {
  122. return WBEM_E_FAILED;
  123. }
  124. wstring wstrContainer = ObjectPath.GetStringValueForProperty(
  125. PVD_DOMAIN_CONTAINER_NAME);
  126. if(_wcsicmp(wstrContainer.data(),
  127. PVD_DNS_ROOTHINTS) == 0)
  128. {
  129. wstring wstrFQDN= ObjectPath.GetStringValueForProperty(
  130. PVD_DOMAIN_FQDN);
  131. if(_wcsicmp(wstrFQDN.data(),
  132. PVD_DNS_ROOTHINTS) == 0)
  133. {
  134. // founded
  135. CWbemClassObject Inst;
  136. m_pClass->SpawnInstance(0, &Inst);
  137. Inst.SetProperty(
  138. dns.GetServerName(),
  139. PVD_DOMAIN_SERVER_NAME);
  140. Inst.SetProperty(
  141. PVD_DNS_ROOTHINTS,
  142. PVD_DOMAIN_FQDN);
  143. Inst.SetProperty(
  144. PVD_DNS_ROOTHINTS,
  145. PVD_DOMAIN_CONTAINER_NAME);
  146. pHandler->Indicate(1, &Inst);
  147. }
  148. }
  149. return WBEM_S_NO_ERROR;
  150. }
  151. /////////////////////////////////////////////////////////////////////////////
  152. //++
  153. //
  154. // Description:
  155. // execute methods defined for roothints class in the mof
  156. //
  157. // Arguments:
  158. // ObjPath [IN] pointing to the object that the
  159. // method should be performed on
  160. // wzMethodName [IN] name of the method to be invoked
  161. // lFlags [IN] WMI flag
  162. // pInParams [IN] Input parameters for the method
  163. // pHandler [IN] WMI sink pointer
  164. //
  165. // Return Value:
  166. // WBEM_S_NO_ERROR
  167. // WBEM_E_INVALID_PARAMETER
  168. //
  169. //--
  170. /////////////////////////////////////////////////////////////////////////////
  171. SCODE CDnsRootHints::ExecuteMethod(
  172. CObjPath & ObjPath,
  173. WCHAR * wzMethodName,
  174. long lFlag,
  175. IWbemClassObject * pInArgs,
  176. IWbemObjectSink * pHandler)
  177. {
  178. CDnsWrap& dns = CDnsWrap::DnsObject();
  179. wstring wstrZoneName = ObjPath.GetStringValueForProperty(
  180. PVD_DOMAIN_CONTAINER_NAME);
  181. string strZoneName;
  182. WcharToString(wstrZoneName.data(), strZoneName);
  183. SCODE sc;
  184. if(_wcsicmp(
  185. wzMethodName,
  186. PVD_MTH_RH_WRITEBACKROOTHINTDATAFILE ) == 0)
  187. {
  188. return dns.dnsOperation(
  189. strZoneName,
  190. CDnsWrap::DNS_WRAP_WRITE_BACK_ZONE);
  191. }
  192. // dww - 6/14/99
  193. // Added the GetDistinguishedName method in the CDnsDomain class.
  194. //
  195. else if(_wcsicmp(
  196. wzMethodName,
  197. PVD_MTH_ZONE_GETDISTINGUISHEDNAME) == 0)
  198. {
  199. wstring wstrName;
  200. wstring wstrRootHints = PVD_DNS_ROOTHINTS;
  201. CWbemClassObject OutParams, OutClass, Class ;
  202. HRESULT hr;
  203. dns.dnsDsZoneName(wstrName, wstrRootHints);
  204. BSTR ClassName=NULL;
  205. ClassName = AllocBstr(PVD_CLASS_ROOTHINTS);
  206. hr = m_pNamespace->GetObject(ClassName, 0, 0, &Class, NULL);
  207. SysFreeString(ClassName);
  208. if ( SUCCEEDED ( hr ) )
  209. {
  210. Class.GetMethod(wzMethodName, 0, NULL, &OutClass);
  211. OutClass.SpawnInstance(0, &OutParams);
  212. OutParams.SetProperty(wstrName, PVD_DNS_RETURN_VALUE);
  213. hr = pHandler->Indicate(1, &OutParams);
  214. }
  215. return hr;
  216. }
  217. return S_OK;
  218. }
  219. SCODE CDnsRootHints::PutInstance(
  220. IWbemClassObject *pInst ,
  221. long lF,
  222. IWbemContext* pCtx ,
  223. IWbemObjectSink *pHandler)
  224. {
  225. return WBEM_E_NOT_SUPPORTED;
  226. };
  227. SCODE CDnsRootHints::DeleteInstance(
  228. CObjPath& ObjectPath,
  229. long lFlags,
  230. IWbemContext *pCtx,
  231. IWbemObjectSink *pResponseHandler)
  232. {
  233. return WBEM_E_NOT_SUPPORTED;
  234. }