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.

740 lines
19 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1999
  5. //
  6. // File: officer.cpp
  7. //
  8. // Contents: officer rights implementation
  9. //
  10. //---------------------------------------------------------------------------
  11. #include <pch.cpp>
  12. #pragma hdrstop
  13. #include <certsd.h>
  14. #include <certacl.h>
  15. #include <sid.h>
  16. #define __dwFILE__ __dwFILE_CERTLIB_OFFICER_CPP__
  17. using namespace CertSrv;
  18. HRESULT
  19. COfficerRightsSD::Merge(
  20. PSECURITY_DESCRIPTOR pOfficerSD,
  21. PSECURITY_DESCRIPTOR pCASD)
  22. {
  23. HRESULT hr;
  24. PACL pCAAcl; // no free
  25. PACL pOfficerAcl; // no free
  26. PACL pNewOfficerAcl = NULL;
  27. ACL_SIZE_INFORMATION CAAclInfo, OfficerAclInfo;
  28. PBOOL pCAFound = NULL, pOfficerFound = NULL;
  29. DWORD cCAAce, cOfficerAce;
  30. PACCESS_ALLOWED_ACE pCAAce;
  31. PACCESS_ALLOWED_CALLBACK_ACE pOfficerAce;
  32. PACCESS_ALLOWED_CALLBACK_ACE pNewAce = NULL;
  33. DWORD dwNewAclSize = sizeof(ACL);
  34. PSID pSidEveryone = NULL, pSidBuiltinAdministrators = NULL;
  35. DWORD dwSidEveryoneSize, dwAceSize, dwSidSize;
  36. PSID_LIST pSidList;
  37. PSECURITY_DESCRIPTOR pNewOfficerSD = NULL;
  38. ACL EmptyAcl;
  39. SECURITY_DESCRIPTOR EmptySD;
  40. CSASSERT(NULL==pOfficerSD || IsValidSecurityDescriptor(pOfficerSD));
  41. CSASSERT(IsValidSecurityDescriptor(pCASD));
  42. // allow NULL officer SD, in that case build an empty SD and use it
  43. if(NULL==pOfficerSD)
  44. {
  45. if(!InitializeAcl(&EmptyAcl, sizeof(ACL), ACL_REVISION))
  46. {
  47. hr = myHLastError();
  48. _JumpError(hr, error, "InitializeAcl");
  49. }
  50. if (!InitializeSecurityDescriptor(&EmptySD, SECURITY_DESCRIPTOR_REVISION))
  51. {
  52. hr = myHLastError();
  53. _JumpError(hr, error, "InitializeSecurityDescriptor");
  54. }
  55. if(!SetSecurityDescriptorDacl(
  56. &EmptySD,
  57. TRUE, // DACL present
  58. &EmptyAcl,
  59. FALSE)) // DACL defaulted
  60. {
  61. hr = myHLastError();
  62. _JumpError(hr, error, "SetSecurityDescriptorControl");
  63. }
  64. pOfficerSD = &EmptySD;
  65. }
  66. hr = myGetSecurityDescriptorDacl(pCASD, &pCAAcl);
  67. _JumpIfError(hr, error, "myGetSecurityDescriptorDacl");
  68. hr = myGetSecurityDescriptorDacl(pOfficerSD, &pOfficerAcl);
  69. _JumpIfError(hr, error, "myGetSecurityDescriptorDacl");
  70. // allocate a bool array for each DACL
  71. if(!GetAclInformation(pCAAcl,
  72. &CAAclInfo,
  73. sizeof(CAAclInfo),
  74. AclSizeInformation))
  75. {
  76. hr = myHLastError();
  77. _JumpError(hr, error, "GetAclInformation");
  78. }
  79. if(!GetAclInformation(pOfficerAcl,
  80. &OfficerAclInfo,
  81. sizeof(OfficerAclInfo),
  82. AclSizeInformation))
  83. {
  84. hr = myHLastError();
  85. _JumpError(hr, error, "GetAclInformation");
  86. }
  87. pCAFound = (PBOOL)LocalAlloc(LMEM_FIXED, sizeof(BOOL)*CAAclInfo.AceCount);
  88. if(!pCAFound)
  89. {
  90. hr = E_OUTOFMEMORY;
  91. _JumpError(hr, error, "LocalAlloc");
  92. }
  93. ZeroMemory(pCAFound, sizeof(BOOL)*CAAclInfo.AceCount);
  94. pOfficerFound = (PBOOL)LocalAlloc(LMEM_FIXED, sizeof(BOOL)*OfficerAclInfo.AceCount);
  95. if(!pOfficerFound)
  96. {
  97. hr = E_OUTOFMEMORY;
  98. _JumpError(hr, error, "LocalAlloc");
  99. }
  100. ZeroMemory(pOfficerFound, sizeof(BOOL)*OfficerAclInfo.AceCount);
  101. hr = GetEveryoneSID(&pSidEveryone);
  102. _JumpIfError(hr, error, "GetEveryoneSID");
  103. dwSidEveryoneSize = GetLengthSid(pSidEveryone);
  104. // mark in the bool arrays each ace whose SID is found in both DACLs;
  105. // also mark CA ACEs we are not interested in (denied ACEs and
  106. // non-officer ACEs)
  107. for(cCAAce=0; cCAAce<CAAclInfo.AceCount; cCAAce++)
  108. {
  109. if(!GetAce(pCAAcl, cCAAce, (PVOID*)&pCAAce))
  110. {
  111. hr = myHLastError();
  112. _JumpError(hr, error, "GetAce");
  113. }
  114. // process only officer allow aces
  115. if(0==(pCAAce->Mask & CA_ACCESS_OFFICER))
  116. {
  117. pCAFound[cCAAce] = TRUE;
  118. continue;
  119. }
  120. // compare SIDs in each officer ace with current CA ace and mark
  121. // corresponding bool in arrays if equal
  122. for(cOfficerAce=0; cOfficerAce<OfficerAclInfo.AceCount; cOfficerAce++)
  123. {
  124. if(!GetAce(pOfficerAcl, cOfficerAce, (PVOID*)&pOfficerAce))
  125. {
  126. hr = myHLastError();
  127. _JumpError(hr, error, "GetAce");
  128. }
  129. if(EqualSid((PSID)&pOfficerAce->SidStart,
  130. (PSID)&pCAAce->SidStart))
  131. {
  132. pCAFound[cCAAce] = TRUE;
  133. pOfficerFound[cOfficerAce] = TRUE;
  134. }
  135. }
  136. // if the officer is found in the CA ACL but not in the officer ACL,
  137. // we will add a new ACE allowing him to manage certs for Everyone
  138. if(!pCAFound[cCAAce])
  139. {
  140. dwNewAclSize += sizeof(ACCESS_ALLOWED_CALLBACK_ACE)+
  141. GetLengthSid((PSID)&pCAAce->SidStart)+
  142. dwSidEveryoneSize;
  143. }
  144. }
  145. // Calculate the size of the new officer ACL; we already added in the header
  146. // size and the size of the new ACEs to be added. Now we add the ACEs to be
  147. // copied over from the old ACL
  148. for(cOfficerAce=0; cOfficerAce<OfficerAclInfo.AceCount; cOfficerAce++)
  149. {
  150. if(pOfficerFound[cOfficerAce])
  151. {
  152. if(!GetAce(pOfficerAcl, cOfficerAce, (PVOID*)&pOfficerAce))
  153. {
  154. hr = myHLastError();
  155. _JumpError(hr, error, "GetAce");
  156. }
  157. dwNewAclSize += pOfficerAce->Header.AceSize;
  158. }
  159. }
  160. // allocate a new DACL
  161. pNewOfficerAcl = (PACL)LocalAlloc(LMEM_FIXED, dwNewAclSize);
  162. if(!pNewOfficerAcl)
  163. {
  164. hr = E_OUTOFMEMORY;
  165. _JumpError(hr, error, "LocalAlloc");
  166. }
  167. #ifdef _DEBUG
  168. ZeroMemory(pNewOfficerAcl, dwNewAclSize);
  169. #endif
  170. if(!InitializeAcl(pNewOfficerAcl, dwNewAclSize, ACL_REVISION))
  171. {
  172. hr = myHLastError();
  173. _JumpError(hr, error, "InitializeAcl");
  174. }
  175. // build the new DACL
  176. // traverse officer DACL and add only marked ACEs (whose SID was found
  177. // in the CA DACL, ie principal is an officer)
  178. for(cOfficerAce=0; cOfficerAce<OfficerAclInfo.AceCount; cOfficerAce++)
  179. {
  180. if(pOfficerFound[cOfficerAce])
  181. {
  182. if(!GetAce(pOfficerAcl, cOfficerAce, (PVOID*)&pOfficerAce))
  183. {
  184. hr = myHLastError();
  185. _JumpError(hr, error, "GetAce");
  186. }
  187. if(!AddAce(
  188. pNewOfficerAcl,
  189. ACL_REVISION,
  190. MAXDWORD,
  191. pOfficerAce,
  192. pOfficerAce->Header.AceSize))
  193. {
  194. hr = myHLastError();
  195. _JumpError(hr, error, "GetAce");
  196. }
  197. }
  198. }
  199. CSASSERT(IsValidAcl(pNewOfficerAcl));
  200. hr = GetBuiltinAdministratorsSID(&pSidBuiltinAdministrators);
  201. _JumpIfError(hr, error, "GetBuiltinAdministratorsSID");
  202. // traverse the CA DACL and add a new officer to list, allowed to manage
  203. // Everyone
  204. for(cCAAce=0; cCAAce<CAAclInfo.AceCount; cCAAce++)
  205. {
  206. if(pCAFound[cCAAce])
  207. continue;
  208. if(!GetAce(pCAAcl, cCAAce, (PVOID*)&pCAAce))
  209. {
  210. hr = myHLastError();
  211. _JumpError(hr, error, "GetAce");
  212. }
  213. // create a new ACE
  214. dwSidSize = GetLengthSid((PSID)&pCAAce->SidStart);
  215. dwAceSize = sizeof(ACCESS_ALLOWED_CALLBACK_ACE)+
  216. dwSidEveryoneSize+dwSidSize;
  217. pNewAce = (ACCESS_ALLOWED_CALLBACK_ACE*) LocalAlloc(LMEM_FIXED, dwAceSize);
  218. if(!pNewAce)
  219. {
  220. hr = E_OUTOFMEMORY;
  221. _JumpError(hr, error, "LocalAlloc");
  222. }
  223. #ifdef _DEBUG
  224. ZeroMemory(pNewAce, dwAceSize);
  225. #endif
  226. pNewAce->Header.AceType = ACCESS_ALLOWED_CALLBACK_ACE_TYPE;
  227. pNewAce->Header.AceFlags= 0;
  228. pNewAce->Header.AceSize = (USHORT)dwAceSize;
  229. pNewAce->Mask = DELETE;
  230. CopySid(dwSidSize,
  231. (PSID)&pNewAce->SidStart,
  232. (PSID)&pCAAce->SidStart);
  233. pSidList = (PSID_LIST)(((BYTE*)&pNewAce->SidStart)+dwSidSize);
  234. pSidList->dwSidCount = 1;
  235. CopySid(dwSidEveryoneSize,
  236. (PSID)&pSidList->SidListStart,
  237. pSidEveryone);
  238. CSASSERT(IsValidSid((PSID)&pNewAce->SidStart));
  239. if(!AddAce(
  240. pNewOfficerAcl,
  241. ACL_REVISION,
  242. MAXDWORD,
  243. pNewAce,
  244. dwAceSize))
  245. {
  246. hr = myHLastError();
  247. _JumpError(hr, error, "AddAce");
  248. }
  249. LocalFree(pNewAce);
  250. pNewAce = NULL;
  251. }
  252. CSASSERT(IsValidAcl(pNewOfficerAcl));
  253. // setup the new security descriptor
  254. pNewOfficerSD = (PSECURITY_DESCRIPTOR)LocalAlloc(LMEM_FIXED,
  255. SECURITY_DESCRIPTOR_MIN_LENGTH);
  256. if (pNewOfficerSD == NULL)
  257. {
  258. hr = E_OUTOFMEMORY;
  259. _JumpError(hr, error, "LocalAlloc");
  260. }
  261. #ifdef _DEBUG
  262. ZeroMemory(pNewOfficerSD, SECURITY_DESCRIPTOR_MIN_LENGTH);
  263. #endif
  264. if (!InitializeSecurityDescriptor(pNewOfficerSD, SECURITY_DESCRIPTOR_REVISION))
  265. {
  266. hr = myHLastError();
  267. _JumpError(hr, error, "InitializeSecurityDescriptor");
  268. }
  269. if(!SetSecurityDescriptorOwner(
  270. pNewOfficerSD,
  271. pSidBuiltinAdministrators,
  272. FALSE))
  273. {
  274. hr = myHLastError();
  275. _JumpError(hr, error, "SetSecurityDescriptorControl");
  276. }
  277. if(!SetSecurityDescriptorDacl(
  278. pNewOfficerSD,
  279. TRUE, // DACL present
  280. pNewOfficerAcl,
  281. FALSE)) // DACL defaulted
  282. {
  283. hr = myHLastError();
  284. _JumpError(hr, error, "SetSecurityDescriptorDacl");
  285. }
  286. CSASSERT(IsValidSecurityDescriptor(pNewOfficerSD));
  287. hr = Set(pNewOfficerSD);
  288. _JumpIfError(hr, error, "CProtectedSecurityDescriptor::Set");
  289. error:
  290. if(pNewAce)
  291. {
  292. LocalFree(pNewAce);
  293. }
  294. if(pSidEveryone)
  295. {
  296. FreeSid(pSidEveryone);
  297. }
  298. if(pSidBuiltinAdministrators)
  299. {
  300. FreeSid(pSidBuiltinAdministrators);
  301. }
  302. if(pNewOfficerAcl)
  303. {
  304. LocalFree(pNewOfficerAcl);
  305. }
  306. if(pNewOfficerSD)
  307. {
  308. LocalFree(pNewOfficerSD);
  309. }
  310. return hr;
  311. }
  312. HRESULT
  313. COfficerRightsSD::Adjust(PSECURITY_DESCRIPTOR pCASD)
  314. {
  315. return Merge(Get(), pCASD);
  316. }
  317. HRESULT
  318. COfficerRightsSD::InitializeEmpty()
  319. {
  320. HRESULT hr = S_OK;
  321. ACL Acl;
  322. SECURITY_DESCRIPTOR SD;
  323. hr = Init(NULL);
  324. _JumpIfError(hr, error, "CProtectedSecurityDescriptor::Init");
  325. if(!InitializeAcl(&Acl, sizeof(ACL), ACL_REVISION))
  326. {
  327. hr = myHLastError();
  328. _JumpError(hr, error, "InitializeAcl");
  329. }
  330. if (!InitializeSecurityDescriptor(&SD, SECURITY_DESCRIPTOR_REVISION))
  331. {
  332. hr = myHLastError();
  333. _JumpError(hr, error, "InitializeSecurityDescriptor");
  334. }
  335. if(!SetSecurityDescriptorDacl(
  336. &SD,
  337. TRUE, // DACL present
  338. &Acl,
  339. FALSE)) // DACL defaulted
  340. {
  341. hr = myHLastError();
  342. _JumpError(hr, error, "SetSecurityDescriptorControl");
  343. }
  344. m_fInitialized = true;
  345. hr = Set(&SD);
  346. _JumpIfError(hr, error, "CProtectedSecurityDescriptor::Set");
  347. error:
  348. return hr;
  349. }
  350. HRESULT COfficerRightsSD::Save()
  351. {
  352. HRESULT hr = S_OK;
  353. if(IsEnabled())
  354. {
  355. hr = CProtectedSecurityDescriptor::Save();
  356. _JumpIfError(hr, error, "CProtectedSecurityDescriptor::Save");
  357. }
  358. else
  359. {
  360. hr = CProtectedSecurityDescriptor::Delete();
  361. _JumpIfError(hr, error, "CProtectedSecurityDescriptor::Delete");
  362. }
  363. error:
  364. return hr;
  365. }
  366. HRESULT COfficerRightsSD::Load()
  367. {
  368. HRESULT hr;
  369. hr = CProtectedSecurityDescriptor::Load();
  370. if(S_OK==hr || HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)==hr)
  371. {
  372. SetEnable(S_OK==hr);
  373. hr = S_OK;
  374. }
  375. _JumpIfError(hr, error, "CProtectedSecurityDescriptor::Save");
  376. error:
  377. return hr;
  378. }
  379. HRESULT COfficerRightsSD::Initialize(LPCWSTR pwszSanitizedName)
  380. {
  381. HRESULT hr;
  382. hr = CProtectedSecurityDescriptor::Initialize(pwszSanitizedName);
  383. _JumpIfError(hr, error, "CProtectedSecurityDescriptor::Save");
  384. SetEnable(NULL!=m_pSD);
  385. error:
  386. return hr;
  387. }
  388. HRESULT COfficerRightsSD::ConvertToString(
  389. IN PSECURITY_DESCRIPTOR pSD,
  390. OUT LPWSTR& rpwszSD)
  391. {
  392. HRESULT hr = S_OK;
  393. LPCWSTR pcwszHeader = L"\n"; // start with a new line
  394. DWORD dwBufSize = sizeof(WCHAR)*(wcslen(pcwszHeader)+1);
  395. ACL_SIZE_INFORMATION AclInfo;
  396. DWORD dwIndex;
  397. PACCESS_ALLOWED_CALLBACK_ACE pAce; // no free
  398. PACL pDacl; // no free
  399. LPWSTR pwszAce; // no free
  400. CSASSERT(IsValidSecurityDescriptor(pSD));
  401. rpwszSD = NULL;
  402. // get acl
  403. hr = myGetSecurityDescriptorDacl(
  404. pSD,
  405. &pDacl);
  406. _JumpIfError(hr, error, "myGetDaclFromInfoSecurityDescriptor");
  407. if(!GetAclInformation(pDacl,
  408. &AclInfo,
  409. sizeof(ACL_SIZE_INFORMATION),
  410. AclSizeInformation))
  411. {
  412. hr = myHLastError();
  413. _JumpError(hr, error, "GetAclInformation");
  414. }
  415. // calculate text size
  416. for(dwIndex = 0; dwIndex < AclInfo.AceCount; dwIndex++)
  417. {
  418. DWORD dwAceSize;
  419. if(!GetAce(pDacl, dwIndex, (LPVOID*)&pAce))
  420. {
  421. hr = myHLastError();
  422. _JumpError(hr, error, "GetAce");
  423. }
  424. hr = ConvertAceToString(
  425. pAce,
  426. &dwAceSize,
  427. NULL);
  428. _JumpIfError(hr, error, "ConvertAceToString");
  429. dwBufSize += dwAceSize;
  430. }
  431. rpwszSD = (LPWSTR)LocalAlloc(LMEM_FIXED, dwBufSize);
  432. _JumpIfAllocFailed(rpwszSD, error);
  433. // build the output string
  434. wcscpy(rpwszSD, pcwszHeader);
  435. pwszAce = rpwszSD + wcslen(pcwszHeader);
  436. for(dwIndex = 0; dwIndex < AclInfo.AceCount; dwIndex++)
  437. {
  438. DWORD dwAceSize;
  439. if(!GetAce(pDacl, dwIndex, (LPVOID*)&pAce))
  440. {
  441. hr = myHLastError();
  442. _JumpError(hr, error, "GetAce");
  443. }
  444. hr = ConvertAceToString(
  445. pAce,
  446. &dwAceSize,
  447. pwszAce);
  448. _JumpIfError(hr, error, "ConvertAceToString");
  449. pwszAce += dwAceSize/sizeof(WCHAR);
  450. }
  451. error:
  452. return hr;
  453. }
  454. // Returned string has the following format:
  455. //
  456. // [Allow|Deny]\t[OfficerName|SID]\n
  457. // \t[Client1Name|SID]\n
  458. // \t[Client2Name|SID]\n
  459. // ...
  460. //
  461. // Example:
  462. //
  463. // Allow OfficerGroup1
  464. // ClientGroup1
  465. // ClientGroup2
  466. //
  467. // If SID cannot be converted to friendly name it is displayed
  468. // as a string SID
  469. //
  470. HRESULT COfficerRightsSD::ConvertAceToString(
  471. IN PACCESS_ALLOWED_CALLBACK_ACE pAce,
  472. OUT OPTIONAL PDWORD pdwSize,
  473. IN OUT OPTIONAL LPWSTR pwszSD)
  474. {
  475. HRESULT hr = S_OK;
  476. DWORD dwSize = 1; // trailing '\0'
  477. CSid sid((PSID)(&pAce->SidStart));
  478. PSID_LIST pSidList = (PSID_LIST) (((BYTE*)&pAce->SidStart)+
  479. GetLengthSid(&pAce->SidStart));
  480. PSID pSid;
  481. DWORD cSids;
  482. LPCWSTR pcwszAllow = m_pcwszResources[0];
  483. LPCWSTR pcwszDeny = m_pcwszResources[1];
  484. LPCWSTR pcwszPermissionType =
  485. (ACCESS_ALLOWED_CALLBACK_ACE_TYPE==pAce->Header.AceType)?
  486. pcwszAllow:pcwszDeny;
  487. LPCWSTR pcwszSid; // no free
  488. // asked for size and/or ace string
  489. CSASSERT(pdwSize || pwszSD);
  490. if(pAce->Header.AceType != ACCESS_ALLOWED_CALLBACK_ACE_TYPE &&
  491. pAce->Header.AceType != ACCESS_DENIED_CALLBACK_ACE_TYPE)
  492. {
  493. return E_INVALIDARG;
  494. }
  495. pcwszSid = sid.GetName();
  496. if(!pcwszSid)
  497. {
  498. return E_OUTOFMEMORY;
  499. }
  500. dwSize = wcslen(pcwszSid);
  501. dwSize += wcslen(pcwszPermissionType);
  502. dwSize += 2; // '\t' between sid an permission and a '\n' after
  503. if(pwszSD)
  504. {
  505. wcscat(pwszSD, pcwszPermissionType);
  506. wcscat(pwszSD, L"\t");
  507. wcscat(pwszSD, pcwszSid);
  508. wcscat(pwszSD, L"\n");
  509. }
  510. for(pSid=(PSID)&pSidList->SidListStart, cSids=0; cSids<pSidList->dwSidCount;
  511. cSids++, pSid = (PSID)(((BYTE*)pSid)+GetLengthSid(pSid)))
  512. {
  513. CSASSERT(IsValidSid(pSid));
  514. CSid sidClient(pSid);
  515. LPCWSTR pcwszSidClient;
  516. pcwszSidClient = sidClient.GetName();
  517. if(!pcwszSidClient)
  518. {
  519. return E_OUTOFMEMORY;
  520. }
  521. dwSize += wcslen(pcwszSidClient) + 2; // \tClientNameOrSid\n
  522. if(pwszSD)
  523. {
  524. wcscat(pwszSD, L"\t");
  525. wcscat(pwszSD, pcwszSidClient);
  526. wcscat(pwszSD, L"\n");
  527. }
  528. }
  529. dwSize *= sizeof(WCHAR);
  530. if(pdwSize)
  531. {
  532. *pdwSize = dwSize;
  533. }
  534. return hr;
  535. }
  536. HRESULT
  537. CertSrv::GetWellKnownSID(
  538. PSID *ppSid,
  539. SID_IDENTIFIER_AUTHORITY *pAuth,
  540. BYTE SubauthorityCount,
  541. DWORD SubAuthority1,
  542. DWORD SubAuthority2,
  543. DWORD SubAuthority3,
  544. DWORD SubAuthority4,
  545. DWORD SubAuthority5,
  546. DWORD SubAuthority6,
  547. DWORD SubAuthority7,
  548. DWORD SubAuthority8)
  549. {
  550. HRESULT hr = S_OK;
  551. // build Everyone SID
  552. if(!AllocateAndInitializeSid(
  553. pAuth,
  554. SubauthorityCount,
  555. SubAuthority1,
  556. SubAuthority2,
  557. SubAuthority3,
  558. SubAuthority4,
  559. SubAuthority5,
  560. SubAuthority6,
  561. SubAuthority7,
  562. SubAuthority8,
  563. ppSid))
  564. {
  565. hr = myHLastError();
  566. _JumpError(hr, error, "AllocateAndInitializeSid");
  567. }
  568. error:
  569. return hr;
  570. }
  571. // caller is responsible for LocalFree'ing PSID
  572. HRESULT CertSrv::GetEveryoneSID(PSID *ppSid)
  573. {
  574. SID_IDENTIFIER_AUTHORITY SIDAuth = SECURITY_WORLD_SID_AUTHORITY;
  575. return GetWellKnownSID(
  576. ppSid,
  577. &SIDAuth,
  578. 1,
  579. SECURITY_WORLD_RID);
  580. }
  581. // caller is responsible for LocalFree'ing PSID
  582. HRESULT CertSrv::GetLocalSystemSID(PSID *ppSid)
  583. {
  584. SID_IDENTIFIER_AUTHORITY SIDAuth = SECURITY_NT_AUTHORITY;
  585. return GetWellKnownSID(
  586. ppSid,
  587. &SIDAuth,
  588. 1,
  589. SECURITY_LOCAL_SYSTEM_RID);
  590. }
  591. // caller is responsible for LocalFree'ing PSID
  592. HRESULT CertSrv::GetBuiltinAdministratorsSID(PSID *ppSid)
  593. {
  594. SID_IDENTIFIER_AUTHORITY SIDAuth = SECURITY_NT_AUTHORITY;
  595. return GetWellKnownSID(
  596. ppSid,
  597. &SIDAuth,
  598. 2,
  599. SECURITY_BUILTIN_DOMAIN_RID,
  600. DOMAIN_ALIAS_RID_ADMINS);
  601. }
  602. HRESULT CertSrv::GetLocalSID(PSID *ppSid)
  603. {
  604. SID_IDENTIFIER_AUTHORITY SIDAuth = SECURITY_LOCAL_SID_AUTHORITY;
  605. return GetWellKnownSID(
  606. ppSid,
  607. &SIDAuth,
  608. 1,
  609. SECURITY_LOCAL_RID);
  610. }
  611. HRESULT CertSrv::GetNetworkSID(PSID *ppSid)
  612. {
  613. SID_IDENTIFIER_AUTHORITY SIDAuth = SECURITY_NT_AUTHORITY;
  614. return GetWellKnownSID(
  615. ppSid,
  616. &SIDAuth,
  617. 1,
  618. SECURITY_NETWORK_RID);
  619. }