9b62f7954aa69ff214ed00ac82a9532b2fd83745
[reactos.git] / dll / win32 / advapi32 / sec / trustee.c
1 /*
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
6 */
7
8 #include <advapi32.h>
9 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
10
11
12 /******************************************************************************
13 * BuildImpersonateTrusteeA [ADVAPI32.@]
14 */
15 VOID WINAPI
16 BuildImpersonateTrusteeA(PTRUSTEE_A pTrustee,
17 PTRUSTEE_A pImpersonateTrustee)
18 {
19 pTrustee->pMultipleTrustee = pImpersonateTrustee;
20 pTrustee->MultipleTrusteeOperation = TRUSTEE_IS_IMPERSONATE;
21 }
22
23
24 /******************************************************************************
25 * BuildImpersonateTrusteeW [ADVAPI32.@]
26 */
27 VOID WINAPI
28 BuildImpersonateTrusteeW(PTRUSTEE_W pTrustee,
29 PTRUSTEE_W pImpersonateTrustee)
30 {
31 pTrustee->pMultipleTrustee = pImpersonateTrustee;
32 pTrustee->MultipleTrusteeOperation = TRUSTEE_IS_IMPERSONATE;
33 }
34
35
36 /******************************************************************************
37 * BuildExplicitAccessWithNameA [ADVAPI32.@]
38 */
39 VOID WINAPI
40 BuildExplicitAccessWithNameA(PEXPLICIT_ACCESSA pExplicitAccess,
41 LPSTR pTrusteeName,
42 DWORD AccessPermissions,
43 ACCESS_MODE AccessMode,
44 DWORD Inheritance)
45 {
46 pExplicitAccess->grfAccessPermissions = AccessPermissions;
47 pExplicitAccess->grfAccessMode = AccessMode;
48 pExplicitAccess->grfInheritance = Inheritance;
49
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;
55 }
56
57
58 /******************************************************************************
59 * BuildExplicitAccessWithNameW [ADVAPI32.@]
60 */
61 VOID WINAPI
62 BuildExplicitAccessWithNameW(PEXPLICIT_ACCESSW pExplicitAccess,
63 LPWSTR pTrusteeName,
64 DWORD AccessPermissions,
65 ACCESS_MODE AccessMode,
66 DWORD Inheritance)
67 {
68 pExplicitAccess->grfAccessPermissions = AccessPermissions;
69 pExplicitAccess->grfAccessMode = AccessMode;
70 pExplicitAccess->grfInheritance = Inheritance;
71
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;
77 }
78
79
80 /******************************************************************************
81 * BuildImpersonateExplicitAccessWithNameA [ADVAPI32.@]
82 */
83 VOID WINAPI
84 BuildImpersonateExplicitAccessWithNameA(PEXPLICIT_ACCESS_A pExplicitAccess,
85 LPSTR pTrusteeName,
86 PTRUSTEE_A pTrustee,
87 DWORD AccessPermissions,
88 ACCESS_MODE AccessMode,
89 DWORD Inheritance)
90 {
91 pExplicitAccess->grfAccessPermissions = AccessPermissions;
92 pExplicitAccess->grfAccessMode = AccessMode;
93 pExplicitAccess->grfInheritance = Inheritance;
94
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;
100 }
101
102
103 /******************************************************************************
104 * BuildImpersonateExplicitAccessWithNameW [ADVAPI32.@]
105 */
106 VOID WINAPI
107 BuildImpersonateExplicitAccessWithNameW(PEXPLICIT_ACCESS_W pExplicitAccess,
108 LPWSTR pTrusteeName,
109 PTRUSTEE_W pTrustee,
110 DWORD AccessPermissions,
111 ACCESS_MODE AccessMode,
112 DWORD Inheritance)
113 {
114 pExplicitAccess->grfAccessPermissions = AccessPermissions;
115 pExplicitAccess->grfAccessMode = AccessMode;
116 pExplicitAccess->grfInheritance = Inheritance;
117
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;
123 }
124
125
126 /******************************************************************************
127 * BuildTrusteeWithSidA [ADVAPI32.@]
128 */
129 VOID WINAPI
130 BuildTrusteeWithSidA(PTRUSTEE_A pTrustee,
131 PSID pSid)
132 {
133 TRACE("%p %p\n", pTrustee, pSid);
134
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;
140 }
141
142
143 /******************************************************************************
144 * BuildTrusteeWithSidW [ADVAPI32.@]
145 */
146 VOID WINAPI
147 BuildTrusteeWithSidW(PTRUSTEE_W pTrustee,
148 PSID pSid)
149 {
150 TRACE("%p %p\n", pTrustee, pSid);
151
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;
157 }
158
159
160 /******************************************************************************
161 * BuildTrusteeWithNameA [ADVAPI32.@]
162 */
163 VOID WINAPI
164 BuildTrusteeWithNameA(PTRUSTEE_A pTrustee,
165 LPSTR name)
166 {
167 TRACE("%p %s\n", pTrustee, name);
168
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;
174 }
175
176
177 /******************************************************************************
178 * BuildTrusteeWithNameW [ADVAPI32.@]
179 */
180 VOID WINAPI
181 BuildTrusteeWithNameW(PTRUSTEE_W pTrustee,
182 LPWSTR name)
183 {
184 TRACE("%p %s\n", pTrustee, name);
185
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;
191 }
192
193
194 /******************************************************************************
195 * BuildTrusteeWithObjectsAndNameA [ADVAPI32.@]
196 */
197 VOID WINAPI
198 BuildTrusteeWithObjectsAndNameA(PTRUSTEEA pTrustee,
199 POBJECTS_AND_NAME_A pObjName,
200 SE_OBJECT_TYPE ObjectType,
201 LPSTR ObjectTypeName,
202 LPSTR InheritedObjectTypeName,
203 LPSTR Name)
204 {
205 DWORD ObjectsPresent = 0;
206
207 TRACE("%p %p 0x%08x %p %p %s\n", pTrustee, pObjName,
208 ObjectType, ObjectTypeName, InheritedObjectTypeName, Name);
209
210 /* Fill the OBJECTS_AND_NAME structure */
211 pObjName->ObjectType = ObjectType;
212 if (ObjectTypeName != NULL)
213 {
214 ObjectsPresent |= ACE_OBJECT_TYPE_PRESENT;
215 }
216
217 pObjName->InheritedObjectTypeName = InheritedObjectTypeName;
218 if (InheritedObjectTypeName != NULL)
219 {
220 ObjectsPresent |= ACE_INHERITED_OBJECT_TYPE_PRESENT;
221 }
222
223 pObjName->ObjectsPresent = ObjectsPresent;
224 pObjName->ptstrName = Name;
225
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;
232 }
233
234
235 /******************************************************************************
236 * BuildTrusteeWithObjectsAndNameW [ADVAPI32.@]
237 */
238 VOID WINAPI
239 BuildTrusteeWithObjectsAndNameW(PTRUSTEEW pTrustee,
240 POBJECTS_AND_NAME_W pObjName,
241 SE_OBJECT_TYPE ObjectType,
242 LPWSTR ObjectTypeName,
243 LPWSTR InheritedObjectTypeName,
244 LPWSTR Name)
245 {
246 DWORD ObjectsPresent = 0;
247
248 TRACE("%p %p 0x%08x %p %p %s\n", pTrustee, pObjName,
249 ObjectType, ObjectTypeName, InheritedObjectTypeName, Name);
250
251 /* Fill the OBJECTS_AND_NAME structure */
252 pObjName->ObjectType = ObjectType;
253 if (ObjectTypeName != NULL)
254 {
255 ObjectsPresent |= ACE_OBJECT_TYPE_PRESENT;
256 }
257
258 pObjName->InheritedObjectTypeName = InheritedObjectTypeName;
259 if (InheritedObjectTypeName != NULL)
260 {
261 ObjectsPresent |= ACE_INHERITED_OBJECT_TYPE_PRESENT;
262 }
263
264 pObjName->ObjectsPresent = ObjectsPresent;
265 pObjName->ptstrName = Name;
266
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;
273 }
274
275
276 /******************************************************************************
277 * BuildTrusteeWithObjectsAndSidA [ADVAPI32.@]
278 */
279 VOID WINAPI
280 BuildTrusteeWithObjectsAndSidA(PTRUSTEEA pTrustee,
281 POBJECTS_AND_SID pObjSid,
282 GUID *pObjectGuid,
283 GUID *pInheritedObjectGuid,
284 PSID pSid)
285 {
286 DWORD ObjectsPresent = 0;
287
288 TRACE("%p %p %p %p %p\n", pTrustee, pObjSid, pObjectGuid, pInheritedObjectGuid, pSid);
289
290 /* Fill the OBJECTS_AND_SID structure */
291 if (pObjectGuid != NULL)
292 {
293 pObjSid->ObjectTypeGuid = *pObjectGuid;
294 ObjectsPresent |= ACE_OBJECT_TYPE_PRESENT;
295 }
296 else
297 {
298 ZeroMemory(&pObjSid->ObjectTypeGuid,
299 sizeof(GUID));
300 }
301
302 if (pInheritedObjectGuid != NULL)
303 {
304 pObjSid->InheritedObjectTypeGuid = *pInheritedObjectGuid;
305 ObjectsPresent |= ACE_INHERITED_OBJECT_TYPE_PRESENT;
306 }
307 else
308 {
309 ZeroMemory(&pObjSid->InheritedObjectTypeGuid,
310 sizeof(GUID));
311 }
312
313 pObjSid->ObjectsPresent = ObjectsPresent;
314 pObjSid->pSid = pSid;
315
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;
322 }
323
324
325 /******************************************************************************
326 * BuildTrusteeWithObjectsAndSidW [ADVAPI32.@]
327 */
328 VOID WINAPI
329 BuildTrusteeWithObjectsAndSidW(PTRUSTEEW pTrustee,
330 POBJECTS_AND_SID pObjSid,
331 GUID *pObjectGuid,
332 GUID *pInheritedObjectGuid,
333 PSID pSid)
334 {
335 DWORD ObjectsPresent = 0;
336
337 TRACE("%p %p %p %p %p\n", pTrustee, pObjSid, pObjectGuid, pInheritedObjectGuid, pSid);
338
339 /* Fill the OBJECTS_AND_SID structure */
340 if (pObjectGuid != NULL)
341 {
342 pObjSid->ObjectTypeGuid = *pObjectGuid;
343 ObjectsPresent |= ACE_OBJECT_TYPE_PRESENT;
344 }
345 else
346 {
347 ZeroMemory(&pObjSid->ObjectTypeGuid,
348 sizeof(GUID));
349 }
350
351 if (pInheritedObjectGuid != NULL)
352 {
353 pObjSid->InheritedObjectTypeGuid = *pInheritedObjectGuid;
354 ObjectsPresent |= ACE_INHERITED_OBJECT_TYPE_PRESENT;
355 }
356 else
357 {
358 ZeroMemory(&pObjSid->InheritedObjectTypeGuid,
359 sizeof(GUID));
360 }
361
362 pObjSid->ObjectsPresent = ObjectsPresent;
363 pObjSid->pSid = pSid;
364
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;
371 }
372
373
374 /******************************************************************************
375 * GetMultipleTrusteeA [ADVAPI32.@]
376 */
377 PTRUSTEEA WINAPI
378 GetMultipleTrusteeA(PTRUSTEE_A pTrustee)
379 {
380 return pTrustee->pMultipleTrustee;
381 }
382
383
384 /******************************************************************************
385 * GetMultipleTrusteeW [ADVAPI32.@]
386 */
387 PTRUSTEEW WINAPI
388 GetMultipleTrusteeW(PTRUSTEE_W pTrustee)
389 {
390 return pTrustee->pMultipleTrustee;
391 }
392
393
394 /******************************************************************************
395 * GetMultipleTrusteeOperationA [ADVAPI32.@]
396 */
397 MULTIPLE_TRUSTEE_OPERATION WINAPI
398 GetMultipleTrusteeOperationA(PTRUSTEE_A pTrustee)
399 {
400 return pTrustee->MultipleTrusteeOperation;
401 }
402
403
404 /******************************************************************************
405 * GetMultipleTrusteeOperationW [ADVAPI32.@]
406 */
407 MULTIPLE_TRUSTEE_OPERATION WINAPI
408 GetMultipleTrusteeOperationW(PTRUSTEE_W pTrustee)
409 {
410 return pTrustee->MultipleTrusteeOperation;
411 }
412
413
414 /******************************************************************************
415 * GetTrusteeFormW [ADVAPI32.@]
416 */
417 TRUSTEE_FORM WINAPI
418 GetTrusteeFormA(PTRUSTEE_A pTrustee)
419 {
420 return pTrustee->TrusteeForm;
421 }
422
423
424 /******************************************************************************
425 * GetTrusteeFormW [ADVAPI32.@]
426 */
427 TRUSTEE_FORM WINAPI
428 GetTrusteeFormW(PTRUSTEE_W pTrustee)
429 {
430 return pTrustee->TrusteeForm;
431 }
432
433
434 /******************************************************************************
435 * GetTrusteeNameA [ADVAPI32.@]
436 */
437 LPSTR WINAPI
438 GetTrusteeNameA(PTRUSTEE_A pTrustee)
439 {
440 return pTrustee->ptstrName;
441 }
442
443
444 /******************************************************************************
445 * GetTrusteeNameW [ADVAPI32.@]
446 */
447 LPWSTR WINAPI
448 GetTrusteeNameW(PTRUSTEE_W pTrustee)
449 {
450 return pTrustee->ptstrName;
451 }
452
453
454 /******************************************************************************
455 * GetTrusteeTypeA [ADVAPI32.@]
456 */
457 TRUSTEE_TYPE WINAPI
458 GetTrusteeTypeA(PTRUSTEE_A pTrustee)
459 {
460 return pTrustee->TrusteeType;
461 }
462
463
464 /******************************************************************************
465 * GetTrusteeTypeW [ADVAPI32.@]
466 */
467 TRUSTEE_TYPE WINAPI
468 GetTrusteeTypeW(PTRUSTEE_W pTrustee)
469 {
470 return pTrustee->TrusteeType;
471 }
472
473 /* EOF */