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