Implemented AllocateLocallyUniqueId().
[reactos.git] / reactos / lib / advapi32 / sec / sid.c
1 /* $Id: sid.c,v 1.3 2001/06/17 20:19:45 ekohl Exp $
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 WINBOOL
185 STDCALL
186 IsValidSid (
187 PSID pSid
188 )
189 {
190 return (WINBOOL)RtlValidSid (pSid);
191 }
192
193 WINBOOL
194 STDCALL
195 LookupAccountSidA (
196 LPCSTR lpSystemName,
197 PSID Sid,
198 LPSTR Name,
199 LPDWORD cbName,
200 LPSTR ReferencedDomainName,
201 LPDWORD cbReferencedDomainName,
202 PSID_NAME_USE peUse
203 )
204 {
205 return (FALSE);
206 }
207
208
209 WINBOOL
210 STDCALL
211 LookupAccountSidW (
212 LPCWSTR lpSystemName,
213 PSID Sid,
214 LPWSTR Name,
215 LPDWORD cbName,
216 LPWSTR ReferencedDomainName,
217 LPDWORD cbReferencedDomainName,
218 PSID_NAME_USE peUse
219 )
220 {
221 return (FALSE);
222 }
223
224 /* EOF */