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.

261 lines
6.9 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. if(WBEM_S_NO_ERROR != dns.ValidateServerName(wstrServer.data()))
  118. {
  119. return WBEM_E_FAILED;
  120. }
  121. wstring wstrContainer = ObjectPath.GetStringValueForProperty(
  122. PVD_DOMAIN_CONTAINER_NAME);
  123. if(_wcsicmp(wstrContainer.data(),
  124. PVD_DNS_ROOTHINTS) == 0)
  125. {
  126. wstring wstrFQDN= ObjectPath.GetStringValueForProperty(
  127. PVD_DOMAIN_FQDN);
  128. if(_wcsicmp(wstrFQDN.data(),
  129. PVD_DNS_ROOTHINTS) == 0)
  130. {
  131. // found
  132. CWbemClassObject Inst;
  133. m_pClass->SpawnInstance(0, &Inst);
  134. Inst.SetProperty(
  135. dns.GetServerName(),
  136. PVD_DOMAIN_SERVER_NAME);
  137. Inst.SetProperty(
  138. PVD_DNS_ROOTHINTS,
  139. PVD_DOMAIN_FQDN);
  140. Inst.SetProperty(
  141. PVD_DNS_ROOTHINTS,
  142. PVD_DOMAIN_CONTAINER_NAME);
  143. pHandler->Indicate(1, &Inst);
  144. }
  145. }
  146. return WBEM_S_NO_ERROR;
  147. }
  148. /////////////////////////////////////////////////////////////////////////////
  149. //++
  150. //
  151. // Description:
  152. // execute methods defined for roothints class in the mof
  153. //
  154. // Arguments:
  155. // ObjPath [IN] pointing to the object that the
  156. // method should be performed on
  157. // wzMethodName [IN] name of the method to be invoked
  158. // lFlags [IN] WMI flag
  159. // pInParams [IN] Input parameters for the method
  160. // pHandler [IN] WMI sink pointer
  161. //
  162. // Return Value:
  163. // WBEM_S_NO_ERROR
  164. // WBEM_E_INVALID_PARAMETER
  165. //
  166. //--
  167. /////////////////////////////////////////////////////////////////////////////
  168. SCODE CDnsRootHints::ExecuteMethod(
  169. CObjPath & ObjPath,
  170. WCHAR * wzMethodName,
  171. long lFlag,
  172. IWbemClassObject * pInArgs,
  173. IWbemObjectSink * pHandler)
  174. {
  175. CDnsWrap& dns = CDnsWrap::DnsObject();
  176. wstring wstrZoneName = ObjPath.GetStringValueForProperty(
  177. PVD_DOMAIN_CONTAINER_NAME);
  178. string strZoneName;
  179. WcharToString(wstrZoneName.data(), strZoneName);
  180. SCODE sc;
  181. if(_wcsicmp(
  182. wzMethodName,
  183. PVD_MTH_RH_WRITEBACKROOTHINTDATAFILE ) == 0)
  184. {
  185. return dns.dnsOperation(
  186. strZoneName,
  187. CDnsWrap::DNS_WRAP_WRITE_BACK_ZONE);
  188. }
  189. else if(_wcsicmp(
  190. wzMethodName,
  191. PVD_MTH_ZONE_GETDISTINGUISHEDNAME) == 0)
  192. {
  193. wstring wstrName;
  194. wstring wstrRootHints = PVD_DNS_ROOTHINTS;
  195. CWbemClassObject OutParams, OutClass, Class ;
  196. HRESULT hr;
  197. dns.dnsDsZoneName(wstrName, wstrRootHints);
  198. BSTR ClassName=NULL;
  199. ClassName = AllocBstr(PVD_CLASS_ROOTHINTS);
  200. hr = m_pNamespace->GetObject(ClassName, 0, 0, &Class, NULL);
  201. SysFreeString(ClassName);
  202. if ( SUCCEEDED ( hr ) )
  203. {
  204. Class.GetMethod(wzMethodName, 0, NULL, &OutClass);
  205. OutClass.SpawnInstance(0, &OutParams);
  206. OutParams.SetProperty(wstrName, PVD_DNS_RETURN_VALUE);
  207. hr = pHandler->Indicate(1, &OutParams);
  208. }
  209. return hr;
  210. }
  211. return S_OK;
  212. }
  213. SCODE CDnsRootHints::PutInstance(
  214. IWbemClassObject *pInst ,
  215. long lF,
  216. IWbemContext* pCtx ,
  217. IWbemObjectSink *pHandler)
  218. {
  219. return WBEM_E_NOT_SUPPORTED;
  220. };
  221. SCODE CDnsRootHints::DeleteInstance(
  222. CObjPath& ObjectPath,
  223. long lFlags,
  224. IWbemContext *pCtx,
  225. IWbemObjectSink *pResponseHandler)
  226. {
  227. return WBEM_E_NOT_SUPPORTED;
  228. }