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