:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[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 #include <ddk/ntddk.h>
10 #include <ntdll/rtl.h>
11 #include <windows.h>
12
13
14 BOOL STDCALL
15 AllocateLocallyUniqueId(PLUID Luid)
16 {
17    NTSTATUS Status;
18
19    Status = NtAllocateLocallyUniqueId(Luid);
20    if (!NT_SUCCESS(Status))
21      {
22         SetLastError(RtlNtStatusToDosError(Status));
23         return(FALSE);
24      }
25    return(TRUE);
26 }
27
28 BOOL STDCALL
29 AllocateAndInitializeSid (
30         PSID_IDENTIFIER_AUTHORITY       pIdentifierAuthority,
31         BYTE                            nSubAuthorityCount,
32         DWORD                           dwSubAuthority0,
33         DWORD                           dwSubAuthority1,
34         DWORD                           dwSubAuthority2,
35         DWORD                           dwSubAuthority3,
36         DWORD                           dwSubAuthority4,
37         DWORD                           dwSubAuthority5,
38         DWORD                           dwSubAuthority6,
39         DWORD                           dwSubAuthority7,
40         PSID                            *pSid
41 )
42 {
43         NTSTATUS Status;
44
45         Status = RtlAllocateAndInitializeSid (pIdentifierAuthority,
46                                               nSubAuthorityCount,
47                                               dwSubAuthority0,
48                                               dwSubAuthority1,
49                                               dwSubAuthority2,
50                                               dwSubAuthority3,
51                                               dwSubAuthority4,
52                                               dwSubAuthority5,
53                                               dwSubAuthority6,
54                                               dwSubAuthority7,
55                                               pSid);
56         if (!NT_SUCCESS(Status))
57         {
58                 SetLastError (RtlNtStatusToDosError (Status));
59                 return FALSE;
60         }
61
62         return TRUE;
63 }
64
65 BOOL
66 STDCALL
67 CopySid (
68         DWORD   nDestinationSidLength,
69         PSID    pDestinationSid,
70         PSID    pSourceSid
71 )
72 {
73         NTSTATUS Status;
74
75         Status = RtlCopySid (nDestinationSidLength,
76                              pDestinationSid,
77                              pSourceSid);
78         if (!NT_SUCCESS(Status))
79         {
80                 SetLastError (RtlNtStatusToDosError (Status));
81                 return FALSE;
82         }
83
84         return TRUE;
85 }
86
87 WINBOOL
88 STDCALL
89 EqualPrefixSid (
90         PSID    pSid1,
91         PSID    pSid2
92         )
93 {
94         return RtlEqualPrefixSid (pSid1, pSid2);
95 }
96
97 WINBOOL
98 STDCALL
99 EqualSid (
100         PSID    pSid1,
101         PSID    pSid2
102         )
103 {
104         return RtlEqualSid (pSid1, pSid2);
105 }
106
107 PVOID
108 STDCALL
109 FreeSid (
110         PSID    pSid
111         )
112 {
113         return RtlFreeSid (pSid);
114 }
115
116 DWORD
117 STDCALL
118 GetLengthSid (
119         PSID    pSid
120         )
121 {
122         return (DWORD)RtlLengthSid (pSid);
123 }
124
125 PSID_IDENTIFIER_AUTHORITY
126 STDCALL
127 GetSidIdentifierAuthority (
128         PSID    pSid
129         )
130 {
131         return RtlIdentifierAuthoritySid (pSid);
132 }
133
134 DWORD
135 STDCALL
136 GetSidLengthRequired (
137         UCHAR   nSubAuthorityCount
138         )
139 {
140         return (DWORD)RtlLengthRequiredSid (nSubAuthorityCount);
141 }
142
143 PDWORD
144 STDCALL
145 GetSidSubAuthority (
146         PSID    pSid,
147         DWORD   nSubAuthority
148         )
149 {
150         return (PDWORD)RtlSubAuthoritySid (pSid, nSubAuthority);
151 }
152
153 PUCHAR
154 STDCALL
155 GetSidSubAuthorityCount (
156         PSID    pSid
157         )
158 {
159         return RtlSubAuthorityCountSid (pSid);
160 }
161
162 WINBOOL
163 STDCALL
164 InitializeSid (
165         PSID                            Sid,
166         PSID_IDENTIFIER_AUTHORITY       pIdentifierAuthority,
167         BYTE                            nSubAuthorityCount
168         )
169 {
170         NTSTATUS Status;
171
172         Status = RtlInitializeSid (Sid,
173                                    pIdentifierAuthority,
174                                    nSubAuthorityCount);
175         if (!NT_SUCCESS(Status))
176         {
177                 SetLastError (RtlNtStatusToDosError (Status));
178                 return FALSE;
179         }
180
181         return TRUE;
182 }
183
184
185 WINBOOL STDCALL
186 IsValidSid(PSID pSid)
187 {
188   return((WINBOOL)RtlValidSid(pSid));
189 }
190
191
192 WINBOOL STDCALL
193 LookupAccountNameA(LPCSTR lpSystemName,
194                    LPCSTR lpAccountName,
195                    PSID Sid,
196                    LPDWORD cbSid,
197                    LPSTR DomainName,
198                    LPDWORD cbDomainName,
199                    PSID_NAME_USE peUse)
200 {
201   return(FALSE);
202 }
203
204
205 WINBOOL STDCALL
206 LookupAccountNameW(LPCWSTR lpSystemName,
207                    LPCWSTR lpAccountName,
208                    PSID Sid,
209                    LPDWORD cbSid,
210                    LPWSTR DomainName,
211                    LPDWORD cbDomainName,
212                    PSID_NAME_USE peUse)
213 {
214   return(FALSE);
215 }
216
217
218 WINBOOL STDCALL
219 LookupAccountSidA(LPCSTR lpSystemName,
220                   PSID Sid,
221                   LPSTR Name,
222                   LPDWORD cbName,
223                   LPSTR ReferencedDomainName,
224                   LPDWORD cbReferencedDomainName,
225                   PSID_NAME_USE peUse)
226 {
227   return(FALSE);
228 }
229
230
231 WINBOOL STDCALL
232 LookupAccountSidW(LPCWSTR lpSystemName,
233                   PSID Sid,
234                   LPWSTR Name,
235                   LPDWORD cbName,
236                   LPWSTR ReferencedDomainName,
237                   LPDWORD cbReferencedDomainName,
238                   PSID_NAME_USE peUse)
239 {
240   return(FALSE);
241 }
242
243 /* EOF */