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.

858 lines
19 KiB

  1. //***************************************************************************
  2. //
  3. // Copyright (c) 1998-2000 Microsoft Corporation
  4. //
  5. // OBJOBJ.CPP
  6. //
  7. // alanbos 15-Aug-96 Created.
  8. //
  9. // Defines the implementation of ISWbemObjectPath for the ISWbemObjectEx
  10. // interface
  11. //
  12. //***************************************************************************
  13. #include "precomp.h"
  14. //***************************************************************************
  15. //
  16. // CSWbemObjectObjectPath::CSWbemObjectObjectPath
  17. //
  18. // DESCRIPTION:
  19. //
  20. // Constructor.
  21. //
  22. //***************************************************************************
  23. CSWbemObjectObjectPath::CSWbemObjectObjectPath(
  24. CSWbemServices *pSWbemServices,
  25. CSWbemObject *pSObject) :
  26. m_pIWbemClassObject (NULL),
  27. m_pSWbemServices (pSWbemServices),
  28. m_pSite (NULL)
  29. {
  30. InterlockedIncrement(&g_cObj);
  31. if (pSObject)
  32. {
  33. m_pIWbemClassObject = pSObject->GetIWbemClassObject ();
  34. m_pSite = new CWbemObjectSite (pSObject);
  35. }
  36. if (m_pSWbemServices)
  37. m_pSWbemServices->AddRef ();
  38. m_pSecurity = new CSWbemObjectObjectPathSecurity (pSWbemServices);
  39. m_Dispatch.SetObj (this, IID_ISWbemObjectPath,
  40. CLSID_SWbemObjectPath, L"SWbemObjectPath");
  41. m_cRef=0;
  42. }
  43. //***************************************************************************
  44. //
  45. // CSWbemObjectObjectPath::~CSWbemObjectObjectPath
  46. //
  47. // DESCRIPTION:
  48. //
  49. // Destructor.
  50. //
  51. //***************************************************************************
  52. CSWbemObjectObjectPath::~CSWbemObjectObjectPath(void)
  53. {
  54. if (m_pSWbemServices)
  55. {
  56. m_pSWbemServices->Release ();
  57. m_pSWbemServices = NULL;
  58. }
  59. if (m_pIWbemClassObject)
  60. {
  61. m_pIWbemClassObject->Release ();
  62. m_pIWbemClassObject = NULL;
  63. }
  64. if (m_pSite)
  65. {
  66. m_pSite->Release ();
  67. m_pSite = NULL;
  68. }
  69. if (m_pSecurity)
  70. {
  71. m_pSecurity->Release ();
  72. m_pSecurity = NULL;
  73. }
  74. InterlockedDecrement(&g_cObj);
  75. }
  76. //***************************************************************************
  77. // HRESULT CSWbemObjectPath::QueryInterface
  78. // long CSWbemObjectPath::AddRef
  79. // long CSWbemObjectPath::Release
  80. //
  81. // DESCRIPTION:
  82. //
  83. // Standard Com IUNKNOWN functions.
  84. //
  85. //***************************************************************************
  86. STDMETHODIMP CSWbemObjectObjectPath::QueryInterface (
  87. IN REFIID riid,
  88. OUT LPVOID *ppv
  89. )
  90. {
  91. *ppv=NULL;
  92. if (IID_IUnknown==riid)
  93. *ppv = reinterpret_cast<IUnknown*>(this);
  94. else if (IID_ISWbemObjectPath==riid)
  95. *ppv = (ISWbemObjectPath *)this;
  96. else if (IID_IDispatch==riid)
  97. *ppv = (IDispatch *)this;
  98. else if (IID_ISupportErrorInfo==riid)
  99. *ppv = (ISupportErrorInfo *)this;
  100. else if (IID_IProvideClassInfo==riid)
  101. *ppv = (IProvideClassInfo *)this;
  102. if (NULL!=*ppv)
  103. {
  104. ((LPUNKNOWN)*ppv)->AddRef();
  105. return NOERROR;
  106. }
  107. return ResultFromScode(E_NOINTERFACE);
  108. }
  109. STDMETHODIMP_(ULONG) CSWbemObjectObjectPath::AddRef(void)
  110. {
  111. InterlockedIncrement(&m_cRef);
  112. return m_cRef;
  113. }
  114. STDMETHODIMP_(ULONG) CSWbemObjectObjectPath::Release(void)
  115. {
  116. LONG cRef = InterlockedDecrement(&m_cRef);
  117. if (0 != cRef)
  118. {
  119. _ASSERT(cRef > 0);
  120. return cRef;
  121. }
  122. delete this;
  123. return 0;
  124. }
  125. //***************************************************************************
  126. // HRESULT CSWbemObjectObjectPath::InterfaceSupportsErrorInfo
  127. //
  128. // DESCRIPTION:
  129. //
  130. // Standard Com ISupportErrorInfo functions.
  131. //
  132. //***************************************************************************
  133. STDMETHODIMP CSWbemObjectObjectPath::InterfaceSupportsErrorInfo (IN REFIID riid)
  134. {
  135. return (IID_ISWbemObjectPath == riid) ? S_OK : S_FALSE;
  136. }
  137. // Methods of ISWbemObjectPath
  138. STDMETHODIMP CSWbemObjectObjectPath::get_RelPath(
  139. /* [retval][out] */ BSTR __RPC_FAR *value)
  140. {
  141. return GetStrVal (value, WBEMS_SP_RELPATH);
  142. }
  143. STDMETHODIMP CSWbemObjectObjectPath::get_Path(
  144. /* [retval][out] */ BSTR __RPC_FAR *value)
  145. {
  146. return GetStrVal (value, WBEMS_SP_PATH);
  147. }
  148. STDMETHODIMP CSWbemObjectObjectPath::get_Server(
  149. /* [retval][out] */ BSTR __RPC_FAR *value)
  150. {
  151. return GetStrVal (value, WBEMS_SP_SERVER);
  152. }
  153. STDMETHODIMP CSWbemObjectObjectPath::get_Namespace(
  154. /* [retval][out] */ BSTR __RPC_FAR *value)
  155. {
  156. return GetStrVal (value, WBEMS_SP_NAMESPACE);
  157. }
  158. STDMETHODIMP CSWbemObjectObjectPath::get_Class(
  159. /* [retval][out] */ BSTR __RPC_FAR *value)
  160. {
  161. return GetStrVal (value, WBEMS_SP_CLASS);
  162. }
  163. STDMETHODIMP CSWbemObjectObjectPath::GetStrVal (
  164. BSTR *value,
  165. LPWSTR name)
  166. {
  167. HRESULT hr = WBEM_E_FAILED ;
  168. ResetLastErrors ();
  169. if (NULL == value)
  170. hr = WBEM_E_INVALID_PARAMETER;
  171. else
  172. {
  173. *value = NULL;
  174. if ( m_pIWbemClassObject )
  175. {
  176. VARIANT var;
  177. VariantInit (&var);
  178. if (WBEM_S_NO_ERROR == m_pIWbemClassObject->Get (name, 0, &var, NULL, NULL))
  179. {
  180. if (VT_BSTR == var.vt)
  181. {
  182. *value = SysAllocString (var.bstrVal);
  183. hr = WBEM_S_NO_ERROR;
  184. }
  185. else if (VT_NULL == var.vt)
  186. {
  187. *value = SysAllocString(OLESTR(""));
  188. hr = WBEM_S_NO_ERROR;
  189. }
  190. }
  191. VariantClear (&var);
  192. if (NULL == *value)
  193. *value = SysAllocString (OLESTR(""));
  194. }
  195. }
  196. if (FAILED(hr))
  197. m_Dispatch.RaiseException (hr);
  198. return hr;
  199. }
  200. STDMETHODIMP CSWbemObjectObjectPath::get_IsClass(
  201. /* [retval][out] */ VARIANT_BOOL __RPC_FAR *value)
  202. {
  203. HRESULT hr = WBEM_E_FAILED ;
  204. ResetLastErrors ();
  205. if (NULL == value)
  206. hr = WBEM_E_INVALID_PARAMETER;
  207. else
  208. {
  209. *value = true;
  210. if (m_pIWbemClassObject)
  211. {
  212. VARIANT var;
  213. VariantInit (&var);
  214. BSTR genus = SysAllocString (WBEMS_SP_GENUS);
  215. if (WBEM_S_NO_ERROR == m_pIWbemClassObject->Get (genus, 0, &var, NULL, NULL))
  216. {
  217. *value = (var.lVal == WBEM_GENUS_CLASS) ? VARIANT_TRUE : VARIANT_FALSE;
  218. hr = WBEM_S_NO_ERROR;
  219. }
  220. VariantClear (&var);
  221. SysFreeString (genus);
  222. }
  223. }
  224. if (FAILED(hr))
  225. m_Dispatch.RaiseException (hr);
  226. return hr;
  227. }
  228. STDMETHODIMP CSWbemObjectObjectPath::get_IsSingleton(
  229. /* [retval][out] */ VARIANT_BOOL __RPC_FAR *value)
  230. {
  231. HRESULT hr = WBEM_E_FAILED;
  232. ResetLastErrors ();
  233. if (NULL == value)
  234. hr = WBEM_E_INVALID_PARAMETER;
  235. else
  236. {
  237. BSTR path = NULL;
  238. *value = false;
  239. if (WBEM_S_NO_ERROR == get_Path (&path))
  240. {
  241. CWbemPathCracker pathCracker (path);
  242. *value = pathCracker.IsSingleton ();
  243. hr = WBEM_S_NO_ERROR;
  244. SysFreeString (path);
  245. }
  246. }
  247. if (FAILED(hr))
  248. m_Dispatch.RaiseException (hr);
  249. return hr;
  250. }
  251. STDMETHODIMP CSWbemObjectObjectPath::get_DisplayName(
  252. /* [retval][out] */ BSTR __RPC_FAR *value)
  253. {
  254. HRESULT hr = WBEM_E_FAILED;
  255. ResetLastErrors ();
  256. if (NULL == value)
  257. hr = WBEM_E_INVALID_PARAMETER;
  258. else
  259. {
  260. BSTR path = NULL;
  261. if (WBEM_S_NO_ERROR == get_Path (&path))
  262. {
  263. wchar_t *securityStr = NULL;
  264. wchar_t *localeStr = NULL;
  265. if (m_pSWbemServices)
  266. {
  267. CSWbemSecurity *pSecurity = m_pSWbemServices->GetSecurityInfo ();
  268. if (pSecurity)
  269. {
  270. BSTR bsAuthority = SysAllocString (pSecurity->GetAuthority ());
  271. enum WbemAuthenticationLevelEnum authnLevel;
  272. enum WbemImpersonationLevelEnum impLevel;
  273. if (SUCCEEDED(pSecurity->get_AuthenticationLevel (&authnLevel)) &&
  274. SUCCEEDED(pSecurity->get_ImpersonationLevel (&impLevel)))
  275. {
  276. CSWbemPrivilegeSet *pPrivilegeSet = pSecurity->GetPrivilegeSet ();
  277. if (pPrivilegeSet)
  278. {
  279. securityStr = CWbemParseDN::GetSecurityString (true, authnLevel, true,
  280. impLevel, *pPrivilegeSet, bsAuthority);
  281. pPrivilegeSet->Release ();
  282. }
  283. }
  284. SysFreeString (bsAuthority);
  285. pSecurity->Release ();
  286. }
  287. localeStr = CWbemParseDN::GetLocaleString (m_pSWbemServices->GetLocale ());
  288. }
  289. size_t len = wcslen (path) + wcslen (WBEMS_PDN_SCHEME) +
  290. ((securityStr) ? wcslen (securityStr) : 0) +
  291. ((localeStr) ? wcslen (localeStr) : 0);
  292. // If security or locale specified, and we have a path, then need a separator
  293. if ( (securityStr || localeStr) && (0 < wcslen (path)) )
  294. len += wcslen (WBEMS_EXCLAMATION);
  295. OLECHAR *displayName = new OLECHAR [len + 1];
  296. if (displayName)
  297. {
  298. wcscpy (displayName, WBEMS_PDN_SCHEME) ;
  299. if (securityStr)
  300. wcscat (displayName, securityStr);
  301. if (localeStr)
  302. wcscat (displayName, localeStr);
  303. if ( (securityStr || localeStr) && (0 < wcslen (path)) )
  304. wcscat (displayName, WBEMS_EXCLAMATION);
  305. wcscat (displayName, path) ;
  306. displayName [len] = NULL;
  307. *value = SysAllocString (displayName);
  308. delete [] displayName ;
  309. hr = WBEM_S_NO_ERROR;
  310. }
  311. else
  312. hr = WBEM_E_OUT_OF_MEMORY;
  313. if (securityStr)
  314. delete [] securityStr;
  315. if (localeStr)
  316. delete [] localeStr;
  317. SysFreeString (path);
  318. }
  319. }
  320. if (FAILED(hr))
  321. m_Dispatch.RaiseException (hr);
  322. return hr;
  323. }
  324. STDMETHODIMP CSWbemObjectObjectPath::get_ParentNamespace(
  325. /* [retval][out] */ BSTR __RPC_FAR *value)
  326. {
  327. HRESULT hr = WBEM_S_NO_ERROR;
  328. ResetLastErrors ();
  329. if (NULL == value)
  330. hr = WBEM_E_INVALID_PARAMETER;
  331. else
  332. {
  333. BSTR path = NULL;
  334. *value = NULL;
  335. if (WBEM_S_NO_ERROR == get_Path (&path))
  336. {
  337. CWbemPathCracker pathCracker (path);
  338. CComBSTR bsNsPath;
  339. if (pathCracker.GetNamespacePath (bsNsPath, true))
  340. {
  341. *value = bsNsPath.Detach ();
  342. hr = WBEM_S_NO_ERROR;
  343. }
  344. SysFreeString (path);
  345. }
  346. if (NULL == *value)
  347. *value = SysAllocString (OLESTR(""));
  348. }
  349. if (FAILED(hr))
  350. m_Dispatch.RaiseException (hr);
  351. return hr;
  352. }
  353. STDMETHODIMP CSWbemObjectObjectPath::put_Class(
  354. /* [in] */ BSTR __RPC_FAR value)
  355. {
  356. HRESULT hr = WBEM_E_FAILED ;
  357. ResetLastErrors ();
  358. if ( value && m_pIWbemClassObject )
  359. {
  360. VARIANT var;
  361. VariantInit (&var);
  362. var.vt = VT_BSTR;
  363. var.bstrVal = SysAllocString (value);
  364. BSTR className = SysAllocString (WBEMS_SP_CLASS);
  365. hr = m_pIWbemClassObject->Put (className, 0, &var, NULL);
  366. VariantClear (&var);
  367. SysFreeString (className);
  368. }
  369. if (FAILED(hr))
  370. m_Dispatch.RaiseException (hr);
  371. else
  372. {
  373. // Propagate the change to the owning site
  374. if (m_pSite)
  375. m_pSite->Update ();
  376. }
  377. return hr;
  378. }
  379. STDMETHODIMP CSWbemObjectObjectPath::get_Keys(
  380. /* [out, retval] */ ISWbemNamedValueSet **objKeys)
  381. {
  382. HRESULT hr = WBEM_E_FAILED;
  383. ResetLastErrors ();
  384. if (NULL == objKeys)
  385. hr = WBEM_E_INVALID_PARAMETER;
  386. else
  387. {
  388. *objKeys = NULL;
  389. BSTR bsPath = NULL;
  390. if (WBEM_S_NO_ERROR == get_Path (&bsPath))
  391. {
  392. CWbemPathCracker *pCWbemPathCracker = new CWbemPathCracker (bsPath);
  393. if (!pCWbemPathCracker)
  394. hr = WBEM_E_OUT_OF_MEMORY;
  395. else
  396. {
  397. CSWbemNamedValueSet *pCSWbemNamedValueSet =
  398. new CSWbemNamedValueSet (pCWbemPathCracker, false);
  399. if (!pCSWbemNamedValueSet)
  400. hr = WBEM_E_OUT_OF_MEMORY;
  401. else if (SUCCEEDED(pCSWbemNamedValueSet->QueryInterface
  402. (IID_ISWbemNamedValueSet, (PPVOID) objKeys)))
  403. hr = WBEM_S_NO_ERROR;
  404. else
  405. delete pCSWbemNamedValueSet;
  406. }
  407. SysFreeString (bsPath);
  408. }
  409. }
  410. if (FAILED(hr))
  411. m_Dispatch.RaiseException (hr);
  412. return hr;
  413. }
  414. STDMETHODIMP CSWbemObjectObjectPath::get_Security_(
  415. /* [out, retval] */ ISWbemSecurity **objSecurity)
  416. {
  417. HRESULT hr = WBEM_E_FAILED;
  418. ResetLastErrors ();
  419. if (objSecurity)
  420. {
  421. *objSecurity = m_pSecurity;
  422. m_pSecurity->AddRef ();
  423. hr = WBEM_S_NO_ERROR;
  424. }
  425. if (FAILED(hr))
  426. m_Dispatch.RaiseException (hr);
  427. return hr;
  428. }
  429. STDMETHODIMP CSWbemObjectObjectPath::get_Locale(
  430. /* [retval][out] */ BSTR __RPC_FAR *value)
  431. {
  432. HRESULT t_Result = WBEM_E_FAILED ;
  433. ResetLastErrors ();
  434. if ( value )
  435. {
  436. if (m_pSWbemServices)
  437. *value = SysAllocString (m_pSWbemServices->GetLocale ()) ;
  438. else
  439. *value = SysAllocString (OLESTR(""));
  440. t_Result = S_OK ;
  441. }
  442. if (FAILED(t_Result))
  443. m_Dispatch.RaiseException (t_Result);
  444. return t_Result ;
  445. }
  446. STDMETHODIMP CSWbemObjectObjectPath::get_Authority(
  447. /* [retval][out] */ BSTR __RPC_FAR *value)
  448. {
  449. HRESULT t_Result = WBEM_E_FAILED ;
  450. ResetLastErrors ();
  451. if ( value )
  452. {
  453. if (m_pSecurity)
  454. *value = SysAllocString (m_pSecurity->GetAuthority ()) ;
  455. else
  456. *value = SysAllocString (OLESTR(""));
  457. t_Result = S_OK ;
  458. }
  459. if (FAILED(t_Result))
  460. m_Dispatch.RaiseException (t_Result);
  461. return t_Result ;
  462. }
  463. // CSWbemObjectObjectPathSecurity methods
  464. //***************************************************************************
  465. //
  466. // CSWbemObjectObjectPathSecurity::CSWbemObjectObjectPathSecurity
  467. //
  468. // DESTRUCTOR
  469. //
  470. //***************************************************************************
  471. CSWbemObjectObjectPathSecurity::CSWbemObjectObjectPathSecurity (
  472. CSWbemServices *pSWbemServices
  473. ) : m_pPrivilegeSet (NULL),
  474. m_bsAuthority (NULL)
  475. {
  476. m_Dispatch.SetObj (this, IID_ISWbemSecurity,
  477. CLSID_SWbemSecurity, L"SWbemSecurity");
  478. m_cRef=1;
  479. InterlockedIncrement(&g_cObj);
  480. if (pSWbemServices)
  481. {
  482. CSWbemSecurity *pSecurity = pSWbemServices->GetSecurityInfo ();
  483. if (pSecurity)
  484. {
  485. // Set up authn and imp levels
  486. pSecurity->get_AuthenticationLevel (&m_dwAuthnLevel);
  487. pSecurity->get_ImpersonationLevel (&m_dwImpLevel);
  488. // Set up authority
  489. m_bsAuthority = SysAllocString (pSecurity->GetAuthority ());
  490. // Set up privileges
  491. CSWbemPrivilegeSet *pPrivilegeSet = pSecurity->GetPrivilegeSet ();
  492. if (pPrivilegeSet)
  493. {
  494. // Note we mark the privilege set as immutable
  495. m_pPrivilegeSet = new CSWbemPrivilegeSet (*pPrivilegeSet, false);
  496. pPrivilegeSet->Release ();
  497. }
  498. pSecurity->Release ();
  499. }
  500. }
  501. }
  502. //***************************************************************************
  503. //
  504. // CSWbemObjectObjectPathSecurity::~CSWbemObjectObjectPathSecurity
  505. //
  506. // DESTRUCTOR
  507. //
  508. //***************************************************************************
  509. CSWbemObjectObjectPathSecurity::~CSWbemObjectObjectPathSecurity (void)
  510. {
  511. InterlockedDecrement(&g_cObj);
  512. if (m_pPrivilegeSet)
  513. {
  514. m_pPrivilegeSet->Release ();
  515. m_pPrivilegeSet = NULL;
  516. }
  517. if (m_bsAuthority)
  518. {
  519. SysFreeString (m_bsAuthority);
  520. m_bsAuthority = NULL;
  521. }
  522. }
  523. //***************************************************************************
  524. // HRESULT CSWbemObjectObjectPathSecurity::QueryInterface
  525. // long CSWbemObjectObjectPathSecurity::AddRef
  526. // long CSWbemObjectObjectPathSecurity::Release
  527. //
  528. // DESCRIPTION:
  529. //
  530. // Standard Com IUNKNOWN functions.
  531. //
  532. //***************************************************************************
  533. STDMETHODIMP CSWbemObjectObjectPathSecurity::QueryInterface (
  534. IN REFIID riid,
  535. OUT LPVOID *ppv
  536. )
  537. {
  538. *ppv=NULL;
  539. if (IID_IUnknown==riid)
  540. *ppv = reinterpret_cast<IUnknown*>(this);
  541. else if (IID_ISWbemSecurity==riid)
  542. *ppv = (ISWbemSecurity *)this;
  543. else if (IID_IDispatch==riid)
  544. *ppv = (IDispatch *)this;
  545. else if (IID_ISupportErrorInfo==riid)
  546. *ppv = (ISupportErrorInfo *) this;
  547. else if (IID_IProvideClassInfo==riid)
  548. *ppv = (IProvideClassInfo *)this;
  549. if (NULL!=*ppv)
  550. {
  551. ((LPUNKNOWN)*ppv)->AddRef();
  552. return NOERROR;
  553. }
  554. return ResultFromScode(E_NOINTERFACE);
  555. }
  556. STDMETHODIMP_(ULONG) CSWbemObjectObjectPathSecurity::AddRef(void)
  557. {
  558. long l = InterlockedIncrement(&m_cRef);
  559. return l;
  560. }
  561. STDMETHODIMP_(ULONG) CSWbemObjectObjectPathSecurity::Release(void)
  562. {
  563. LONG cRef = InterlockedDecrement(&m_cRef);
  564. if (0 != cRef)
  565. {
  566. _ASSERT(cRef > 0);
  567. return cRef;
  568. }
  569. delete this;
  570. return 0;
  571. }
  572. //***************************************************************************
  573. // HRESULT CSWbemObjectObjectPathSecurity::InterfaceSupportsErrorInfo
  574. //
  575. // DESCRIPTION:
  576. //
  577. // Standard Com ISupportErrorInfo functions.
  578. //
  579. //***************************************************************************
  580. STDMETHODIMP CSWbemObjectObjectPathSecurity::InterfaceSupportsErrorInfo (IN REFIID riid)
  581. {
  582. return (IID_ISWbemSecurity == riid) ? S_OK : S_FALSE;
  583. }
  584. //***************************************************************************
  585. //
  586. // SCODE CSWbemObjectObjectPathSecurity::get_AuthenticationLevel
  587. //
  588. // DESCRIPTION:
  589. //
  590. // Retrieve the authentication level
  591. //
  592. // PARAMETERS:
  593. //
  594. // pAuthenticationLevel holds the value on return
  595. //
  596. // RETURN VALUES:
  597. //
  598. // WBEM_S_NO_ERROR success
  599. // WBEM_E_INVALID_PARAMETER bad input parameters
  600. // WBEM_E_FAILED otherwise
  601. //
  602. //***************************************************************************
  603. HRESULT CSWbemObjectObjectPathSecurity::get_AuthenticationLevel (
  604. WbemAuthenticationLevelEnum *pAuthenticationLevel
  605. )
  606. {
  607. HRESULT hr = WBEM_E_FAILED;
  608. ResetLastErrors ();
  609. if (NULL == pAuthenticationLevel)
  610. hr = WBEM_E_INVALID_PARAMETER;
  611. else
  612. {
  613. *pAuthenticationLevel = m_dwAuthnLevel;
  614. hr = WBEM_S_NO_ERROR;
  615. }
  616. if (FAILED(hr))
  617. m_Dispatch.RaiseException (hr);
  618. return hr;
  619. }
  620. //***************************************************************************
  621. //
  622. // SCODE CSWbemObjectObjectPathSecurity::get_ImpersonationLevel
  623. //
  624. // DESCRIPTION:
  625. //
  626. // Retrieve the impersonation level
  627. //
  628. // PARAMETERS:
  629. //
  630. // pImpersonationLevel holds the value on return
  631. //
  632. // RETURN VALUES:
  633. //
  634. // WBEM_S_NO_ERROR success
  635. // WBEM_E_INVALID_PARAMETER bad input parameters
  636. // WBEM_E_FAILED otherwise
  637. //
  638. //***************************************************************************
  639. HRESULT CSWbemObjectObjectPathSecurity::get_ImpersonationLevel (
  640. WbemImpersonationLevelEnum *pImpersonationLevel
  641. )
  642. {
  643. HRESULT hr = WBEM_E_FAILED;
  644. ResetLastErrors ();
  645. if (NULL == pImpersonationLevel)
  646. hr = WBEM_E_INVALID_PARAMETER;
  647. else
  648. {
  649. *pImpersonationLevel = m_dwImpLevel;
  650. hr = WBEM_S_NO_ERROR;
  651. }
  652. if (FAILED(hr))
  653. m_Dispatch.RaiseException (hr);
  654. return hr;
  655. }
  656. //***************************************************************************
  657. //
  658. // SCODE CSWbemObjectObjectPathSecurity::get_Privileges
  659. //
  660. // DESCRIPTION:
  661. //
  662. // Return the Privilege override set
  663. //
  664. // WBEM_S_NO_ERROR success
  665. // WBEM_E_INVALID_PARAMETER bad input parameters
  666. // WBEM_E_FAILED otherwise
  667. //
  668. //***************************************************************************
  669. HRESULT CSWbemObjectObjectPathSecurity::get_Privileges (
  670. ISWbemPrivilegeSet **ppPrivileges
  671. )
  672. {
  673. HRESULT hr = WBEM_E_FAILED;
  674. ResetLastErrors ();
  675. if (NULL == ppPrivileges)
  676. hr = WBEM_E_INVALID_PARAMETER;
  677. else // Bug ID 566345
  678. {
  679. *ppPrivileges = NULL;
  680. if (m_pPrivilegeSet)
  681. {
  682. if (SUCCEEDED (m_pPrivilegeSet->QueryInterface (IID_ISWbemPrivilegeSet,
  683. (PPVOID) ppPrivileges)))
  684. hr = WBEM_S_NO_ERROR;
  685. }
  686. }
  687. if (FAILED(hr))
  688. m_Dispatch.RaiseException (hr);
  689. return hr;
  690. }