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
11 #include "wine/debug.h"
13 WINE_DEFAULT_DEBUG_CHANNEL(advapi
);
16 /******************************************************************************
17 * BuildImpersonateTrusteeA [ADVAPI32.@]
20 BuildImpersonateTrusteeA(PTRUSTEE_A pTrustee
,
21 PTRUSTEE_A pImpersonateTrustee
)
23 pTrustee
->pMultipleTrustee
= pImpersonateTrustee
;
24 pTrustee
->MultipleTrusteeOperation
= TRUSTEE_IS_IMPERSONATE
;
28 /******************************************************************************
29 * BuildImpersonateTrusteeW [ADVAPI32.@]
32 BuildImpersonateTrusteeW(PTRUSTEE_W pTrustee
,
33 PTRUSTEE_W pImpersonateTrustee
)
35 pTrustee
->pMultipleTrustee
= pImpersonateTrustee
;
36 pTrustee
->MultipleTrusteeOperation
= TRUSTEE_IS_IMPERSONATE
;
40 /******************************************************************************
41 * BuildExplicitAccessWithNameA [ADVAPI32.@]
44 BuildExplicitAccessWithNameA(PEXPLICIT_ACCESSA pExplicitAccess
,
46 DWORD AccessPermissions
,
47 ACCESS_MODE AccessMode
,
50 pExplicitAccess
->grfAccessPermissions
= AccessPermissions
;
51 pExplicitAccess
->grfAccessMode
= AccessMode
;
52 pExplicitAccess
->grfInheritance
= Inheritance
;
54 pExplicitAccess
->Trustee
.pMultipleTrustee
= NULL
;
55 pExplicitAccess
->Trustee
.MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
56 pExplicitAccess
->Trustee
.TrusteeForm
= TRUSTEE_IS_NAME
;
57 pExplicitAccess
->Trustee
.TrusteeType
= TRUSTEE_IS_UNKNOWN
;
58 pExplicitAccess
->Trustee
.ptstrName
= pTrusteeName
;
62 /******************************************************************************
63 * BuildExplicitAccessWithNameW [ADVAPI32.@]
66 BuildExplicitAccessWithNameW(PEXPLICIT_ACCESSW pExplicitAccess
,
68 DWORD AccessPermissions
,
69 ACCESS_MODE AccessMode
,
72 pExplicitAccess
->grfAccessPermissions
= AccessPermissions
;
73 pExplicitAccess
->grfAccessMode
= AccessMode
;
74 pExplicitAccess
->grfInheritance
= Inheritance
;
76 pExplicitAccess
->Trustee
.pMultipleTrustee
= NULL
;
77 pExplicitAccess
->Trustee
.MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
78 pExplicitAccess
->Trustee
.TrusteeForm
= TRUSTEE_IS_NAME
;
79 pExplicitAccess
->Trustee
.TrusteeType
= TRUSTEE_IS_UNKNOWN
;
80 pExplicitAccess
->Trustee
.ptstrName
= pTrusteeName
;
84 /******************************************************************************
85 * BuildImpersonateExplicitAccessWithNameA [ADVAPI32.@]
88 BuildImpersonateExplicitAccessWithNameA(PEXPLICIT_ACCESS_A pExplicitAccess
,
91 DWORD AccessPermissions
,
92 ACCESS_MODE AccessMode
,
95 pExplicitAccess
->grfAccessPermissions
= AccessPermissions
;
96 pExplicitAccess
->grfAccessMode
= AccessMode
;
97 pExplicitAccess
->grfInheritance
= Inheritance
;
99 pExplicitAccess
->Trustee
.pMultipleTrustee
= pTrustee
;
100 pExplicitAccess
->Trustee
.MultipleTrusteeOperation
= TRUSTEE_IS_IMPERSONATE
;
101 pExplicitAccess
->Trustee
.TrusteeForm
= TRUSTEE_IS_NAME
;
102 pExplicitAccess
->Trustee
.TrusteeType
= TRUSTEE_IS_UNKNOWN
;
103 pExplicitAccess
->Trustee
.ptstrName
= pTrusteeName
;
107 /******************************************************************************
108 * BuildImpersonateExplicitAccessWithNameW [ADVAPI32.@]
111 BuildImpersonateExplicitAccessWithNameW(PEXPLICIT_ACCESS_W pExplicitAccess
,
114 DWORD AccessPermissions
,
115 ACCESS_MODE AccessMode
,
118 pExplicitAccess
->grfAccessPermissions
= AccessPermissions
;
119 pExplicitAccess
->grfAccessMode
= AccessMode
;
120 pExplicitAccess
->grfInheritance
= Inheritance
;
122 pExplicitAccess
->Trustee
.pMultipleTrustee
= pTrustee
;
123 pExplicitAccess
->Trustee
.MultipleTrusteeOperation
= TRUSTEE_IS_IMPERSONATE
;
124 pExplicitAccess
->Trustee
.TrusteeForm
= TRUSTEE_IS_NAME
;
125 pExplicitAccess
->Trustee
.TrusteeType
= TRUSTEE_IS_UNKNOWN
;
126 pExplicitAccess
->Trustee
.ptstrName
= pTrusteeName
;
130 /******************************************************************************
131 * BuildTrusteeWithSidA [ADVAPI32.@]
134 BuildTrusteeWithSidA(PTRUSTEE_A pTrustee
,
137 TRACE("%p %p\n", pTrustee
, pSid
);
139 pTrustee
->pMultipleTrustee
= NULL
;
140 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
141 pTrustee
->TrusteeForm
= TRUSTEE_IS_SID
;
142 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
143 pTrustee
->ptstrName
= (LPSTR
) pSid
;
147 /******************************************************************************
148 * BuildTrusteeWithSidW [ADVAPI32.@]
151 BuildTrusteeWithSidW(PTRUSTEE_W pTrustee
,
154 TRACE("%p %p\n", pTrustee
, pSid
);
156 pTrustee
->pMultipleTrustee
= NULL
;
157 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
158 pTrustee
->TrusteeForm
= TRUSTEE_IS_SID
;
159 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
160 pTrustee
->ptstrName
= (LPWSTR
) pSid
;
164 /******************************************************************************
165 * BuildTrusteeWithNameA [ADVAPI32.@]
168 BuildTrusteeWithNameA(PTRUSTEE_A pTrustee
,
171 TRACE("%p %s\n", pTrustee
, name
);
173 pTrustee
->pMultipleTrustee
= NULL
;
174 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
175 pTrustee
->TrusteeForm
= TRUSTEE_IS_NAME
;
176 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
177 pTrustee
->ptstrName
= name
;
181 /******************************************************************************
182 * BuildTrusteeWithNameW [ADVAPI32.@]
185 BuildTrusteeWithNameW(PTRUSTEE_W pTrustee
,
188 TRACE("%p %s\n", pTrustee
, name
);
190 pTrustee
->pMultipleTrustee
= NULL
;
191 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
192 pTrustee
->TrusteeForm
= TRUSTEE_IS_NAME
;
193 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
194 pTrustee
->ptstrName
= name
;
198 /******************************************************************************
199 * BuildTrusteeWithObjectsAndNameA [ADVAPI32.@]
202 BuildTrusteeWithObjectsAndNameA(PTRUSTEEA pTrustee
,
203 POBJECTS_AND_NAME_A pObjName
,
204 SE_OBJECT_TYPE ObjectType
,
205 LPSTR ObjectTypeName
,
206 LPSTR InheritedObjectTypeName
,
209 DWORD ObjectsPresent
= 0;
211 TRACE("%p %p 0x%08x %p %p %s\n", pTrustee
, pObjName
,
212 ObjectType
, ObjectTypeName
, InheritedObjectTypeName
, Name
);
214 /* Fill the OBJECTS_AND_NAME structure */
215 pObjName
->ObjectType
= ObjectType
;
216 if (ObjectTypeName
!= NULL
)
218 ObjectsPresent
|= ACE_OBJECT_TYPE_PRESENT
;
221 pObjName
->InheritedObjectTypeName
= InheritedObjectTypeName
;
222 if (InheritedObjectTypeName
!= NULL
)
224 ObjectsPresent
|= ACE_INHERITED_OBJECT_TYPE_PRESENT
;
227 pObjName
->ObjectsPresent
= ObjectsPresent
;
228 pObjName
->ptstrName
= Name
;
230 /* Fill the TRUSTEE structure */
231 pTrustee
->pMultipleTrustee
= NULL
;
232 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
233 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_NAME
;
234 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
235 pTrustee
->ptstrName
= (LPSTR
)pObjName
;
239 /******************************************************************************
240 * BuildTrusteeWithObjectsAndNameW [ADVAPI32.@]
243 BuildTrusteeWithObjectsAndNameW(PTRUSTEEW pTrustee
,
244 POBJECTS_AND_NAME_W pObjName
,
245 SE_OBJECT_TYPE ObjectType
,
246 LPWSTR ObjectTypeName
,
247 LPWSTR InheritedObjectTypeName
,
250 DWORD ObjectsPresent
= 0;
252 TRACE("%p %p 0x%08x %p %p %s\n", pTrustee
, pObjName
,
253 ObjectType
, ObjectTypeName
, InheritedObjectTypeName
, Name
);
255 /* Fill the OBJECTS_AND_NAME structure */
256 pObjName
->ObjectType
= ObjectType
;
257 if (ObjectTypeName
!= NULL
)
259 ObjectsPresent
|= ACE_OBJECT_TYPE_PRESENT
;
262 pObjName
->InheritedObjectTypeName
= InheritedObjectTypeName
;
263 if (InheritedObjectTypeName
!= NULL
)
265 ObjectsPresent
|= ACE_INHERITED_OBJECT_TYPE_PRESENT
;
268 pObjName
->ObjectsPresent
= ObjectsPresent
;
269 pObjName
->ptstrName
= Name
;
271 /* Fill the TRUSTEE structure */
272 pTrustee
->pMultipleTrustee
= NULL
;
273 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
274 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_NAME
;
275 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
276 pTrustee
->ptstrName
= (LPWSTR
)pObjName
;
280 /******************************************************************************
281 * BuildTrusteeWithObjectsAndSidA [ADVAPI32.@]
284 BuildTrusteeWithObjectsAndSidA(PTRUSTEEA pTrustee
,
285 POBJECTS_AND_SID pObjSid
,
287 GUID
*pInheritedObjectGuid
,
290 DWORD ObjectsPresent
= 0;
292 TRACE("%p %p %p %p %p\n", pTrustee
, pObjSid
, pObjectGuid
, pInheritedObjectGuid
, pSid
);
294 /* Fill the OBJECTS_AND_SID structure */
295 if (pObjectGuid
!= NULL
)
297 pObjSid
->ObjectTypeGuid
= *pObjectGuid
;
298 ObjectsPresent
|= ACE_OBJECT_TYPE_PRESENT
;
302 ZeroMemory(&pObjSid
->ObjectTypeGuid
,
306 if (pInheritedObjectGuid
!= NULL
)
308 pObjSid
->InheritedObjectTypeGuid
= *pInheritedObjectGuid
;
309 ObjectsPresent
|= ACE_INHERITED_OBJECT_TYPE_PRESENT
;
313 ZeroMemory(&pObjSid
->InheritedObjectTypeGuid
,
317 pObjSid
->ObjectsPresent
= ObjectsPresent
;
318 pObjSid
->pSid
= pSid
;
320 /* Fill the TRUSTEE structure */
321 pTrustee
->pMultipleTrustee
= NULL
;
322 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
323 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_SID
;
324 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
325 pTrustee
->ptstrName
= (LPSTR
) pObjSid
;
329 /******************************************************************************
330 * BuildTrusteeWithObjectsAndSidW [ADVAPI32.@]
333 BuildTrusteeWithObjectsAndSidW(PTRUSTEEW pTrustee
,
334 POBJECTS_AND_SID pObjSid
,
336 GUID
*pInheritedObjectGuid
,
339 DWORD ObjectsPresent
= 0;
341 TRACE("%p %p %p %p %p\n", pTrustee
, pObjSid
, pObjectGuid
, pInheritedObjectGuid
, pSid
);
343 /* Fill the OBJECTS_AND_SID structure */
344 if (pObjectGuid
!= NULL
)
346 pObjSid
->ObjectTypeGuid
= *pObjectGuid
;
347 ObjectsPresent
|= ACE_OBJECT_TYPE_PRESENT
;
351 ZeroMemory(&pObjSid
->ObjectTypeGuid
,
355 if (pInheritedObjectGuid
!= NULL
)
357 pObjSid
->InheritedObjectTypeGuid
= *pInheritedObjectGuid
;
358 ObjectsPresent
|= ACE_INHERITED_OBJECT_TYPE_PRESENT
;
362 ZeroMemory(&pObjSid
->InheritedObjectTypeGuid
,
366 pObjSid
->ObjectsPresent
= ObjectsPresent
;
367 pObjSid
->pSid
= pSid
;
369 /* Fill the TRUSTEE structure */
370 pTrustee
->pMultipleTrustee
= NULL
;
371 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
372 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_SID
;
373 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
374 pTrustee
->ptstrName
= (LPWSTR
) pObjSid
;
378 /******************************************************************************
379 * GetMultipleTrusteeA [ADVAPI32.@]
382 GetMultipleTrusteeA(PTRUSTEE_A pTrustee
)
384 return pTrustee
->pMultipleTrustee
;
388 /******************************************************************************
389 * GetMultipleTrusteeW [ADVAPI32.@]
392 GetMultipleTrusteeW(PTRUSTEE_W pTrustee
)
394 return pTrustee
->pMultipleTrustee
;
398 /******************************************************************************
399 * GetMultipleTrusteeOperationA [ADVAPI32.@]
401 MULTIPLE_TRUSTEE_OPERATION WINAPI
402 GetMultipleTrusteeOperationA(PTRUSTEE_A pTrustee
)
404 return pTrustee
->MultipleTrusteeOperation
;
408 /******************************************************************************
409 * GetMultipleTrusteeOperationW [ADVAPI32.@]
411 MULTIPLE_TRUSTEE_OPERATION WINAPI
412 GetMultipleTrusteeOperationW(PTRUSTEE_W pTrustee
)
414 return pTrustee
->MultipleTrusteeOperation
;
418 /******************************************************************************
419 * GetTrusteeFormW [ADVAPI32.@]
422 GetTrusteeFormA(PTRUSTEE_A pTrustee
)
424 return pTrustee
->TrusteeForm
;
428 /******************************************************************************
429 * GetTrusteeFormW [ADVAPI32.@]
432 GetTrusteeFormW(PTRUSTEE_W pTrustee
)
434 return pTrustee
->TrusteeForm
;
438 /******************************************************************************
439 * GetTrusteeNameA [ADVAPI32.@]
442 GetTrusteeNameA(PTRUSTEE_A pTrustee
)
444 return pTrustee
->ptstrName
;
448 /******************************************************************************
449 * GetTrusteeNameW [ADVAPI32.@]
452 GetTrusteeNameW(PTRUSTEE_W pTrustee
)
454 return pTrustee
->ptstrName
;
458 /******************************************************************************
459 * GetTrusteeTypeA [ADVAPI32.@]
462 GetTrusteeTypeA(PTRUSTEE_A pTrustee
)
464 return pTrustee
->TrusteeType
;
468 /******************************************************************************
469 * GetTrusteeTypeW [ADVAPI32.@]
472 GetTrusteeTypeW(PTRUSTEE_W pTrustee
)
474 return pTrustee
->TrusteeType
;