3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/advapi32/sec/trustee.c
6 * PURPOSE: Trustee functions
10 WINE_DEFAULT_DEBUG_CHANNEL(advapi
);
13 /******************************************************************************
14 * BuildImpersonateTrusteeA [ADVAPI32.@]
17 BuildImpersonateTrusteeA(PTRUSTEE_A pTrustee
,
18 PTRUSTEE_A pImpersonateTrustee
)
20 pTrustee
->pMultipleTrustee
= pImpersonateTrustee
;
21 pTrustee
->MultipleTrusteeOperation
= TRUSTEE_IS_IMPERSONATE
;
25 /******************************************************************************
26 * BuildImpersonateTrusteeW [ADVAPI32.@]
29 BuildImpersonateTrusteeW(PTRUSTEE_W pTrustee
,
30 PTRUSTEE_W pImpersonateTrustee
)
32 pTrustee
->pMultipleTrustee
= pImpersonateTrustee
;
33 pTrustee
->MultipleTrusteeOperation
= TRUSTEE_IS_IMPERSONATE
;
37 /******************************************************************************
38 * BuildExplicitAccessWithNameA [ADVAPI32.@]
41 BuildExplicitAccessWithNameA(PEXPLICIT_ACCESSA pExplicitAccess
,
43 DWORD AccessPermissions
,
44 ACCESS_MODE AccessMode
,
47 pExplicitAccess
->grfAccessPermissions
= AccessPermissions
;
48 pExplicitAccess
->grfAccessMode
= AccessMode
;
49 pExplicitAccess
->grfInheritance
= Inheritance
;
51 pExplicitAccess
->Trustee
.pMultipleTrustee
= NULL
;
52 pExplicitAccess
->Trustee
.MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
53 pExplicitAccess
->Trustee
.TrusteeForm
= TRUSTEE_IS_NAME
;
54 pExplicitAccess
->Trustee
.TrusteeType
= TRUSTEE_IS_UNKNOWN
;
55 pExplicitAccess
->Trustee
.ptstrName
= pTrusteeName
;
59 /******************************************************************************
60 * BuildExplicitAccessWithNameW [ADVAPI32.@]
63 BuildExplicitAccessWithNameW(PEXPLICIT_ACCESSW pExplicitAccess
,
65 DWORD AccessPermissions
,
66 ACCESS_MODE AccessMode
,
69 pExplicitAccess
->grfAccessPermissions
= AccessPermissions
;
70 pExplicitAccess
->grfAccessMode
= AccessMode
;
71 pExplicitAccess
->grfInheritance
= Inheritance
;
73 pExplicitAccess
->Trustee
.pMultipleTrustee
= NULL
;
74 pExplicitAccess
->Trustee
.MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
75 pExplicitAccess
->Trustee
.TrusteeForm
= TRUSTEE_IS_NAME
;
76 pExplicitAccess
->Trustee
.TrusteeType
= TRUSTEE_IS_UNKNOWN
;
77 pExplicitAccess
->Trustee
.ptstrName
= pTrusteeName
;
81 /******************************************************************************
82 * BuildImpersonateExplicitAccessWithNameA [ADVAPI32.@]
85 BuildImpersonateExplicitAccessWithNameA(PEXPLICIT_ACCESS_A pExplicitAccess
,
88 DWORD AccessPermissions
,
89 ACCESS_MODE AccessMode
,
92 pExplicitAccess
->grfAccessPermissions
= AccessPermissions
;
93 pExplicitAccess
->grfAccessMode
= AccessMode
;
94 pExplicitAccess
->grfInheritance
= Inheritance
;
96 pExplicitAccess
->Trustee
.pMultipleTrustee
= pTrustee
;
97 pExplicitAccess
->Trustee
.MultipleTrusteeOperation
= TRUSTEE_IS_IMPERSONATE
;
98 pExplicitAccess
->Trustee
.TrusteeForm
= TRUSTEE_IS_NAME
;
99 pExplicitAccess
->Trustee
.TrusteeType
= TRUSTEE_IS_UNKNOWN
;
100 pExplicitAccess
->Trustee
.ptstrName
= pTrusteeName
;
104 /******************************************************************************
105 * BuildImpersonateExplicitAccessWithNameW [ADVAPI32.@]
108 BuildImpersonateExplicitAccessWithNameW(PEXPLICIT_ACCESS_W pExplicitAccess
,
111 DWORD AccessPermissions
,
112 ACCESS_MODE AccessMode
,
115 pExplicitAccess
->grfAccessPermissions
= AccessPermissions
;
116 pExplicitAccess
->grfAccessMode
= AccessMode
;
117 pExplicitAccess
->grfInheritance
= Inheritance
;
119 pExplicitAccess
->Trustee
.pMultipleTrustee
= pTrustee
;
120 pExplicitAccess
->Trustee
.MultipleTrusteeOperation
= TRUSTEE_IS_IMPERSONATE
;
121 pExplicitAccess
->Trustee
.TrusteeForm
= TRUSTEE_IS_NAME
;
122 pExplicitAccess
->Trustee
.TrusteeType
= TRUSTEE_IS_UNKNOWN
;
123 pExplicitAccess
->Trustee
.ptstrName
= pTrusteeName
;
127 /******************************************************************************
128 * BuildTrusteeWithSidA [ADVAPI32.@]
131 BuildTrusteeWithSidA(PTRUSTEE_A pTrustee
,
134 TRACE("%p %p\n", pTrustee
, pSid
);
136 pTrustee
->pMultipleTrustee
= NULL
;
137 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
138 pTrustee
->TrusteeForm
= TRUSTEE_IS_SID
;
139 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
140 pTrustee
->ptstrName
= (LPSTR
) pSid
;
144 /******************************************************************************
145 * BuildTrusteeWithSidW [ADVAPI32.@]
148 BuildTrusteeWithSidW(PTRUSTEE_W pTrustee
,
151 TRACE("%p %p\n", pTrustee
, pSid
);
153 pTrustee
->pMultipleTrustee
= NULL
;
154 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
155 pTrustee
->TrusteeForm
= TRUSTEE_IS_SID
;
156 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
157 pTrustee
->ptstrName
= (LPWSTR
) pSid
;
161 /******************************************************************************
162 * BuildTrusteeWithNameA [ADVAPI32.@]
165 BuildTrusteeWithNameA(PTRUSTEE_A pTrustee
,
168 TRACE("%p %s\n", pTrustee
, name
);
170 pTrustee
->pMultipleTrustee
= NULL
;
171 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
172 pTrustee
->TrusteeForm
= TRUSTEE_IS_NAME
;
173 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
174 pTrustee
->ptstrName
= name
;
178 /******************************************************************************
179 * BuildTrusteeWithNameW [ADVAPI32.@]
182 BuildTrusteeWithNameW(PTRUSTEE_W pTrustee
,
185 TRACE("%p %s\n", pTrustee
, name
);
187 pTrustee
->pMultipleTrustee
= NULL
;
188 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
189 pTrustee
->TrusteeForm
= TRUSTEE_IS_NAME
;
190 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
191 pTrustee
->ptstrName
= name
;
195 /******************************************************************************
196 * BuildTrusteeWithObjectsAndNameA [ADVAPI32.@]
199 BuildTrusteeWithObjectsAndNameA(PTRUSTEEA pTrustee
,
200 POBJECTS_AND_NAME_A pObjName
,
201 SE_OBJECT_TYPE ObjectType
,
202 LPSTR ObjectTypeName
,
203 LPSTR InheritedObjectTypeName
,
206 DWORD ObjectsPresent
= 0;
208 TRACE("%p %p 0x%08x %p %p %s\n", pTrustee
, pObjName
,
209 ObjectType
, ObjectTypeName
, InheritedObjectTypeName
, Name
);
211 /* Fill the OBJECTS_AND_NAME structure */
212 pObjName
->ObjectType
= ObjectType
;
213 if (ObjectTypeName
!= NULL
)
215 ObjectsPresent
|= ACE_OBJECT_TYPE_PRESENT
;
218 pObjName
->InheritedObjectTypeName
= InheritedObjectTypeName
;
219 if (InheritedObjectTypeName
!= NULL
)
221 ObjectsPresent
|= ACE_INHERITED_OBJECT_TYPE_PRESENT
;
224 pObjName
->ObjectsPresent
= ObjectsPresent
;
225 pObjName
->ptstrName
= Name
;
227 /* Fill the TRUSTEE structure */
228 pTrustee
->pMultipleTrustee
= NULL
;
229 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
230 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_NAME
;
231 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
232 pTrustee
->ptstrName
= (LPSTR
)pObjName
;
236 /******************************************************************************
237 * BuildTrusteeWithObjectsAndNameW [ADVAPI32.@]
240 BuildTrusteeWithObjectsAndNameW(PTRUSTEEW pTrustee
,
241 POBJECTS_AND_NAME_W pObjName
,
242 SE_OBJECT_TYPE ObjectType
,
243 LPWSTR ObjectTypeName
,
244 LPWSTR InheritedObjectTypeName
,
247 DWORD ObjectsPresent
= 0;
249 TRACE("%p %p 0x%08x %p %p %s\n", pTrustee
, pObjName
,
250 ObjectType
, ObjectTypeName
, InheritedObjectTypeName
, Name
);
252 /* Fill the OBJECTS_AND_NAME structure */
253 pObjName
->ObjectType
= ObjectType
;
254 if (ObjectTypeName
!= NULL
)
256 ObjectsPresent
|= ACE_OBJECT_TYPE_PRESENT
;
259 pObjName
->InheritedObjectTypeName
= InheritedObjectTypeName
;
260 if (InheritedObjectTypeName
!= NULL
)
262 ObjectsPresent
|= ACE_INHERITED_OBJECT_TYPE_PRESENT
;
265 pObjName
->ObjectsPresent
= ObjectsPresent
;
266 pObjName
->ptstrName
= Name
;
268 /* Fill the TRUSTEE structure */
269 pTrustee
->pMultipleTrustee
= NULL
;
270 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
271 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_NAME
;
272 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
273 pTrustee
->ptstrName
= (LPWSTR
)pObjName
;
277 /******************************************************************************
278 * BuildTrusteeWithObjectsAndSidA [ADVAPI32.@]
281 BuildTrusteeWithObjectsAndSidA(PTRUSTEEA pTrustee
,
282 POBJECTS_AND_SID pObjSid
,
284 GUID
*pInheritedObjectGuid
,
287 DWORD ObjectsPresent
= 0;
289 TRACE("%p %p %p %p %p\n", pTrustee
, pObjSid
, pObjectGuid
, pInheritedObjectGuid
, pSid
);
291 /* Fill the OBJECTS_AND_SID structure */
292 if (pObjectGuid
!= NULL
)
294 pObjSid
->ObjectTypeGuid
= *pObjectGuid
;
295 ObjectsPresent
|= ACE_OBJECT_TYPE_PRESENT
;
299 ZeroMemory(&pObjSid
->ObjectTypeGuid
,
303 if (pInheritedObjectGuid
!= NULL
)
305 pObjSid
->InheritedObjectTypeGuid
= *pInheritedObjectGuid
;
306 ObjectsPresent
|= ACE_INHERITED_OBJECT_TYPE_PRESENT
;
310 ZeroMemory(&pObjSid
->InheritedObjectTypeGuid
,
314 pObjSid
->ObjectsPresent
= ObjectsPresent
;
315 pObjSid
->pSid
= pSid
;
317 /* Fill the TRUSTEE structure */
318 pTrustee
->pMultipleTrustee
= NULL
;
319 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
320 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_SID
;
321 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
322 pTrustee
->ptstrName
= (LPSTR
) pObjSid
;
326 /******************************************************************************
327 * BuildTrusteeWithObjectsAndSidW [ADVAPI32.@]
330 BuildTrusteeWithObjectsAndSidW(PTRUSTEEW pTrustee
,
331 POBJECTS_AND_SID pObjSid
,
333 GUID
*pInheritedObjectGuid
,
336 DWORD ObjectsPresent
= 0;
338 TRACE("%p %p %p %p %p\n", pTrustee
, pObjSid
, pObjectGuid
, pInheritedObjectGuid
, pSid
);
340 /* Fill the OBJECTS_AND_SID structure */
341 if (pObjectGuid
!= NULL
)
343 pObjSid
->ObjectTypeGuid
= *pObjectGuid
;
344 ObjectsPresent
|= ACE_OBJECT_TYPE_PRESENT
;
348 ZeroMemory(&pObjSid
->ObjectTypeGuid
,
352 if (pInheritedObjectGuid
!= NULL
)
354 pObjSid
->InheritedObjectTypeGuid
= *pInheritedObjectGuid
;
355 ObjectsPresent
|= ACE_INHERITED_OBJECT_TYPE_PRESENT
;
359 ZeroMemory(&pObjSid
->InheritedObjectTypeGuid
,
363 pObjSid
->ObjectsPresent
= ObjectsPresent
;
364 pObjSid
->pSid
= pSid
;
366 /* Fill the TRUSTEE structure */
367 pTrustee
->pMultipleTrustee
= NULL
;
368 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
369 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_SID
;
370 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
371 pTrustee
->ptstrName
= (LPWSTR
) pObjSid
;
375 /******************************************************************************
376 * GetMultipleTrusteeA [ADVAPI32.@]
379 GetMultipleTrusteeA(PTRUSTEE_A pTrustee
)
381 return pTrustee
->pMultipleTrustee
;
385 /******************************************************************************
386 * GetMultipleTrusteeW [ADVAPI32.@]
389 GetMultipleTrusteeW(PTRUSTEE_W pTrustee
)
391 return pTrustee
->pMultipleTrustee
;
395 /******************************************************************************
396 * GetMultipleTrusteeOperationA [ADVAPI32.@]
398 MULTIPLE_TRUSTEE_OPERATION WINAPI
399 GetMultipleTrusteeOperationA(PTRUSTEE_A pTrustee
)
401 return pTrustee
->MultipleTrusteeOperation
;
405 /******************************************************************************
406 * GetMultipleTrusteeOperationW [ADVAPI32.@]
408 MULTIPLE_TRUSTEE_OPERATION WINAPI
409 GetMultipleTrusteeOperationW(PTRUSTEE_W pTrustee
)
411 return pTrustee
->MultipleTrusteeOperation
;
415 /******************************************************************************
416 * GetTrusteeFormW [ADVAPI32.@]
419 GetTrusteeFormA(PTRUSTEE_A pTrustee
)
421 return pTrustee
->TrusteeForm
;
425 /******************************************************************************
426 * GetTrusteeFormW [ADVAPI32.@]
429 GetTrusteeFormW(PTRUSTEE_W pTrustee
)
431 return pTrustee
->TrusteeForm
;
435 /******************************************************************************
436 * GetTrusteeNameA [ADVAPI32.@]
439 GetTrusteeNameA(PTRUSTEE_A pTrustee
)
441 return pTrustee
->ptstrName
;
445 /******************************************************************************
446 * GetTrusteeNameW [ADVAPI32.@]
449 GetTrusteeNameW(PTRUSTEE_W pTrustee
)
451 return pTrustee
->ptstrName
;
455 /******************************************************************************
456 * GetTrusteeTypeA [ADVAPI32.@]
459 GetTrusteeTypeA(PTRUSTEE_A pTrustee
)
461 return pTrustee
->TrusteeType
;
465 /******************************************************************************
466 * GetTrusteeTypeW [ADVAPI32.@]
469 GetTrusteeTypeW(PTRUSTEE_W pTrustee
)
471 return pTrustee
->TrusteeType
;