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.

450 lines
10 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. scope.cxx
  5. Abstract:
  6. Routines implementing the Scope object
  7. Author:
  8. Cliff Van Dyke (cliffv) 11-Apr-2001
  9. --*/
  10. #include "pch.hxx"
  11. DWORD
  12. AzpScopeInit(
  13. IN PGENERIC_OBJECT ParentGenericObject,
  14. IN PGENERIC_OBJECT ChildGenericObject
  15. )
  16. /*++
  17. Routine Description:
  18. This routine is a worker routine for AzScopeCreate. It does any object specific
  19. initialization that needs to be done.
  20. On entry, AzGlResource must be locked exclusively.
  21. Arguments:
  22. ParentGenericObject - Specifies the parent object to add the child object onto.
  23. The reference count has been incremented on this object.
  24. ChildGenericObject - Specifies the newly allocated child object.
  25. The reference count has been incremented on this object.
  26. Return Value:
  27. NO_ERROR - The operation was successful
  28. ERROR_NOT_ENOUGH_MEMORY - not enough memory
  29. Other exception status codes
  30. --*/
  31. {
  32. PAZP_SCOPE Scope = (PAZP_SCOPE) ChildGenericObject;
  33. PAZP_APPLICATION Application = (PAZP_APPLICATION) ParentGenericObject;
  34. //
  35. // Initialization
  36. //
  37. ASSERT( AzpIsLockedExclusive( &AzGlResource ) );
  38. //
  39. // Sanity check the parent
  40. //
  41. ASSERT( ParentGenericObject->ObjectType == OBJECT_TYPE_APPLICATION );
  42. //
  43. // Initialize the lists of child objects
  44. // Let the generic object manager know all of the types of children we support
  45. //
  46. ChildGenericObject->ChildGenericObjectHead = &Scope->Groups;
  47. // List of child groups
  48. ObInitGenericHead( &Scope->Groups,
  49. OBJECT_TYPE_GROUP,
  50. ChildGenericObject,
  51. &Scope->Roles,
  52. &Application->Groups ); // Shares namespace with the groups of my parent object
  53. // List of child roles
  54. ObInitGenericHead( &Scope->Roles,
  55. OBJECT_TYPE_ROLE,
  56. ChildGenericObject,
  57. &Scope->AzpSids,
  58. NULL ); // Doesn't share namespace
  59. // List of child AzpSids
  60. ObInitGenericHead( &Scope->AzpSids,
  61. OBJECT_TYPE_SID,
  62. ChildGenericObject,
  63. NULL,
  64. NULL ); // Doesn't share namespace
  65. //
  66. // Scopes are referenced by "Roles"
  67. // Let the generic object manager know all of the lists we support
  68. // This is a "back" link so we don't need to define which Roles can reference this scope.
  69. //
  70. ChildGenericObject->GenericObjectLists = &Scope->backRoles;
  71. // Back link to roles
  72. ObInitObjectList( &Scope->backRoles,
  73. NULL,
  74. TRUE, // Backward link
  75. 0, // No link pair id
  76. NULL,
  77. NULL,
  78. NULL );
  79. return NO_ERROR;
  80. }
  81. VOID
  82. AzpScopeFree(
  83. IN PGENERIC_OBJECT GenericObject
  84. )
  85. /*++
  86. Routine Description:
  87. This routine is a worker routine for Scope object free. It does any object specific
  88. cleanup that needs to be done.
  89. On entry, AzGlResource must be locked exclusively.
  90. Arguments:
  91. GenericObject - Specifies a pointer to the object to be deleted.
  92. Return Value:
  93. None
  94. --*/
  95. {
  96. // PAZP_SCOPE Scope = (PAZP_SCOPE) GenericObject;
  97. UNREFERENCED_PARAMETER( GenericObject );
  98. //
  99. // Initialization
  100. //
  101. ASSERT( AzpIsLockedExclusive( &AzGlResource ) );
  102. //
  103. // Free any local strings
  104. //
  105. }
  106. DWORD
  107. WINAPI
  108. AzScopeCreate(
  109. IN AZ_HANDLE ApplicationHandle,
  110. IN LPCWSTR ScopeName,
  111. IN DWORD Reserved,
  112. OUT PAZ_HANDLE ScopeHandle
  113. )
  114. /*++
  115. Routine Description:
  116. This routine adds a scope into the scope of the specified application.
  117. Arguments:
  118. ApplicationHandle - Specifies a handle to the application.
  119. ScopeName - Specifies the name of the scope to add.
  120. Reserved - Reserved. Must by zero.
  121. ScopeHandle - Return a handle to the scope.
  122. The caller must close this handle by calling AzCloseHandle.
  123. Return Value:
  124. NO_ERROR - The operation was successful
  125. ERROR_ALREADY_EXISTS - An object by that name already exists
  126. --*/
  127. {
  128. //
  129. // Call the common routine to do most of the work
  130. //
  131. return ObCommonCreateObject(
  132. (PGENERIC_OBJECT) ApplicationHandle,
  133. OBJECT_TYPE_APPLICATION,
  134. &(((PAZP_APPLICATION)ApplicationHandle)->Scopes),
  135. OBJECT_TYPE_SCOPE,
  136. ScopeName,
  137. Reserved,
  138. (PGENERIC_OBJECT *) ScopeHandle );
  139. }
  140. DWORD
  141. WINAPI
  142. AzScopeOpen(
  143. IN AZ_HANDLE ApplicationHandle,
  144. IN LPCWSTR ScopeName,
  145. IN DWORD Reserved,
  146. OUT PAZ_HANDLE ScopeHandle
  147. )
  148. /*++
  149. Routine Description:
  150. This routine opens a scope into the scope of the specified application.
  151. Arguments:
  152. ApplicationHandle - Specifies a handle to the application.
  153. ScopeName - Specifies the name of the scope to open
  154. Reserved - Reserved. Must by zero.
  155. ScopeHandle - Return a handle to the scope.
  156. The caller must close this handle by calling AzCloseHandle.
  157. Return Value:
  158. NO_ERROR - The operation was successful
  159. ERROR_NOT_FOUND - There is no scope by that name
  160. --*/
  161. {
  162. //
  163. // Call the common routine to do most of the work
  164. //
  165. return ObCommonOpenObject(
  166. (PGENERIC_OBJECT) ApplicationHandle,
  167. OBJECT_TYPE_APPLICATION,
  168. &(((PAZP_APPLICATION)ApplicationHandle)->Scopes),
  169. OBJECT_TYPE_SCOPE,
  170. ScopeName,
  171. Reserved,
  172. (PGENERIC_OBJECT *) ScopeHandle );
  173. }
  174. DWORD
  175. WINAPI
  176. AzScopeEnum(
  177. IN AZ_HANDLE ApplicationHandle,
  178. IN DWORD Reserved,
  179. IN OUT PULONG EnumerationContext,
  180. OUT PAZ_HANDLE ScopeHandle
  181. )
  182. /*++
  183. Routine Description:
  184. Enumerates all of the scopes for the specified application.
  185. Arguments:
  186. ApplicationHandle - Specifies a handle to the application.
  187. Reserved - Reserved. Must by zero.
  188. EnumerationContext - Specifies a context indicating the next scope to return
  189. On input for the first call, should point to zero.
  190. On input for subsequent calls, should point to the value returned on the previous call.
  191. On output, returns a value to be passed on the next call.
  192. ScopeHandle - Returns a handle to the next scope object.
  193. The caller must close this handle by calling AzCloseHandle.
  194. Return Value:
  195. NO_ERROR - The operation was successful (a handle was returned)
  196. ERROR_NO_MORE_ITEMS - No more items were available for enumeration
  197. --*/
  198. {
  199. //
  200. // Call the common routine to do most of the work
  201. //
  202. return ObCommonEnumObjects(
  203. (PGENERIC_OBJECT) ApplicationHandle,
  204. OBJECT_TYPE_APPLICATION,
  205. &(((PAZP_APPLICATION)ApplicationHandle)->Scopes),
  206. EnumerationContext,
  207. Reserved,
  208. (PGENERIC_OBJECT *) ScopeHandle );
  209. }
  210. DWORD
  211. WINAPI
  212. AzScopeGetProperty(
  213. IN AZ_HANDLE ScopeHandle,
  214. IN ULONG PropertyId,
  215. IN DWORD Reserved,
  216. OUT PVOID *PropertyValue
  217. )
  218. /*++
  219. Routine Description:
  220. Returns the specified property for a scope.
  221. Arguments:
  222. ScopeHandle - Specifies a handle to the scope
  223. PropertyId - Specifies which property to return.
  224. Reserved - Reserved. Must by zero.
  225. PropertyValue - Specifies a pointer to return the property in.
  226. The returned pointer must be freed using AzFreeMemory.
  227. The returned value and type depends in PropertyId. The valid values are:
  228. AZ_PROP_NAME LPWSTR - Object name of the object
  229. AZ_PROP_DESCRIPTION LPWSTR - Description of the object
  230. Return Value:
  231. NO_ERROR - The operation was successful
  232. ERROR_INVALID_PARAMETER - PropertyId isn't valid
  233. --*/
  234. {
  235. //
  236. // Call the common routine to do most of the work
  237. //
  238. return ObCommonGetProperty(
  239. (PGENERIC_OBJECT) ScopeHandle,
  240. OBJECT_TYPE_SCOPE,
  241. PropertyId,
  242. Reserved,
  243. PropertyValue );
  244. }
  245. DWORD
  246. WINAPI
  247. AzScopeSetProperty(
  248. IN AZ_HANDLE ScopeHandle,
  249. IN ULONG PropertyId,
  250. IN DWORD Reserved,
  251. IN PVOID PropertyValue
  252. )
  253. /*++
  254. Routine Description:
  255. Sets the specified property for a scope.
  256. Arguments:
  257. ScopeHandle - Specifies a handle to the scope
  258. PropertyId - Specifies which property to set
  259. Reserved - Reserved. Must by zero.
  260. PropertyValue - Specifies a pointer to the property.
  261. The specified value and type depends in PropertyId. The valid values are:
  262. AZ_PROP_NAME LPWSTR - Object name of the object
  263. AZ_PROP_DESCRIPTION LPWSTR - Description of the object
  264. Return Value:
  265. NO_ERROR - The operation was successful
  266. ERROR_INVALID_PARAMETER - PropertyId isn't valid
  267. --*/
  268. {
  269. //
  270. // Call the common routine to do most of the work
  271. //
  272. return ObCommonSetProperty(
  273. (PGENERIC_OBJECT) ScopeHandle,
  274. OBJECT_TYPE_SCOPE,
  275. PropertyId,
  276. Reserved,
  277. PropertyValue );
  278. }
  279. DWORD
  280. WINAPI
  281. AzScopeDelete(
  282. IN AZ_HANDLE ApplicationHandle,
  283. IN LPCWSTR ScopeName,
  284. IN DWORD Reserved
  285. )
  286. /*++
  287. Routine Description:
  288. This routine deletes a scope from the scope of the specified application.
  289. Also deletes any child objects of ScopeName.
  290. Arguments:
  291. ApplicationHandle - Specifies a handle to the application.
  292. ScopeName - Specifies the name of the scope to delete.
  293. Reserved - Reserved. Must by zero.
  294. Return Value:
  295. NO_ERROR - The operation was successful
  296. ERROR_NOT_FOUND - An object by that name cannot be found
  297. --*/
  298. {
  299. //
  300. // Call the common routine to do most of the work
  301. //
  302. return ObCommonDeleteObject(
  303. (PGENERIC_OBJECT) ApplicationHandle,
  304. OBJECT_TYPE_APPLICATION,
  305. &(((PAZP_APPLICATION)ApplicationHandle)->Scopes),
  306. OBJECT_TYPE_SCOPE,
  307. ScopeName,
  308. Reserved );
  309. }