- Implement AddAccessAllowedAceEx, AddAccessDeniedAceEx and AddAuditAccessAceEx.
[reactos.git] / reactos / lib / advapi32 / sec / ac.c
1 /* $Id: ac.c,v 1.11 2004/09/13 12:14:11 ekohl Exp $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/advapi32/sec/ac.c
6 * PURPOSE: ACL/ACE functions
7 */
8
9 #include "advapi32.h"
10
11
12 /* --- ACL --- */
13
14 /*
15 * @implemented
16 */
17 BOOL
18 STDCALL
19 GetAclInformation (
20 PACL pAcl,
21 LPVOID pAclInformation,
22 DWORD nAclInformationLength,
23 ACL_INFORMATION_CLASS dwAclInformationClass
24 )
25 {
26 NTSTATUS Status;
27
28 Status = RtlQueryInformationAcl (pAcl,
29 pAclInformation,
30 nAclInformationLength,
31 dwAclInformationClass);
32 if (!NT_SUCCESS(Status))
33 {
34 SetLastError (RtlNtStatusToDosError (Status));
35 return FALSE;
36 }
37
38 return TRUE;
39 }
40
41
42 /*
43 * @implemented
44 */
45 BOOL
46 STDCALL
47 InitializeAcl (
48 PACL pAcl,
49 DWORD nAclLength,
50 DWORD dwAclRevision
51 )
52 {
53 NTSTATUS Status;
54
55 Status = RtlCreateAcl (pAcl,
56 nAclLength,
57 dwAclRevision);
58 if (!NT_SUCCESS(Status))
59 {
60 SetLastError (RtlNtStatusToDosError (Status));
61 return FALSE;
62 }
63
64 return TRUE;
65 }
66
67
68 /*
69 * @implemented
70 */
71 BOOL
72 STDCALL
73 IsValidAcl (
74 PACL pAcl
75 )
76 {
77 return RtlValidAcl (pAcl);
78 }
79
80
81 /*
82 * @implemented
83 */
84 BOOL
85 STDCALL
86 SetAclInformation (
87 PACL pAcl,
88 LPVOID pAclInformation,
89 DWORD nAclInformationLength,
90 ACL_INFORMATION_CLASS dwAclInformationClass
91 )
92 {
93 NTSTATUS Status;
94
95 Status = RtlSetInformationAcl (pAcl,
96 pAclInformation,
97 nAclInformationLength,
98 dwAclInformationClass);
99 if (!NT_SUCCESS(Status))
100 {
101 SetLastError (RtlNtStatusToDosError (Status));
102 return FALSE;
103 }
104
105 return TRUE;
106 }
107
108
109 /* --- ACE --- */
110
111 /*
112 * @implemented
113 */
114 BOOL
115 STDCALL
116 AddAccessAllowedAce (
117 PACL pAcl,
118 DWORD dwAceRevision,
119 DWORD AccessMask,
120 PSID pSid
121 )
122 {
123 NTSTATUS Status;
124
125 Status = RtlAddAccessAllowedAce (pAcl,
126 dwAceRevision,
127 AccessMask,
128 pSid);
129 if (!NT_SUCCESS(Status))
130 {
131 SetLastError (RtlNtStatusToDosError (Status));
132 return FALSE;
133 }
134
135 return TRUE;
136 }
137
138
139 /*
140 * @implemented
141 */
142 BOOL STDCALL
143 AddAccessAllowedAceEx(PACL pAcl,
144 DWORD dwAceRevision,
145 DWORD AceFlags,
146 DWORD AccessMask,
147 PSID pSid)
148 {
149 NTSTATUS Status;
150
151 Status = RtlAddAccessAllowedAceEx(pAcl,
152 dwAceRevision,
153 AceFlags,
154 AccessMask,
155 pSid);
156 if (!NT_SUCCESS(Status))
157 {
158 SetLastError(RtlNtStatusToDosError(Status));
159 return FALSE;
160 }
161
162 return TRUE;
163 }
164
165
166 /*
167 * @implemented
168 */
169 BOOL
170 STDCALL
171 AddAccessDeniedAce (
172 PACL pAcl,
173 DWORD dwAceRevision,
174 DWORD AccessMask,
175 PSID pSid
176 )
177 {
178 NTSTATUS Status;
179
180 Status = RtlAddAccessDeniedAce (pAcl,
181 dwAceRevision,
182 AccessMask,
183 pSid);
184 if (!NT_SUCCESS(Status))
185 {
186 SetLastError (RtlNtStatusToDosError (Status));
187 return FALSE;
188 }
189
190 return TRUE;
191 }
192
193
194 /*
195 * @implemented
196 */
197 BOOL STDCALL
198 AddAccessDeniedAceEx(PACL pAcl,
199 DWORD dwAceRevision,
200 DWORD AceFlags,
201 DWORD AccessMask,
202 PSID pSid)
203 {
204 NTSTATUS Status;
205
206 Status = RtlAddAccessDeniedAceEx(pAcl,
207 dwAceRevision,
208 AceFlags,
209 AccessMask,
210 pSid);
211 if (!NT_SUCCESS(Status))
212 {
213 SetLastError(RtlNtStatusToDosError(Status));
214 return FALSE;
215 }
216
217 return TRUE;
218 }
219
220
221 /*
222 * @implemented
223 */
224 BOOL
225 STDCALL
226 AddAce (
227 PACL pAcl,
228 DWORD dwAceRevision,
229 DWORD dwStartingAceIndex,
230 LPVOID pAceList,
231 DWORD nAceListLength
232 )
233 {
234 NTSTATUS Status;
235
236 Status = RtlAddAce (pAcl,
237 dwAceRevision,
238 dwStartingAceIndex,
239 pAceList,
240 nAceListLength);
241 if (!NT_SUCCESS(Status))
242 {
243 SetLastError (RtlNtStatusToDosError (Status));
244 return FALSE;
245 }
246
247 return TRUE;
248 }
249
250
251 /*
252 * @implemented
253 */
254 BOOL
255 STDCALL
256 AddAuditAccessAce (
257 PACL pAcl,
258 DWORD dwAceRevision,
259 DWORD dwAccessMask,
260 PSID pSid,
261 BOOL bAuditSuccess,
262 BOOL bAuditFailure
263 )
264 {
265 NTSTATUS Status;
266
267 Status = RtlAddAuditAccessAce (pAcl,
268 dwAceRevision,
269 dwAccessMask,
270 pSid,
271 bAuditSuccess,
272 bAuditFailure);
273 if (!NT_SUCCESS(Status))
274 {
275 SetLastError (RtlNtStatusToDosError (Status));
276 return FALSE;
277 }
278
279 return TRUE;
280 }
281
282
283 /*
284 * @implemented
285 */
286 BOOL STDCALL
287 AddAuditAccessAceEx(PACL pAcl,
288 DWORD dwAceRevision,
289 DWORD AceFlags,
290 DWORD dwAccessMask,
291 PSID pSid,
292 BOOL bAuditSuccess,
293 BOOL bAuditFailure)
294 {
295 NTSTATUS Status;
296
297 Status = RtlAddAuditAccessAceEx(pAcl,
298 dwAceRevision,
299 AceFlags,
300 dwAccessMask,
301 pSid,
302 bAuditSuccess,
303 bAuditFailure);
304 if (!NT_SUCCESS(Status))
305 {
306 SetLastError(RtlNtStatusToDosError(Status));
307 return FALSE;
308 }
309
310 return TRUE;
311 }
312
313
314 /*
315 * @implemented
316 */
317 BOOL
318 STDCALL
319 DeleteAce (
320 PACL pAcl,
321 DWORD dwAceIndex
322 )
323 {
324 NTSTATUS Status;
325
326 Status = RtlDeleteAce (pAcl,
327 dwAceIndex);
328 if (!NT_SUCCESS(Status))
329 {
330 SetLastError (RtlNtStatusToDosError (Status));
331 return FALSE;
332 }
333
334 return TRUE;
335 }
336
337
338 /*
339 * @implemented
340 */
341 BOOL
342 STDCALL
343 FindFirstFreeAce (
344 PACL pAcl,
345 LPVOID * pAce
346 )
347 {
348 return RtlFirstFreeAce (pAcl,
349 (PACE*)pAce);
350 }
351
352
353 /*
354 * @implemented
355 */
356 BOOL
357 STDCALL
358 GetAce (
359 PACL pAcl,
360 DWORD dwAceIndex,
361 LPVOID * pAce
362 )
363 {
364 NTSTATUS Status;
365
366 Status = RtlGetAce (pAcl,
367 dwAceIndex,
368 (PACE*)pAce);
369 if (!NT_SUCCESS(Status))
370 {
371 SetLastError (RtlNtStatusToDosError (Status));
372 return FALSE;
373 }
374
375 return TRUE;
376 }
377
378 /* EOF */