bc915a6d4c83ef6a67e34c2cae4ccfb91c428e42
[reactos.git] / reactos / lib / advapi32 / sec / lsa.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/advapi32/sec/lsa.c
5 * PURPOSE: Local security authority functions
6 * PROGRAMMER: Emanuele Aliberti
7 * UPDATE HISTORY:
8 * 19990322 EA created
9 * 19990515 EA stubs
10 * 20030202 KJK compressed stubs
11 *
12 */
13
14 #include "advapi32.h"
15 #include <ntsecapi.h>
16
17 #define NDEBUG
18 #include <debug.h>
19
20
21 #ifndef SID_REVISION /* FIXME - Winnt.h */
22 #define SID_REVISION (1) /* Current revision */
23 #endif
24
25
26 /*
27 * @unimplemented
28 */
29 NTSTATUS STDCALL
30 LsaClose(LSA_HANDLE ObjectHandle)
31 {
32 DPRINT1("(%p):LsaClose stub\n",ObjectHandle);
33 return 0xc0000000;
34 }
35
36 /*
37 * @unimplemented
38 */
39 NTSTATUS
40 STDCALL
41 LsaAddAccountRights(
42 LSA_HANDLE PolicyHandle,
43 PSID AccountSid,
44 PLSA_UNICODE_STRING UserRights,
45 ULONG CountOfRights)
46 {
47 return STATUS_NOT_IMPLEMENTED;
48 }
49
50 /*
51 * @unimplemented
52 */
53 NTSTATUS
54 STDCALL
55 LsaCreateTrustedDomainEx(
56 LSA_HANDLE PolicyHandle,
57 PTRUSTED_DOMAIN_INFORMATION_EX TrustedDomainInformation,
58 PTRUSTED_DOMAIN_AUTH_INFORMATION AuthenticationInformation,
59 ACCESS_MASK DesiredAccess,
60 PLSA_HANDLE TrustedDomainHandle)
61 {
62 return STATUS_NOT_IMPLEMENTED;
63 }
64
65 /*
66 * @unimplemented
67 */
68 NTSTATUS
69 STDCALL
70 LsaDeleteTrustedDomain(
71 LSA_HANDLE PolicyHandle,
72 PSID TrustedDomainSid)
73 {
74 return STATUS_NOT_IMPLEMENTED;
75 }
76
77 /*
78 * @unimplemented
79 */
80 NTSTATUS
81 STDCALL
82 LsaEnumerateAccountRights(
83 LSA_HANDLE PolicyHandle,
84 PSID AccountSid,
85 PLSA_UNICODE_STRING *UserRights,
86 PULONG CountOfRights)
87 {
88 return STATUS_NOT_IMPLEMENTED;
89 }
90
91 /*
92 * @unimplemented
93 */
94 NTSTATUS
95 STDCALL
96 LsaEnumerateAccountsWithUserRight(
97 LSA_HANDLE PolicyHandle,
98 OPTIONAL PLSA_UNICODE_STRING UserRights,
99 PVOID *EnumerationBuffer,
100 PULONG CountReturned)
101 {
102 return STATUS_NOT_IMPLEMENTED;
103 }
104
105 /*
106 * @unimplemented
107 */
108 NTSTATUS
109 STDCALL
110 LsaEnumerateTrustedDomains(
111 LSA_HANDLE PolicyHandle,
112 PLSA_ENUMERATION_HANDLE EnumerationContext,
113 PVOID *Buffer,
114 ULONG PreferedMaximumLength,
115 PULONG CountReturned)
116 {
117 return STATUS_NOT_IMPLEMENTED;
118 }
119
120 /*
121 * @unimplemented
122 */
123 NTSTATUS
124 STDCALL
125 LsaEnumerateTrustedDomainsEx(
126 LSA_HANDLE PolicyHandle,
127 PLSA_ENUMERATION_HANDLE EnumerationContext,
128 PVOID *Buffer,
129 ULONG PreferedMaximumLength,
130 PULONG CountReturned)
131 {
132 return STATUS_NOT_IMPLEMENTED;
133 }
134
135 /*
136 * @implemented
137 */
138 NTSTATUS STDCALL
139 LsaFreeMemory(PVOID Buffer)
140 {
141 return RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
142 }
143
144 /*
145 * @unimplemented
146 */
147 NTSTATUS
148 STDCALL
149 LsaLookupNames(
150 LSA_HANDLE PolicyHandle,
151 ULONG Count,
152 PLSA_UNICODE_STRING Names,
153 PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
154 PLSA_TRANSLATED_SID *Sids)
155 {
156 return STATUS_NOT_IMPLEMENTED;
157 }
158
159 /*
160 * @unimplemented
161 */
162 NTSTATUS
163 STDCALL
164 LsaLookupNames2(
165 LSA_HANDLE PolicyHandle,
166 ULONG Flags,
167 ULONG Count,
168 PLSA_UNICODE_STRING Names,
169 PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
170 PLSA_TRANSLATED_SID2 *Sids)
171 {
172 return STATUS_NOT_IMPLEMENTED;
173 }
174
175 /*
176 * @unimplemented
177 */
178 NTSTATUS
179 STDCALL
180 LsaLookupSids(
181 LSA_HANDLE PolicyHandle,
182 ULONG Count,
183 PSID *Sids,
184 PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
185 PLSA_TRANSLATED_NAME *Names)
186 {
187 return STATUS_NOT_IMPLEMENTED;
188 }
189
190 /******************************************************************************
191 * LsaNtStatusToWinError
192 *
193 * PARAMS
194 * Status [I]
195 *
196 * @implemented
197 */
198 ULONG STDCALL
199 LsaNtStatusToWinError(NTSTATUS Status)
200 {
201 return RtlNtStatusToDosError(Status);
202 }
203
204 /******************************************************************************
205 * LsaOpenPolicy
206 *
207 * PARAMS
208 * x1 []
209 * x2 []
210 * x3 []
211 * x4 []
212 *
213 * @unimplemented
214 */
215 NTSTATUS STDCALL
216 LsaOpenPolicy(PLSA_UNICODE_STRING lsaucs,
217 PLSA_OBJECT_ATTRIBUTES lsaoa,
218 ACCESS_MASK access,
219 PLSA_HANDLE PolicyHandle)
220 {
221 DPRINT1("LsaOpenPolicy - stub\n");
222 return STATUS_SUCCESS;
223 }
224
225 /*
226 * @unimplemented
227 */
228 NTSTATUS
229 STDCALL
230 LsaOpenTrustedDomainByName(
231 LSA_HANDLE PolicyHandle,
232 PLSA_UNICODE_STRING TrustedDomainName,
233 ACCESS_MASK DesiredAccess,
234 PLSA_HANDLE TrustedDomainHandle)
235 {
236 return STATUS_NOT_IMPLEMENTED;
237 }
238
239 /*
240 * @unimplemented
241 */
242 NTSTATUS
243 STDCALL
244 LsaQueryDomainInformationPolicy(
245 LSA_HANDLE PolicyHandle,
246 POLICY_DOMAIN_INFORMATION_CLASS pic,
247 PVOID *Buffer)
248 {
249 return STATUS_NOT_IMPLEMENTED;
250 }
251
252 /*
253 * @unimplemented
254 */
255 NTSTATUS
256 STDCALL
257 LsaQueryForestTrustInformation(
258 LSA_HANDLE PolicyHandle,
259 PLSA_UNICODE_STRING TrustedDomainName,
260 PLSA_FOREST_TRUST_INFORMATION * ForestTrustInfo)
261 {
262 return STATUS_NOT_IMPLEMENTED;
263 }
264
265 /*
266 * @unimplemented
267 */
268 NTSTATUS STDCALL
269 LsaQueryInformationPolicy(LSA_HANDLE PolicyHandle,
270 POLICY_INFORMATION_CLASS pic,
271 PVOID *Buffer)
272 {
273 DPRINT1("(%p,0x%08x,%p):LsaQueryInformationPolicy stub\n",
274 PolicyHandle, pic, Buffer);
275
276 if (!Buffer)
277 return FALSE;
278
279 switch (pic)
280 {
281 case PolicyAuditEventsInformation: /* 2 */
282 {
283 PPOLICY_AUDIT_EVENTS_INFO p = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(POLICY_AUDIT_EVENTS_INFO));
284 p->AuditingMode = FALSE; /* no auditing */
285 *Buffer = p;
286 }
287 break;
288 case PolicyPrimaryDomainInformation: /* 3 */
289 case PolicyAccountDomainInformation: /* 5 */
290 {
291 struct di
292 { POLICY_PRIMARY_DOMAIN_INFO ppdi;
293 SID sid;
294 };
295 SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
296
297 struct di * xdi = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(xdi));
298 HKEY key;
299 BOOL useDefault = TRUE;
300 LONG ret;
301
302 if ((ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
303 "System\\CurrentControlSet\\Services\\VxD\\VNETSUP", 0,
304 KEY_READ, &key)) == ERROR_SUCCESS)
305 {
306 DWORD size = 0;
307 WCHAR wg[] = { 'W','o','r','k','g','r','o','u','p',0 };
308
309 ret = RegQueryValueExW(key, wg, NULL, NULL, NULL, &size);
310 if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS)
311 {
312 xdi->ppdi.Name.Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
313 HEAP_ZERO_MEMORY, size);
314 if ((ret = RegQueryValueExW(key, wg, NULL, NULL,
315 (LPBYTE)xdi->ppdi.Name.Buffer, &size)) == ERROR_SUCCESS)
316 {
317 xdi->ppdi.Name.Length = (USHORT)size;
318 useDefault = FALSE;
319 }
320 else
321 {
322 RtlFreeHeap(RtlGetProcessHeap(), 0, xdi->ppdi.Name.Buffer);
323 xdi->ppdi.Name.Buffer = NULL;
324 }
325 }
326 RegCloseKey(key);
327 }
328 if (useDefault)
329 RtlCreateUnicodeStringFromAsciiz(&(xdi->ppdi.Name), "DOMAIN");
330 DPRINT1("setting domain to \n");
331
332 xdi->ppdi.Sid = &(xdi->sid);
333 xdi->sid.Revision = SID_REVISION;
334 xdi->sid.SubAuthorityCount = 1;
335 xdi->sid.IdentifierAuthority = localSidAuthority;
336 xdi->sid.SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID;
337 *Buffer = xdi;
338 }
339 break;
340 case PolicyAuditLogInformation:
341 case PolicyPdAccountInformation:
342 case PolicyLsaServerRoleInformation:
343 case PolicyReplicaSourceInformation:
344 case PolicyDefaultQuotaInformation:
345 case PolicyModificationInformation:
346 case PolicyAuditFullSetInformation:
347 case PolicyAuditFullQueryInformation:
348 case PolicyDnsDomainInformation:
349 case PolicyEfsInformation:
350 {
351 DPRINT1("category not implemented\n");
352 return FALSE;
353 }
354 }
355 return TRUE;
356 }
357
358 /*
359 * @unimplemented
360 */
361 NTSTATUS
362 STDCALL
363 LsaQueryTrustedDomainInfoByName(
364 LSA_HANDLE PolicyHandle,
365 PLSA_UNICODE_STRING TrustedDomainName,
366 TRUSTED_INFORMATION_CLASS pic,
367 PVOID *Buffer)
368 {
369 return STATUS_NOT_IMPLEMENTED;
370 }
371
372 /*
373 * @unimplemented
374 */
375 NTSTATUS
376 STDCALL
377 LsaQueryTrustedDomainInfo(
378 LSA_HANDLE PolicyHandle,
379 PSID TrustedDomainSid,
380 TRUSTED_INFORMATION_CLASS pic,
381 PVOID *Buffer)
382 {
383 return STATUS_NOT_IMPLEMENTED;
384 }
385
386 /*
387 * @unimplemented
388 */
389 NTSTATUS
390 STDCALL
391 LsaRemoveAccountRights(
392 LSA_HANDLE PolicyHandle,
393 PSID AccountSid,
394 BOOLEAN AllRights,
395 PLSA_UNICODE_STRING UserRights,
396 ULONG CountOfRights)
397 {
398 return STATUS_NOT_IMPLEMENTED;
399 }
400
401 /*
402 * @unimplemented
403 */
404 NTSTATUS
405 STDCALL
406 LsaRetrievePrivateData(
407 LSA_HANDLE PolicyHandle,
408 PLSA_UNICODE_STRING KeyName,
409 PLSA_UNICODE_STRING *PrivateData)
410 {
411 return STATUS_NOT_IMPLEMENTED;
412 }
413
414 /*
415 * @unimplemented
416 */
417 NTSTATUS
418 STDCALL
419 LsaSetDomainInformationPolicy(
420 LSA_HANDLE PolicyHandle,
421 POLICY_DOMAIN_INFORMATION_CLASS pic,
422 PVOID Buffer)
423 {
424 return STATUS_NOT_IMPLEMENTED;
425 }
426
427 /*
428 * @unimplemented
429 */
430 NTSTATUS
431 STDCALL
432 LsaSetInformationPolicy(
433 LSA_HANDLE PolicyHandle,
434 POLICY_INFORMATION_CLASS pic,
435 PVOID Buffer)
436 {
437 return STATUS_NOT_IMPLEMENTED;
438 }
439
440 /*
441 * @unimplemented
442 */
443 NTSTATUS
444 STDCALL
445 LsaSetForestTrustInformation(
446 LSA_HANDLE PolicyHandle,
447 PLSA_UNICODE_STRING TrustedDomainName,
448 PLSA_FOREST_TRUST_INFORMATION ForestTrustInfo,
449 BOOL CheckOnly,
450 PLSA_FOREST_TRUST_COLLISION_INFORMATION *CollisionInfo)
451 {
452 return STATUS_NOT_IMPLEMENTED;
453 }
454
455 /*
456 * @unimplemented
457 */
458 NTSTATUS
459 STDCALL
460 LsaSetTrustedDomainInfoByName(
461 LSA_HANDLE PolicyHandle,
462 PLSA_UNICODE_STRING TrustedDomainName,
463 TRUSTED_INFORMATION_CLASS pic,
464 PVOID Buffer)
465 {
466 return STATUS_NOT_IMPLEMENTED;
467 }
468
469 /*
470 * @unimplemented
471 */
472 NTSTATUS
473 STDCALL
474 LsaSetTrustedDomainInformation(
475 LSA_HANDLE PolicyHandle,
476 PSID TrustedDomainSid,
477 TRUSTED_INFORMATION_CLASS pic,
478 PVOID Buffer)
479 {
480 return STATUS_NOT_IMPLEMENTED;
481 }
482
483 /*
484 * @unimplemented
485 */
486 NTSTATUS
487 STDCALL
488 LsaStorePrivateData(
489 LSA_HANDLE PolicyHandle,
490 PLSA_UNICODE_STRING KeyName,
491 PLSA_UNICODE_STRING PrivateData)
492 {
493 return STATUS_NOT_IMPLEMENTED;
494 }
495
496 /*
497 * @unimplemented
498 */
499 NTSTATUS
500 STDCALL
501 LsaGetUserName(
502 PUNICODE_STRING *UserName,
503 PUNICODE_STRING *DomainName)
504 {
505 DPRINT1("LsaGetUserName not implemented\n");
506
507 return STATUS_NOT_IMPLEMENTED;
508 }
509
510 /* EOF */