update for HEAD-2003091401
[reactos.git] / lib / advapi32 / sec / sid.c
1 /* $Id$
2  *
3  * COPYRIGHT:       See COPYING in the top level directory
4  * PROJECT:         ReactOS system libraries
5  * FILE:            lib/advapi32/sec/sid.c
6  * PURPOSE:         Security ID functions
7  */
8
9 #define NTOS_MODE_USER
10 #include <ntos.h>
11 #include <windows.h>
12
13
14 /*
15  * @implemented
16  */
17 BOOL STDCALL
18 AllocateLocallyUniqueId(PLUID Luid)
19 {
20    NTSTATUS Status;
21
22    Status = NtAllocateLocallyUniqueId(Luid);
23    if (!NT_SUCCESS(Status))
24      {
25         SetLastError(RtlNtStatusToDosError(Status));
26         return(FALSE);
27      }
28    return(TRUE);
29 }
30
31
32 /*
33  * @implemented
34  */
35 BOOL STDCALL
36 AllocateAndInitializeSid (
37         PSID_IDENTIFIER_AUTHORITY       pIdentifierAuthority,
38         BYTE                            nSubAuthorityCount,
39         DWORD                           dwSubAuthority0,
40         DWORD                           dwSubAuthority1,
41         DWORD                           dwSubAuthority2,
42         DWORD                           dwSubAuthority3,
43         DWORD                           dwSubAuthority4,
44         DWORD                           dwSubAuthority5,
45         DWORD                           dwSubAuthority6,
46         DWORD                           dwSubAuthority7,
47         PSID                            *pSid
48 )
49 {
50         NTSTATUS Status;
51
52         Status = RtlAllocateAndInitializeSid (pIdentifierAuthority,
53                                               nSubAuthorityCount,
54                                               dwSubAuthority0,
55                                               dwSubAuthority1,
56                                               dwSubAuthority2,
57                                               dwSubAuthority3,
58                                               dwSubAuthority4,
59                                               dwSubAuthority5,
60                                               dwSubAuthority6,
61                                               dwSubAuthority7,
62                                               pSid);
63         if (!NT_SUCCESS(Status))
64         {
65                 SetLastError (RtlNtStatusToDosError (Status));
66                 return FALSE;
67         }
68
69         return TRUE;
70 }
71
72
73 /*
74  * @implemented
75  */
76 BOOL
77 STDCALL
78 CopySid (
79         DWORD   nDestinationSidLength,
80         PSID    pDestinationSid,
81         PSID    pSourceSid
82 )
83 {
84         NTSTATUS Status;
85
86         Status = RtlCopySid (nDestinationSidLength,
87                              pDestinationSid,
88                              pSourceSid);
89         if (!NT_SUCCESS(Status))
90         {
91                 SetLastError (RtlNtStatusToDosError (Status));
92                 return FALSE;
93         }
94
95         return TRUE;
96 }
97
98
99 /*
100  * @implemented
101  */
102 WINBOOL
103 STDCALL
104 EqualPrefixSid (
105         PSID    pSid1,
106         PSID    pSid2
107         )
108 {
109         return RtlEqualPrefixSid (pSid1, pSid2);
110 }
111
112 /*
113  * @implemented
114  */
115 WINBOOL
116 STDCALL
117 EqualSid (
118         PSID    pSid1,
119         PSID    pSid2
120         )
121 {
122         return RtlEqualSid (pSid1, pSid2);
123 }
124
125
126 /*
127  * @implemented
128  */
129 PVOID
130 STDCALL
131 FreeSid (
132         PSID    pSid
133         )
134 {
135         return RtlFreeSid (pSid);
136 }
137
138
139 /*
140  * @implemented
141  */
142 DWORD
143 STDCALL
144 GetLengthSid (
145         PSID    pSid
146         )
147 {
148         return (DWORD)RtlLengthSid (pSid);
149 }
150
151
152 /*
153  * @implemented
154  */
155 PSID_IDENTIFIER_AUTHORITY
156 STDCALL
157 GetSidIdentifierAuthority (
158         PSID    pSid
159         )
160 {
161         return RtlIdentifierAuthoritySid (pSid);
162 }
163
164
165 /*
166  * @implemented
167  */
168 DWORD
169 STDCALL
170 GetSidLengthRequired (
171         UCHAR   nSubAuthorityCount
172         )
173 {
174         return (DWORD)RtlLengthRequiredSid (nSubAuthorityCount);
175 }
176
177
178 /*
179  * @implemented
180  */
181 PDWORD
182 STDCALL
183 GetSidSubAuthority (
184         PSID    pSid,
185         DWORD   nSubAuthority
186         )
187 {
188         return (PDWORD)RtlSubAuthoritySid (pSid, nSubAuthority);
189 }
190
191
192 /*
193  * @implemented
194  */
195 PUCHAR
196 STDCALL
197 GetSidSubAuthorityCount (
198         PSID    pSid
199         )
200 {
201         return RtlSubAuthorityCountSid (pSid);
202 }
203
204
205 /*
206  * @implemented
207  */
208 WINBOOL
209 STDCALL
210 InitializeSid (
211         PSID                            Sid,
212         PSID_IDENTIFIER_AUTHORITY       pIdentifierAuthority,
213         BYTE                            nSubAuthorityCount
214         )
215 {
216         NTSTATUS Status;
217
218         Status = RtlInitializeSid (Sid,
219                                    pIdentifierAuthority,
220                                    nSubAuthorityCount);
221         if (!NT_SUCCESS(Status))
222         {
223                 SetLastError (RtlNtStatusToDosError (Status));
224                 return FALSE;
225         }
226
227         return TRUE;
228 }
229
230
231 /*
232  * @implemented
233  */
234 WINBOOL STDCALL
235 IsValidSid(PSID pSid)
236 {
237   return((WINBOOL)RtlValidSid(pSid));
238 }
239
240
241 /*
242  * @unimplemented
243  */
244 WINBOOL STDCALL
245 LookupAccountNameA(LPCSTR lpSystemName,
246                    LPCSTR lpAccountName,
247                    PSID Sid,
248                    LPDWORD cbSid,
249                    LPSTR DomainName,
250                    LPDWORD cbDomainName,
251                    PSID_NAME_USE peUse)
252 {
253   return(FALSE);
254 }
255
256
257 /*
258  * @unimplemented
259  */
260 WINBOOL STDCALL
261 LookupAccountNameW(LPCWSTR lpSystemName,
262                    LPCWSTR lpAccountName,
263                    PSID Sid,
264                    LPDWORD cbSid,
265                    LPWSTR DomainName,
266                    LPDWORD cbDomainName,
267                    PSID_NAME_USE peUse)
268 {
269   return(FALSE);
270 }
271
272
273 /*
274  * @unimplemented
275  */
276 WINBOOL STDCALL
277 LookupAccountSidA(LPCSTR lpSystemName,
278                   PSID Sid,
279                   LPSTR Name,
280                   LPDWORD cbName,
281                   LPSTR ReferencedDomainName,
282                   LPDWORD cbReferencedDomainName,
283                   PSID_NAME_USE peUse)
284 {
285   return(FALSE);
286 }
287
288
289 /*
290  * @unimplemented
291  */
292 WINBOOL STDCALL
293 LookupAccountSidW(LPCWSTR lpSystemName,
294                   PSID Sid,
295                   LPWSTR Name,
296                   LPDWORD cbName,
297                   LPWSTR ReferencedDomainName,
298                   LPDWORD cbReferencedDomainName,
299                   PSID_NAME_USE peUse)
300 {
301   return(FALSE);
302 }
303
304 /* EOF */