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.

192 lines
7.1 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 2000.
  5. //
  6. // File: rsopsec.cpp
  7. //
  8. // Contents: implementation used by the RSOP mode security pane
  9. //
  10. // Classes: CRSOPSecurityInfo
  11. //
  12. // Functions:
  13. //
  14. // History: 02-15-2000 stevebl Created
  15. //
  16. //---------------------------------------------------------------------------
  17. #include "precomp.hxx"
  18. const
  19. ACCESS_MASK
  20. GENERIC_READ_MAPPING = ((STANDARD_RIGHTS_READ) | \
  21. (ACTRL_DS_LIST) | \
  22. (ACTRL_DS_READ_PROP) | \
  23. (ACTRL_DS_LIST_OBJECT));
  24. const
  25. ACCESS_MASK
  26. GENERIC_EXECUTE_MAPPING = ((STANDARD_RIGHTS_EXECUTE) | \
  27. (ACTRL_DS_LIST));
  28. const
  29. ACCESS_MASK
  30. GENERIC_WRITE_MAPPING = ((STANDARD_RIGHTS_WRITE) | \
  31. (ACTRL_DS_SELF) | \
  32. (ACTRL_DS_WRITE_PROP));
  33. const
  34. ACCESS_MASK
  35. GENERIC_ALL_MAPPING = ((STANDARD_RIGHTS_REQUIRED) | \
  36. (ACTRL_DS_CREATE_CHILD) | \
  37. (ACTRL_DS_DELETE_CHILD) | \
  38. (ACTRL_DS_DELETE_TREE) | \
  39. (ACTRL_DS_READ_PROP) | \
  40. (ACTRL_DS_WRITE_PROP) | \
  41. (ACTRL_DS_LIST) | \
  42. (ACTRL_DS_LIST_OBJECT) | \
  43. (ACTRL_DS_CONTROL_ACCESS) | \
  44. (ACTRL_DS_SELF));
  45. //The Following array defines the permission names for DS Key Objects
  46. SI_ACCESS siDSAccesses[] =
  47. {
  48. { NULL, DS_GENERIC_ALL, MAKEINTRESOURCE(IDS_DS_GENERIC_ALL), SI_ACCESS_GENERAL | SI_ACCESS_SPECIFIC },
  49. { NULL, DS_GENERIC_READ, MAKEINTRESOURCE(IDS_DS_GENERIC_READ), SI_ACCESS_GENERAL },
  50. { NULL, DS_GENERIC_WRITE, MAKEINTRESOURCE(IDS_DS_GENERIC_WRITE), SI_ACCESS_GENERAL },
  51. { NULL, ACTRL_DS_LIST, MAKEINTRESOURCE(IDS_ACTRL_DS_LIST), SI_ACCESS_SPECIFIC },
  52. { NULL, ACTRL_DS_LIST_OBJECT, MAKEINTRESOURCE(IDS_ACTRL_DS_LIST_OBJECT), SI_ACCESS_SPECIFIC },
  53. { NULL, ACTRL_DS_READ_PROP, MAKEINTRESOURCE(IDS_ACTRL_DS_READ_PROP), SI_ACCESS_SPECIFIC | SI_ACCESS_PROPERTY },
  54. { NULL, ACTRL_DS_WRITE_PROP, MAKEINTRESOURCE(IDS_ACTRL_DS_WRITE_PROP), SI_ACCESS_SPECIFIC | SI_ACCESS_PROPERTY },
  55. { NULL, DELETE, MAKEINTRESOURCE(IDS_ACTRL_DELETE), SI_ACCESS_SPECIFIC },
  56. { NULL, ACTRL_DS_DELETE_TREE, MAKEINTRESOURCE(IDS_ACTRL_DS_DELETE_TREE), SI_ACCESS_SPECIFIC },
  57. { NULL, READ_CONTROL, MAKEINTRESOURCE(IDS_ACTRL_READ_CONTROL), SI_ACCESS_SPECIFIC },
  58. { NULL, WRITE_DAC, MAKEINTRESOURCE(IDS_ACTRL_CHANGE_ACCESS), SI_ACCESS_SPECIFIC },
  59. { NULL, WRITE_OWNER, MAKEINTRESOURCE(IDS_ACTRL_CHANGE_OWNER), SI_ACCESS_SPECIFIC },
  60. { NULL, 0, MAKEINTRESOURCE(IDS_NO_ACCESS), 0 },
  61. { NULL, ACTRL_DS_SELF, MAKEINTRESOURCE(IDS_ACTRL_DS_SELF), SI_ACCESS_SPECIFIC },
  62. { NULL, ACTRL_DS_CONTROL_ACCESS, MAKEINTRESOURCE(IDS_ACTRL_DS_CONTROL_ACCESS),SI_ACCESS_SPECIFIC },
  63. { NULL, ACTRL_DS_CREATE_CHILD, MAKEINTRESOURCE(IDS_ACTRL_DS_CREATE_CHILD), SI_ACCESS_CONTAINER | SI_ACCESS_SPECIFIC },
  64. { NULL, ACTRL_DS_DELETE_CHILD, MAKEINTRESOURCE(IDS_ACTRL_DS_DELETE_CHILD), SI_ACCESS_CONTAINER | SI_ACCESS_SPECIFIC },
  65. };
  66. /*
  67. SI_INHERIT_TYPE siDSInheritTypes[] =
  68. {
  69. { &GUID_NULL, 0, MAKEINTRESOURCE(IDS_DS_CONTAINER_ONLY) },
  70. { &GUID_NULL, CONTAINER_INHERIT_ACE, MAKEINTRESOURCE(IDS_DS_CONTAINER_SUBITEMS) },
  71. { &GUID_NULL, CONTAINER_INHERIT_ACE | INHERIT_ONLY_ACE, MAKEINTRESOURCE(IDS_DS_SUBITEMS_ONLY) },
  72. };
  73. */
  74. STDMETHODIMP CRSOPSecurityInfo::QueryInterface(REFIID riid,
  75. LPVOID *ppv)
  76. {
  77. if (IsEqualIID(riid, IID_ISecurityInformation) || IsEqualIID(riid, IID_IUnknown))
  78. {
  79. *ppv = (LPSECURITYINFO)this;
  80. m_cRef++;
  81. return S_OK;
  82. }
  83. else
  84. {
  85. *ppv = NULL;
  86. return E_NOINTERFACE;
  87. }
  88. }
  89. STDMETHODIMP_(ULONG) CRSOPSecurityInfo::AddRef()
  90. {
  91. return ++m_cRef;
  92. }
  93. STDMETHODIMP_(ULONG) CRSOPSecurityInfo::Release()
  94. {
  95. if (--m_cRef == 0) {
  96. delete this;
  97. return 0;
  98. }
  99. return m_cRef;
  100. }
  101. STDMETHODIMP CRSOPSecurityInfo::MapGeneric(const GUID *pguidObjectType,
  102. UCHAR *pAceFlags,
  103. ACCESS_MASK *pMask)
  104. {
  105. GENERIC_MAPPING gm;
  106. gm.GenericRead = GENERIC_READ_MAPPING;
  107. gm.GenericWrite = GENERIC_WRITE_MAPPING;
  108. gm.GenericExecute = GENERIC_EXECUTE_MAPPING;
  109. gm.GenericAll = GENERIC_ALL_MAPPING;
  110. MapGenericMask(pMask, &gm);
  111. return S_OK;
  112. }
  113. STDMETHODIMP CRSOPSecurityInfo::GetObjectInformation(PSI_OBJECT_INFO pObjectInfo)
  114. {
  115. pObjectInfo->dwFlags = SI_READONLY | SI_ADVANCED | SI_SERVER_IS_DC;
  116. pObjectInfo->hInstance = ghInstance;
  117. pObjectInfo->pszServerName = NULL;
  118. pObjectInfo->pszObjectName = m_pData->m_pDetails->pszPackageName;
  119. pObjectInfo->pszPageTitle = NULL;
  120. memset(&pObjectInfo->guidObjectType, 0, sizeof(GUID));
  121. return S_OK;
  122. }
  123. STDMETHODIMP CRSOPSecurityInfo::GetSecurity(SECURITY_INFORMATION RequestedInformation,
  124. PSECURITY_DESCRIPTOR *ppSD,
  125. BOOL fDefault)
  126. {
  127. HRESULT hr = S_OK;
  128. if (IsValidSecurityDescriptor(m_pData->m_psd))
  129. {
  130. ULONG nLength = GetSecurityDescriptorLength(m_pData->m_psd);
  131. *ppSD = (PSECURITY_DESCRIPTOR)LocalAlloc(LPTR, nLength);
  132. if (*ppSD != NULL)
  133. CopyMemory(*ppSD, m_pData->m_psd, nLength);
  134. else
  135. hr = E_OUTOFMEMORY;
  136. }
  137. else
  138. {
  139. *ppSD = NULL;
  140. }
  141. return hr;
  142. }
  143. STDMETHODIMP CRSOPSecurityInfo::SetSecurity(SECURITY_INFORMATION SecurityInformation,
  144. PSECURITY_DESCRIPTOR pSecurityDescriptor)
  145. {
  146. return E_ACCESSDENIED;
  147. }
  148. STDMETHODIMP CRSOPSecurityInfo::GetAccessRights(const GUID * pguidObjectType,
  149. DWORD dwFlags,
  150. PSI_ACCESS * ppAccess,
  151. ULONG *pcAccesses,
  152. ULONG *piDefaultAccess)
  153. {
  154. *ppAccess = siDSAccesses;
  155. *pcAccesses = sizeof(siDSAccesses)/sizeof(siDSAccesses[0]);
  156. *piDefaultAccess = 0;
  157. return S_OK;
  158. }
  159. STDMETHODIMP CRSOPSecurityInfo::GetInheritTypes(PSI_INHERIT_TYPE * ppInheritTypes,
  160. ULONG *pcInheritTypes)
  161. {
  162. *ppInheritTypes = NULL;
  163. *pcInheritTypes = 0;
  164. return S_OK;
  165. }
  166. STDMETHODIMP CRSOPSecurityInfo::PropertySheetPageCallback(HWND hwnd,
  167. UINT uMsg,
  168. SI_PAGE_TYPE uPage)
  169. {
  170. return S_FALSE; // prevents UI from displaying pop-ups
  171. }