2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/advapi32/sec/trustee.c
5 * PURPOSE: Trustee functions
9 WINE_DEFAULT_DEBUG_CHANNEL(advapi
);
12 /******************************************************************************
13 * BuildImpersonateTrusteeA [ADVAPI32.@]
16 BuildImpersonateTrusteeA(PTRUSTEE_A pTrustee
,
17 PTRUSTEE_A pImpersonateTrustee
)
19 pTrustee
->pMultipleTrustee
= pImpersonateTrustee
;
20 pTrustee
->MultipleTrusteeOperation
= TRUSTEE_IS_IMPERSONATE
;
24 /******************************************************************************
25 * BuildImpersonateTrusteeW [ADVAPI32.@]
28 BuildImpersonateTrusteeW(PTRUSTEE_W pTrustee
,
29 PTRUSTEE_W pImpersonateTrustee
)
31 pTrustee
->pMultipleTrustee
= pImpersonateTrustee
;
32 pTrustee
->MultipleTrusteeOperation
= TRUSTEE_IS_IMPERSONATE
;
36 /******************************************************************************
37 * BuildExplicitAccessWithNameA [ADVAPI32.@]
40 BuildExplicitAccessWithNameA(PEXPLICIT_ACCESSA pExplicitAccess
,
42 DWORD AccessPermissions
,
43 ACCESS_MODE AccessMode
,
46 pExplicitAccess
->grfAccessPermissions
= AccessPermissions
;
47 pExplicitAccess
->grfAccessMode
= AccessMode
;
48 pExplicitAccess
->grfInheritance
= Inheritance
;
50 pExplicitAccess
->Trustee
.pMultipleTrustee
= NULL
;
51 pExplicitAccess
->Trustee
.MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
52 pExplicitAccess
->Trustee
.TrusteeForm
= TRUSTEE_IS_NAME
;
53 pExplicitAccess
->Trustee
.TrusteeType
= TRUSTEE_IS_UNKNOWN
;
54 pExplicitAccess
->Trustee
.ptstrName
= pTrusteeName
;
58 /******************************************************************************
59 * BuildExplicitAccessWithNameW [ADVAPI32.@]
62 BuildExplicitAccessWithNameW(PEXPLICIT_ACCESSW pExplicitAccess
,
64 DWORD AccessPermissions
,
65 ACCESS_MODE AccessMode
,
68 pExplicitAccess
->grfAccessPermissions
= AccessPermissions
;
69 pExplicitAccess
->grfAccessMode
= AccessMode
;
70 pExplicitAccess
->grfInheritance
= Inheritance
;
72 pExplicitAccess
->Trustee
.pMultipleTrustee
= NULL
;
73 pExplicitAccess
->Trustee
.MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
74 pExplicitAccess
->Trustee
.TrusteeForm
= TRUSTEE_IS_NAME
;
75 pExplicitAccess
->Trustee
.TrusteeType
= TRUSTEE_IS_UNKNOWN
;
76 pExplicitAccess
->Trustee
.ptstrName
= pTrusteeName
;
80 /******************************************************************************
81 * BuildImpersonateExplicitAccessWithNameA [ADVAPI32.@]
84 BuildImpersonateExplicitAccessWithNameA(PEXPLICIT_ACCESS_A pExplicitAccess
,
87 DWORD AccessPermissions
,
88 ACCESS_MODE AccessMode
,
91 pExplicitAccess
->grfAccessPermissions
= AccessPermissions
;
92 pExplicitAccess
->grfAccessMode
= AccessMode
;
93 pExplicitAccess
->grfInheritance
= Inheritance
;
95 pExplicitAccess
->Trustee
.pMultipleTrustee
= pTrustee
;
96 pExplicitAccess
->Trustee
.MultipleTrusteeOperation
= TRUSTEE_IS_IMPERSONATE
;
97 pExplicitAccess
->Trustee
.TrusteeForm
= TRUSTEE_IS_NAME
;
98 pExplicitAccess
->Trustee
.TrusteeType
= TRUSTEE_IS_UNKNOWN
;
99 pExplicitAccess
->Trustee
.ptstrName
= pTrusteeName
;
103 /******************************************************************************
104 * BuildImpersonateExplicitAccessWithNameW [ADVAPI32.@]
107 BuildImpersonateExplicitAccessWithNameW(PEXPLICIT_ACCESS_W pExplicitAccess
,
110 DWORD AccessPermissions
,
111 ACCESS_MODE AccessMode
,
114 pExplicitAccess
->grfAccessPermissions
= AccessPermissions
;
115 pExplicitAccess
->grfAccessMode
= AccessMode
;
116 pExplicitAccess
->grfInheritance
= Inheritance
;
118 pExplicitAccess
->Trustee
.pMultipleTrustee
= pTrustee
;
119 pExplicitAccess
->Trustee
.MultipleTrusteeOperation
= TRUSTEE_IS_IMPERSONATE
;
120 pExplicitAccess
->Trustee
.TrusteeForm
= TRUSTEE_IS_NAME
;
121 pExplicitAccess
->Trustee
.TrusteeType
= TRUSTEE_IS_UNKNOWN
;
122 pExplicitAccess
->Trustee
.ptstrName
= pTrusteeName
;
126 /******************************************************************************
127 * BuildTrusteeWithSidA [ADVAPI32.@]
130 BuildTrusteeWithSidA(PTRUSTEE_A pTrustee
,
133 TRACE("%p %p\n", pTrustee
, pSid
);
135 pTrustee
->pMultipleTrustee
= NULL
;
136 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
137 pTrustee
->TrusteeForm
= TRUSTEE_IS_SID
;
138 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
139 pTrustee
->ptstrName
= (LPSTR
) pSid
;
143 /******************************************************************************
144 * BuildTrusteeWithSidW [ADVAPI32.@]
147 BuildTrusteeWithSidW(PTRUSTEE_W pTrustee
,
150 TRACE("%p %p\n", pTrustee
, pSid
);
152 pTrustee
->pMultipleTrustee
= NULL
;
153 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
154 pTrustee
->TrusteeForm
= TRUSTEE_IS_SID
;
155 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
156 pTrustee
->ptstrName
= (LPWSTR
) pSid
;
160 /******************************************************************************
161 * BuildTrusteeWithNameA [ADVAPI32.@]
164 BuildTrusteeWithNameA(PTRUSTEE_A pTrustee
,
167 TRACE("%p %s\n", pTrustee
, name
);
169 pTrustee
->pMultipleTrustee
= NULL
;
170 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
171 pTrustee
->TrusteeForm
= TRUSTEE_IS_NAME
;
172 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
173 pTrustee
->ptstrName
= name
;
177 /******************************************************************************
178 * BuildTrusteeWithNameW [ADVAPI32.@]
181 BuildTrusteeWithNameW(PTRUSTEE_W pTrustee
,
184 TRACE("%p %s\n", pTrustee
, name
);
186 pTrustee
->pMultipleTrustee
= NULL
;
187 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
188 pTrustee
->TrusteeForm
= TRUSTEE_IS_NAME
;
189 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
190 pTrustee
->ptstrName
= name
;
194 /******************************************************************************
195 * BuildTrusteeWithObjectsAndNameA [ADVAPI32.@]
198 BuildTrusteeWithObjectsAndNameA(PTRUSTEEA pTrustee
,
199 POBJECTS_AND_NAME_A pObjName
,
200 SE_OBJECT_TYPE ObjectType
,
201 LPSTR ObjectTypeName
,
202 LPSTR InheritedObjectTypeName
,
205 DWORD ObjectsPresent
= 0;
207 TRACE("%p %p 0x%08x %p %p %s\n", pTrustee
, pObjName
,
208 ObjectType
, ObjectTypeName
, InheritedObjectTypeName
, Name
);
210 /* Fill the OBJECTS_AND_NAME structure */
211 pObjName
->ObjectType
= ObjectType
;
212 if (ObjectTypeName
!= NULL
)
214 ObjectsPresent
|= ACE_OBJECT_TYPE_PRESENT
;
217 pObjName
->InheritedObjectTypeName
= InheritedObjectTypeName
;
218 if (InheritedObjectTypeName
!= NULL
)
220 ObjectsPresent
|= ACE_INHERITED_OBJECT_TYPE_PRESENT
;
223 pObjName
->ObjectsPresent
= ObjectsPresent
;
224 pObjName
->ptstrName
= Name
;
226 /* Fill the TRUSTEE structure */
227 pTrustee
->pMultipleTrustee
= NULL
;
228 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
229 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_NAME
;
230 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
231 pTrustee
->ptstrName
= (LPSTR
)pObjName
;
235 /******************************************************************************
236 * BuildTrusteeWithObjectsAndNameW [ADVAPI32.@]
239 BuildTrusteeWithObjectsAndNameW(PTRUSTEEW pTrustee
,
240 POBJECTS_AND_NAME_W pObjName
,
241 SE_OBJECT_TYPE ObjectType
,
242 LPWSTR ObjectTypeName
,
243 LPWSTR InheritedObjectTypeName
,
246 DWORD ObjectsPresent
= 0;
248 TRACE("%p %p 0x%08x %p %p %s\n", pTrustee
, pObjName
,
249 ObjectType
, ObjectTypeName
, InheritedObjectTypeName
, Name
);
251 /* Fill the OBJECTS_AND_NAME structure */
252 pObjName
->ObjectType
= ObjectType
;
253 if (ObjectTypeName
!= NULL
)
255 ObjectsPresent
|= ACE_OBJECT_TYPE_PRESENT
;
258 pObjName
->InheritedObjectTypeName
= InheritedObjectTypeName
;
259 if (InheritedObjectTypeName
!= NULL
)
261 ObjectsPresent
|= ACE_INHERITED_OBJECT_TYPE_PRESENT
;
264 pObjName
->ObjectsPresent
= ObjectsPresent
;
265 pObjName
->ptstrName
= Name
;
267 /* Fill the TRUSTEE structure */
268 pTrustee
->pMultipleTrustee
= NULL
;
269 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
270 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_NAME
;
271 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
272 pTrustee
->ptstrName
= (LPWSTR
)pObjName
;
276 /******************************************************************************
277 * BuildTrusteeWithObjectsAndSidA [ADVAPI32.@]
280 BuildTrusteeWithObjectsAndSidA(PTRUSTEEA pTrustee
,
281 POBJECTS_AND_SID pObjSid
,
283 GUID
*pInheritedObjectGuid
,
286 DWORD ObjectsPresent
= 0;
288 TRACE("%p %p %p %p %p\n", pTrustee
, pObjSid
, pObjectGuid
, pInheritedObjectGuid
, pSid
);
290 /* Fill the OBJECTS_AND_SID structure */
291 if (pObjectGuid
!= NULL
)
293 pObjSid
->ObjectTypeGuid
= *pObjectGuid
;
294 ObjectsPresent
|= ACE_OBJECT_TYPE_PRESENT
;
298 ZeroMemory(&pObjSid
->ObjectTypeGuid
,
302 if (pInheritedObjectGuid
!= NULL
)
304 pObjSid
->InheritedObjectTypeGuid
= *pInheritedObjectGuid
;
305 ObjectsPresent
|= ACE_INHERITED_OBJECT_TYPE_PRESENT
;
309 ZeroMemory(&pObjSid
->InheritedObjectTypeGuid
,
313 pObjSid
->ObjectsPresent
= ObjectsPresent
;
314 pObjSid
->pSid
= pSid
;
316 /* Fill the TRUSTEE structure */
317 pTrustee
->pMultipleTrustee
= NULL
;
318 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
319 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_SID
;
320 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
321 pTrustee
->ptstrName
= (LPSTR
) pObjSid
;
325 /******************************************************************************
326 * BuildTrusteeWithObjectsAndSidW [ADVAPI32.@]
329 BuildTrusteeWithObjectsAndSidW(PTRUSTEEW pTrustee
,
330 POBJECTS_AND_SID pObjSid
,
332 GUID
*pInheritedObjectGuid
,
335 DWORD ObjectsPresent
= 0;
337 TRACE("%p %p %p %p %p\n", pTrustee
, pObjSid
, pObjectGuid
, pInheritedObjectGuid
, pSid
);
339 /* Fill the OBJECTS_AND_SID structure */
340 if (pObjectGuid
!= NULL
)
342 pObjSid
->ObjectTypeGuid
= *pObjectGuid
;
343 ObjectsPresent
|= ACE_OBJECT_TYPE_PRESENT
;
347 ZeroMemory(&pObjSid
->ObjectTypeGuid
,
351 if (pInheritedObjectGuid
!= NULL
)
353 pObjSid
->InheritedObjectTypeGuid
= *pInheritedObjectGuid
;
354 ObjectsPresent
|= ACE_INHERITED_OBJECT_TYPE_PRESENT
;
358 ZeroMemory(&pObjSid
->InheritedObjectTypeGuid
,
362 pObjSid
->ObjectsPresent
= ObjectsPresent
;
363 pObjSid
->pSid
= pSid
;
365 /* Fill the TRUSTEE structure */
366 pTrustee
->pMultipleTrustee
= NULL
;
367 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
368 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_SID
;
369 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
370 pTrustee
->ptstrName
= (LPWSTR
) pObjSid
;
374 /******************************************************************************
375 * GetMultipleTrusteeA [ADVAPI32.@]
378 GetMultipleTrusteeA(PTRUSTEE_A pTrustee
)
380 return pTrustee
->pMultipleTrustee
;
384 /******************************************************************************
385 * GetMultipleTrusteeW [ADVAPI32.@]
388 GetMultipleTrusteeW(PTRUSTEE_W pTrustee
)
390 return pTrustee
->pMultipleTrustee
;
394 /******************************************************************************
395 * GetMultipleTrusteeOperationA [ADVAPI32.@]
397 MULTIPLE_TRUSTEE_OPERATION WINAPI
398 GetMultipleTrusteeOperationA(PTRUSTEE_A pTrustee
)
400 return pTrustee
->MultipleTrusteeOperation
;
404 /******************************************************************************
405 * GetMultipleTrusteeOperationW [ADVAPI32.@]
407 MULTIPLE_TRUSTEE_OPERATION WINAPI
408 GetMultipleTrusteeOperationW(PTRUSTEE_W pTrustee
)
410 return pTrustee
->MultipleTrusteeOperation
;
414 /******************************************************************************
415 * GetTrusteeFormW [ADVAPI32.@]
418 GetTrusteeFormA(PTRUSTEE_A pTrustee
)
420 return pTrustee
->TrusteeForm
;
424 /******************************************************************************
425 * GetTrusteeFormW [ADVAPI32.@]
428 GetTrusteeFormW(PTRUSTEE_W pTrustee
)
430 return pTrustee
->TrusteeForm
;
434 /******************************************************************************
435 * GetTrusteeNameA [ADVAPI32.@]
438 GetTrusteeNameA(PTRUSTEE_A pTrustee
)
440 return pTrustee
->ptstrName
;
444 /******************************************************************************
445 * GetTrusteeNameW [ADVAPI32.@]
448 GetTrusteeNameW(PTRUSTEE_W pTrustee
)
450 return pTrustee
->ptstrName
;
454 /******************************************************************************
455 * GetTrusteeTypeA [ADVAPI32.@]
458 GetTrusteeTypeA(PTRUSTEE_A pTrustee
)
460 return pTrustee
->TrusteeType
;
464 /******************************************************************************
465 * GetTrusteeTypeW [ADVAPI32.@]
468 GetTrusteeTypeW(PTRUSTEE_W pTrustee
)
470 return pTrustee
->TrusteeType
;