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.

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