cbff5e2b86dcbbafa3dfebfe12a6ed28d4b74ceb
[reactos.git] / dll / win32 / lsasrv / lsasrv.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: Local Security Authority (LSA) Server
4 * FILE: reactos/dll/win32/lsasrv/lsasrv.h
5 * PURPOSE: Common header file
6 *
7 * PROGRAMMERS: Eric Kohl
8 */
9
10 #ifndef _LSASRV_H
11 #define _LSASRV_H
12
13 #include <stdarg.h>
14
15 #define WIN32_NO_STATUS
16 #define _INC_WINDOWS
17 #define COM_NO_WINDOWS_H
18
19 #include <windef.h>
20 #include <winbase.h>
21 #include <winreg.h>
22
23 #define NTOS_MODE_USER
24 #include <ndk/cmfuncs.h>
25 #include <ndk/exfuncs.h>
26 #include <ndk/kefuncs.h>
27 #include <ndk/mmfuncs.h>
28 #include <ndk/obfuncs.h>
29 #include <ndk/psfuncs.h>
30 #include <ndk/rtlfuncs.h>
31 #include <ndk/setypes.h>
32
33 #include <ntsam.h>
34 #include <ntlsa.h>
35 #include <sddl.h>
36
37 #include <srmp.h>
38
39 #include <lsass.h>
40 #include <lsa_s.h>
41
42 #include <wine/debug.h>
43 WINE_DEFAULT_DEBUG_CHANNEL(lsasrv);
44
45 typedef enum _LSA_DB_OBJECT_TYPE
46 {
47 LsaDbIgnoreObject,
48 LsaDbPolicyObject,
49 LsaDbAccountObject,
50 LsaDbDomainObject,
51 LsaDbSecretObject
52 } LSA_DB_OBJECT_TYPE, *PLSA_DB_OBJECT_TYPE;
53
54 typedef struct _LSA_DB_OBJECT
55 {
56 ULONG Signature;
57 LSA_DB_OBJECT_TYPE ObjectType;
58 ULONG RefCount;
59 ACCESS_MASK Access;
60 HANDLE KeyHandle;
61 BOOLEAN Trusted;
62 struct _LSA_DB_OBJECT *ParentObject;
63 } LSA_DB_OBJECT, *PLSA_DB_OBJECT;
64
65 #define LSAP_DB_SIGNATURE 0x12345678
66
67 #define POLICY_AUDIT_EVENT_TYPE_COUNT (AuditCategoryAccountLogon - AuditCategorySystem + 1)
68 typedef struct _LSAP_POLICY_AUDIT_EVENTS_DATA
69 {
70 BOOLEAN AuditingMode;
71 DWORD AuditEvents[POLICY_AUDIT_EVENT_TYPE_COUNT];
72 DWORD MaximumAuditEventCount;
73 } LSAP_POLICY_AUDIT_EVENTS_DATA, *PLSAP_POLICY_AUDIT_EVENTS_DATA;
74
75 typedef struct _LSAP_LOGON_CONTEXT
76 {
77 LIST_ENTRY Entry;
78 HANDLE ClientProcessHandle;
79 HANDLE ConnectionHandle;
80 } LSAP_LOGON_CONTEXT, *PLSAP_LOGON_CONTEXT;
81
82 typedef struct _SAMPR_ULONG_ARRAY
83 {
84 unsigned long Count;
85 unsigned long *Element;
86 } SAMPR_ULONG_ARRAY, *PSAMPR_ULONG_ARRAY;
87
88 extern SID_IDENTIFIER_AUTHORITY NullSidAuthority;
89 extern SID_IDENTIFIER_AUTHORITY WorldSidAuthority;
90 extern SID_IDENTIFIER_AUTHORITY LocalSidAuthority;
91 extern SID_IDENTIFIER_AUTHORITY CreatorSidAuthority;
92 extern SID_IDENTIFIER_AUTHORITY NtAuthority;
93
94 extern PSID BuiltinDomainSid;
95 extern UNICODE_STRING BuiltinDomainName;
96 extern PSID AccountDomainSid;
97 extern UNICODE_STRING AccountDomainName;
98
99 extern PSID LsapWorldSid;
100 extern PSID LsapNetworkSid;
101 extern PSID LsapBatchSid;
102 extern PSID LsapInteractiveSid;
103 extern PSID LsapServiceSid;
104 extern PSID LsapLocalSystemSid;
105 extern PSID LsapAdministratorsSid;
106
107
108 /* authpackage.c */
109 NTSTATUS
110 LsapInitAuthPackages(VOID);
111
112 NTSTATUS
113 LsapLookupAuthenticationPackage(PLSA_API_MSG RequestMsg,
114 PLSAP_LOGON_CONTEXT LogonContext);
115
116 NTSTATUS
117 LsapCallAuthenticationPackage(PLSA_API_MSG RequestMsg,
118 PLSAP_LOGON_CONTEXT LogonContext);
119
120 NTSTATUS
121 LsapLogonUser(PLSA_API_MSG RequestMsg,
122 PLSAP_LOGON_CONTEXT LogonContext);
123
124 /* authport.c */
125 NTSTATUS
126 StartAuthenticationPort(VOID);
127
128 /* database.c */
129 NTSTATUS
130 LsapInitDatabase(VOID);
131
132 NTSTATUS
133 LsapCreateDbObject(IN PLSA_DB_OBJECT ParentObject,
134 IN LPWSTR ContainerName,
135 IN LPWSTR ObjectName,
136 IN LSA_DB_OBJECT_TYPE HandleType,
137 IN ACCESS_MASK DesiredAccess,
138 IN BOOLEAN Trusted,
139 OUT PLSA_DB_OBJECT *DbObject);
140
141 NTSTATUS
142 LsapOpenDbObject(IN PLSA_DB_OBJECT ParentObject,
143 IN LPWSTR ContainerName,
144 IN LPWSTR ObjectName,
145 IN LSA_DB_OBJECT_TYPE ObjectType,
146 IN ACCESS_MASK DesiredAccess,
147 IN BOOLEAN Trusted,
148 OUT PLSA_DB_OBJECT *DbObject);
149
150 NTSTATUS
151 LsapValidateDbObject(IN LSAPR_HANDLE Handle,
152 IN LSA_DB_OBJECT_TYPE HandleType,
153 IN ACCESS_MASK GrantedAccess,
154 OUT PLSA_DB_OBJECT *DbObject);
155
156 NTSTATUS
157 LsapCloseDbObject(IN PLSA_DB_OBJECT DbObject);
158
159 NTSTATUS
160 LsapDeleteDbObject(IN PLSA_DB_OBJECT DbObject);
161
162 NTSTATUS
163 LsapGetObjectAttribute(PLSA_DB_OBJECT DbObject,
164 LPWSTR AttributeName,
165 LPVOID AttributeData,
166 PULONG AttributeSize);
167
168 NTSTATUS
169 LsapSetObjectAttribute(PLSA_DB_OBJECT DbObject,
170 LPWSTR AttributeName,
171 LPVOID AttributeData,
172 ULONG AttributeSize);
173
174 NTSTATUS
175 LsapDeleteObjectAttribute(PLSA_DB_OBJECT DbObject,
176 LPWSTR AttributeName);
177
178 /* dssetup.c */
179 VOID
180 DsSetupInit(VOID);
181
182 /* lookup.c */
183 NTSTATUS
184 LsapInitSids(VOID);
185
186 ULONG
187 LsapGetRelativeIdFromSid(PSID Sid);
188
189 NTSTATUS
190 LsapLookupNames(DWORD Count,
191 PRPC_UNICODE_STRING Names,
192 PLSAPR_REFERENCED_DOMAIN_LIST *ReferencedDomains,
193 PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
194 LSAP_LOOKUP_LEVEL LookupLevel,
195 DWORD *MappedCount,
196 DWORD LookupOptions,
197 DWORD ClientRevision);
198
199 NTSTATUS
200 LsapLookupSids(PLSAPR_SID_ENUM_BUFFER SidEnumBuffer,
201 PLSAPR_REFERENCED_DOMAIN_LIST *ReferencedDomains,
202 PLSAPR_TRANSLATED_NAMES_EX TranslatedNames,
203 LSAP_LOOKUP_LEVEL LookupLevel,
204 DWORD *MappedCount,
205 DWORD LookupOptions,
206 DWORD ClientRevision);
207
208 /* lsarpc.c */
209 NTSTATUS
210 LsarStartRpcServer(VOID);
211
212 /* notify.c */
213 VOID
214 LsapInitNotificationList(VOID);
215
216 NTSTATUS
217 LsapRegisterNotification(
218 PLSA_API_MSG RequestMsg);
219
220 /* policy.c */
221 NTSTATUS
222 LsarQueryAuditLog(PLSA_DB_OBJECT PolicyObject,
223 PLSAPR_POLICY_INFORMATION *PolicyInformation);
224
225 NTSTATUS
226 LsarQueryAuditEvents(PLSA_DB_OBJECT PolicyObject,
227 PLSAPR_POLICY_INFORMATION *PolicyInformation);
228
229 NTSTATUS
230 LsarQueryPrimaryDomain(PLSA_DB_OBJECT PolicyObject,
231 PLSAPR_POLICY_INFORMATION *PolicyInformation);
232
233 NTSTATUS
234 LsarQueryPdAccount(PLSA_DB_OBJECT PolicyObject,
235 PLSAPR_POLICY_INFORMATION *PolicyInformation);
236
237 NTSTATUS
238 LsarQueryAccountDomain(PLSA_DB_OBJECT PolicyObject,
239 PLSAPR_POLICY_INFORMATION *PolicyInformation);
240
241 NTSTATUS
242 LsarQueryServerRole(PLSA_DB_OBJECT PolicyObject,
243 PLSAPR_POLICY_INFORMATION *PolicyInformation);
244
245 NTSTATUS
246 LsarQueryReplicaSource(PLSA_DB_OBJECT PolicyObject,
247 PLSAPR_POLICY_INFORMATION *PolicyInformation);
248
249 NTSTATUS
250 LsarQueryDefaultQuota(PLSA_DB_OBJECT PolicyObject,
251 PLSAPR_POLICY_INFORMATION *PolicyInformation);
252
253 NTSTATUS
254 LsarQueryModification(PLSA_DB_OBJECT PolicyObject,
255 PLSAPR_POLICY_INFORMATION *PolicyInformation);
256
257 NTSTATUS
258 LsarQueryAuditFull(PLSA_DB_OBJECT PolicyObject,
259 PLSAPR_POLICY_INFORMATION *PolicyInformation);
260
261 NTSTATUS
262 LsarQueryDnsDomain(PLSA_DB_OBJECT PolicyObject,
263 PLSAPR_POLICY_INFORMATION *PolicyInformation);
264
265 NTSTATUS
266 LsarQueryDnsDomainInt(PLSA_DB_OBJECT PolicyObject,
267 PLSAPR_POLICY_INFORMATION *PolicyInformation);
268
269 NTSTATUS
270 LsarQueryLocalAccountDomain(PLSA_DB_OBJECT PolicyObject,
271 PLSAPR_POLICY_INFORMATION *PolicyInformation);
272
273 NTSTATUS
274 LsarSetAuditLog(PLSA_DB_OBJECT PolicyObject,
275 PPOLICY_AUDIT_LOG_INFO Info);
276
277 NTSTATUS
278 LsarSetAuditEvents(PLSA_DB_OBJECT PolicyObject,
279 PLSAPR_POLICY_AUDIT_EVENTS_INFO Info);
280
281 NTSTATUS
282 LsarSetPrimaryDomain(PLSA_DB_OBJECT PolicyObject,
283 PLSAPR_POLICY_PRIMARY_DOM_INFO Info);
284
285 NTSTATUS
286 LsarSetAccountDomain(PLSA_DB_OBJECT PolicyObject,
287 PLSAPR_POLICY_ACCOUNT_DOM_INFO Info);
288
289 NTSTATUS
290 LsarSetServerRole(PLSA_DB_OBJECT PolicyObject,
291 PPOLICY_LSA_SERVER_ROLE_INFO Info);
292
293 NTSTATUS
294 LsarSetReplicaSource(PLSA_DB_OBJECT PolicyObject,
295 PPOLICY_LSA_REPLICA_SRCE_INFO Info);
296
297 NTSTATUS
298 LsarSetDefaultQuota(PLSA_DB_OBJECT PolicyObject,
299 PPOLICY_DEFAULT_QUOTA_INFO Info);
300
301 NTSTATUS
302 LsarSetModification(PLSA_DB_OBJECT PolicyObject,
303 PPOLICY_MODIFICATION_INFO Info);
304
305 NTSTATUS
306 LsarSetAuditFull(PLSA_DB_OBJECT PolicyObject,
307 PPOLICY_AUDIT_FULL_QUERY_INFO Info);
308
309 NTSTATUS
310 LsarSetDnsDomain(PLSA_DB_OBJECT PolicyObject,
311 PLSAPR_POLICY_DNS_DOMAIN_INFO Info);
312
313 NTSTATUS
314 LsarSetDnsDomainInt(PLSA_DB_OBJECT PolicyObject,
315 PLSAPR_POLICY_DNS_DOMAIN_INFO Info);
316
317 NTSTATUS
318 LsarSetLocalAccountDomain(PLSA_DB_OBJECT PolicyObject,
319 PLSAPR_POLICY_ACCOUNT_DOM_INFO Info);
320
321 /* privileges.c */
322 NTSTATUS
323 LsarpLookupPrivilegeName(PLUID Value,
324 PRPC_UNICODE_STRING *Name);
325
326 NTSTATUS
327 LsarpLookupPrivilegeDisplayName(PRPC_UNICODE_STRING Name,
328 USHORT ClientLanguage,
329 USHORT ClientSystemDefaultLanguage,
330 PRPC_UNICODE_STRING *DisplayName,
331 USHORT *LanguageReturned);
332
333 PLUID
334 LsarpLookupPrivilegeValue(
335 IN PRPC_UNICODE_STRING Name);
336
337 NTSTATUS
338 LsarpEnumeratePrivileges(DWORD *EnumerationContext,
339 PLSAPR_PRIVILEGE_ENUM_BUFFER EnumerationBuffer,
340 DWORD PreferedMaximumLength);
341
342 NTSTATUS
343 LsapLookupAccountRightName(ULONG RightValue,
344 PRPC_UNICODE_STRING *Name);
345
346 ACCESS_MASK
347 LsapLookupAccountRightValue(
348 IN PRPC_UNICODE_STRING Name);
349
350 /* registry.h */
351 NTSTATUS
352 LsapRegCloseKey(IN HANDLE KeyHandle);
353
354 NTSTATUS
355 LsapRegCreateKey(IN HANDLE ParentKeyHandle,
356 IN LPCWSTR KeyName,
357 IN ACCESS_MASK DesiredAccess,
358 OUT HANDLE KeyHandle);
359
360 NTSTATUS
361 LsapRegDeleteSubKey(IN HANDLE ParentKeyHandle,
362 IN LPCWSTR KeyName);
363
364 NTSTATUS
365 LsapRegDeleteKey(IN HANDLE KeyHandle);
366
367 NTSTATUS
368 LsapRegEnumerateSubKey(IN HANDLE KeyHandle,
369 IN ULONG Index,
370 IN ULONG Length,
371 OUT LPWSTR Buffer);
372
373 NTSTATUS
374 LsapRegOpenKey(IN HANDLE ParentKeyHandle,
375 IN LPCWSTR KeyName,
376 IN ACCESS_MASK DesiredAccess,
377 OUT HANDLE KeyHandle);
378
379 NTSTATUS
380 LsapRegQueryKeyInfo(IN HANDLE KeyHandle,
381 OUT PULONG SubKeyCount,
382 OUT PULONG MaxSubKeyNameLength,
383 OUT PULONG ValueCount);
384
385 NTSTATUS
386 LsapRegDeleteValue(IN HANDLE KeyHandle,
387 IN LPWSTR ValueName);
388
389 NTSTATUS
390 LsapRegEnumerateValue(IN HANDLE KeyHandle,
391 IN ULONG Index,
392 OUT LPWSTR Name,
393 IN OUT PULONG NameLength,
394 OUT PULONG Type OPTIONAL,
395 OUT PVOID Data OPTIONAL,
396 IN OUT PULONG DataLength OPTIONAL);
397
398 NTSTATUS
399 LsapRegQueryValue(IN HANDLE KeyHandle,
400 IN LPWSTR ValueName,
401 OUT PULONG Type OPTIONAL,
402 OUT LPVOID Data OPTIONAL,
403 IN OUT PULONG DataLength OPTIONAL);
404
405 NTSTATUS
406 LsapRegSetValue(IN HANDLE KeyHandle,
407 IN LPWSTR ValueName,
408 IN ULONG Type,
409 IN LPVOID Data,
410 IN ULONG DataLength);
411
412 /* security.c */
413 NTSTATUS
414 LsapCreatePolicySd(PSECURITY_DESCRIPTOR *PolicySd,
415 PULONG PolicySdSize);
416
417 NTSTATUS
418 LsapCreateAccountSd(PSECURITY_DESCRIPTOR *AccountSd,
419 PULONG AccountSdSize);
420
421 NTSTATUS
422 LsapCreateSecretSd(PSECURITY_DESCRIPTOR *SecretSd,
423 PULONG SecretSdSize);
424
425 /* session.c */
426 VOID
427 LsapInitLogonSessions(VOID);
428
429 NTSTATUS
430 NTAPI
431 LsapCreateLogonSession(IN PLUID LogonId);
432
433 NTSTATUS
434 NTAPI
435 LsapDeleteLogonSession(IN PLUID LogonId);
436
437 NTSTATUS
438 NTAPI
439 LsapAddCredential(
440 _In_ PLUID LogonId,
441 _In_ ULONG AuthenticationPackage,
442 _In_ PLSA_STRING PrimaryKeyValue,
443 _In_ PLSA_STRING Credential);
444
445 NTSTATUS
446 NTAPI
447 LsapGetCredentials(
448 _In_ PLUID LogonId,
449 _In_ ULONG AuthenticationPackage,
450 _Inout_ PULONG QueryContext,
451 _In_ BOOLEAN RetrieveAllCredentials,
452 _Inout_ PLSA_STRING PrimaryKeyValue,
453 _Out_ PULONG PrimaryKeyLength,
454 _Out_ PLSA_STRING Credentials);
455
456 NTSTATUS
457 NTAPI
458 LsapDeleteCredential(
459 _In_ PLUID LogonId,
460 _In_ ULONG AuthenticationPackage,
461 _In_ PLSA_STRING PrimaryKeyValue);
462
463 NTSTATUS
464 LsapSetLogonSessionData(
465 _In_ PLUID LogonId,
466 _In_ ULONG LogonType,
467 _In_ PUNICODE_STRING UserName,
468 _In_ PUNICODE_STRING LogonDomain,
469 _In_ PSID Sid);
470
471 NTSTATUS
472 LsapEnumLogonSessions(IN OUT PLSA_API_MSG RequestMsg);
473
474 NTSTATUS
475 LsapGetLogonSessionData(IN OUT PLSA_API_MSG RequestMsg);
476
477 /* srm.c */
478 NTSTATUS
479 LsapRmInitializeServer(VOID);
480
481 NTSTATUS
482 LsapRmCreateLogonSession(
483 PLUID LogonId);
484
485 NTSTATUS
486 LsapRmDeleteLogonSession(
487 PLUID LogonId);
488
489 /* utils.c */
490 INT
491 LsapLoadString(HINSTANCE hInstance,
492 UINT uId,
493 LPWSTR lpBuffer,
494 INT nBufferMax);
495
496 INT
497 LsapGetResourceStringLengthEx(
498 _In_ HINSTANCE hInstance,
499 _In_ UINT uId,
500 _In_ USHORT usLanguage);
501
502 INT
503 LsapLoadStringEx(
504 _In_ HINSTANCE hInstance,
505 _In_ UINT uId,
506 _In_ USHORT usLanguage,
507 _Out_ LPWSTR lpBuffer,
508 _Out_ INT nBufferMax);
509
510 PSID
511 LsapAppendRidToSid(
512 PSID SrcSid,
513 ULONG Rid);
514
515 #endif /* _LSASRV_H */