ReactOS 0.4.16-dev-109-gf4cb10f
lsasrv.c
Go to the documentation of this file.
1/*
2 * PROJECT: Local Security Authority Server DLL
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/win32/lsasrv/lsasrv.c
5 * PURPOSE: Main file
6 * COPYRIGHT: Copyright 2006-2009 Eric Kohl
7 */
8
9/* INCLUDES ****************************************************************/
10
11#include "lsasrv.h"
12
14
15/* FUNCTIONS ***************************************************************/
16
17VOID
21{
22 ULONG i;
23
24 if (Ptr == NULL)
25 return;
26
27 if (Ptr->Information != NULL)
28 {
29 for (i = 0; i < Ptr->EntriesRead; i++)
30 midl_user_free(Ptr->Information[i].Sid);
31
32 midl_user_free(Ptr->Information);
33 }
34
36}
37
38
39VOID
43{
44 if (Ptr != NULL)
46}
47
48
49VOID
52 IN PLSAPR_POLICY_INFORMATION PolicyInformation)
53{
54 if (PolicyInformation != NULL)
55 {
56 switch (InformationClass)
57 {
58 case PolicyAuditLogInformation: /* 1 */
59 break;
60
62 if (PolicyInformation->PolicyAuditEventsInfo.EventAuditingOptions != NULL)
63 midl_user_free(PolicyInformation->PolicyAuditEventsInfo.EventAuditingOptions);
64 break;
65
67 if (PolicyInformation->PolicyPrimaryDomInfo.Name.Buffer != NULL)
68 midl_user_free(PolicyInformation->PolicyPrimaryDomInfo.Name.Buffer);
69
70 if (PolicyInformation->PolicyPrimaryDomInfo.Sid != NULL)
71 midl_user_free(PolicyInformation->PolicyPrimaryDomInfo.Sid);
72 break;
73
74 case PolicyPdAccountInformation: /* 4 */
75 if (PolicyInformation->PolicyPdAccountInfo.Name.Buffer != NULL)
76 midl_user_free(PolicyInformation->PolicyPdAccountInfo.Name.Buffer);
77 break;
78
80 if (PolicyInformation->PolicyAccountDomainInfo.DomainName.Buffer != NULL)
81 midl_user_free(PolicyInformation->PolicyAccountDomainInfo.DomainName.Buffer);
82
83 if (PolicyInformation->PolicyAccountDomainInfo.Sid != NULL)
84 midl_user_free(PolicyInformation->PolicyAccountDomainInfo.Sid);
85 break;
86
88 break;
89
91 if (PolicyInformation->PolicyReplicaSourceInfo.ReplicaSource.Buffer != NULL)
92 midl_user_free(PolicyInformation->PolicyReplicaSourceInfo.ReplicaSource.Buffer);
93
94 if (PolicyInformation->PolicyReplicaSourceInfo.ReplicaAccountName.Buffer != NULL)
95 midl_user_free(PolicyInformation->PolicyReplicaSourceInfo.ReplicaAccountName.Buffer);
96 break;
97
99 break;
100
102 break;
103
104 case PolicyAuditFullSetInformation: /* 10 (0xA) */
105 break;
106
107 case PolicyAuditFullQueryInformation: /* 11 (0xB) */
108 break;
109
110 case PolicyDnsDomainInformation: /* 12 (0xC) */
111 if (PolicyInformation->PolicyDnsDomainInfo.Name.Buffer != NULL)
112 midl_user_free(PolicyInformation->PolicyDnsDomainInfo.Name.Buffer);
113
114 if (PolicyInformation->PolicyDnsDomainInfo.DnsDomainName.Buffer != NULL)
115 midl_user_free(PolicyInformation->PolicyDnsDomainInfo.DnsDomainName.Buffer);
116
117 if (PolicyInformation->PolicyDnsDomainInfo.DnsForestName.Buffer != NULL)
118 midl_user_free(PolicyInformation->PolicyDnsDomainInfo.DnsForestName.Buffer);
119
120 if (PolicyInformation->PolicyDnsDomainInfo.Sid != NULL)
121 midl_user_free(PolicyInformation->PolicyDnsDomainInfo.Sid);
122 break;
123
124 case PolicyDnsDomainInformationInt: /* 13 (0xD) */
125 if (PolicyInformation->PolicyDnsDomainInfoInt.Name.Buffer != NULL)
126 midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.Name.Buffer);
127
128 if (PolicyInformation->PolicyDnsDomainInfoInt.DnsDomainName.Buffer != NULL)
129 midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.DnsDomainName.Buffer);
130
131 if (PolicyInformation->PolicyDnsDomainInfoInt.DnsForestName.Buffer != NULL)
132 midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.DnsForestName.Buffer);
133
134 if (PolicyInformation->PolicyDnsDomainInfoInt.Sid != NULL)
135 midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.Sid);
136 break;
137
138 case PolicyLocalAccountDomainInformation: /* 14 (0xE) */
139 if (PolicyInformation->PolicyLocalAccountDomainInfo.DomainName.Buffer != NULL)
140 midl_user_free(PolicyInformation->PolicyLocalAccountDomainInfo.DomainName.Buffer);
141
142 if (PolicyInformation->PolicyLocalAccountDomainInfo.Sid != NULL)
143 midl_user_free(PolicyInformation->PolicyLocalAccountDomainInfo.Sid);
144 break;
145
146 default:
147 ERR("Invalid InformationClass: %lu\n", InformationClass);
148 break;
149 }
150
151 midl_user_free(PolicyInformation);
152 }
153}
154
155
156VOID
157NTAPI
160{
161 ULONG i;
162
163 if (Ptr != NULL)
164 {
165 if (Ptr->Privileges != NULL)
166 {
167 for (i = 0; i < Ptr->Entries; i++)
168 {
169 if (Ptr->Privileges[i].Name.Buffer != NULL)
170 midl_user_free(Ptr->Privileges[i].Name.Buffer);
171 }
172
173 midl_user_free(Ptr->Privileges);
174 }
175 }
176}
177
178
179VOID
180NTAPI
182{
183 if (Ptr != NULL)
184 {
186 }
187}
188
189
190VOID
191NTAPI
194{
195 ULONG i;
196
197 if (Ptr != NULL)
198 {
199 if (Ptr->Domains != NULL)
200 {
201 for (i = 0; i < Ptr->Entries; i++)
202 {
203 if (Ptr->Domains[i].Name.Buffer != NULL)
204 midl_user_free(Ptr->Domains[i].Name.Buffer);
205
206 if (Ptr->Domains[i].Sid != NULL)
207 midl_user_free(Ptr->Domains[i].Sid);
208 }
209
210 midl_user_free(Ptr->Domains);
211 }
212
214 }
215}
216
217
218VOID
219NTAPI
222{
223 if (Ptr != NULL)
224 {
225 if (Ptr->SecurityDescriptor != NULL)
226 midl_user_free(Ptr->SecurityDescriptor);
227
229 }
230}
231
232
233VOID
234NTAPI
237{
238 ULONG i;
239
240 if (Ptr != NULL)
241 {
242 if (Ptr->Names != NULL)
243 {
244 for (i = 0; i < Ptr->Entries; i++)
245 {
246 if (Ptr->Names[i].Name.Buffer != NULL)
247 midl_user_free(Ptr->Names[i].Name.Buffer);
248 }
249
250 midl_user_free(Ptr->Names);
251 }
252
254 }
255}
256
257
258VOID
259NTAPI
262{
263 if (Ptr != NULL)
264 {
265 if (Ptr->Sids != NULL)
266 midl_user_free(Ptr->Sids);
267
269 }
270}
271
272
274WINAPI
276{
278 BOOLEAN PrivilegeEnabled;
279
280 TRACE("LsapInitLsa()\n");
281
282 /* Get the product type */
284
285 /* Initialize the well known SIDs */
286 LsapInitSids();
287
288 /* Initialize the SRM server */
290 if (!NT_SUCCESS(Status))
291 {
292 ERR("LsapRmInitializeServer() failed (Status 0x%08lx)\n", Status);
293 return Status;
294 }
295
296 /* Initialize the LSA database */
298
299 /* Initialize logon sessions */
301
302 /* Initialize the notification list */
304
305 /* Initialize registered authentication packages */
307 if (!NT_SUCCESS(Status))
308 {
309 ERR("LsapInitAuthPackages() failed (Status 0x%08lx)\n", Status);
310 return Status;
311 }
312
313 /* Enable the token creation privilege for the rest of our lifetime */
315 if (!NT_SUCCESS(Status))
316 {
317 ERR("RtlAdjustPrivilege(SE_CREATE_TOKEN_PRIVILEGE) failed, ignoring (Status 0x%08lx)\n", Status);
318 }
319
320 /* Start the authentication LPC port thread */
322 if (!NT_SUCCESS(Status))
323 {
324 ERR("StartAuthenticationPort() failed (Status 0x%08lx)\n", Status);
325 return Status;
326 }
327
328 /* Start the RPC server */
330 if (!NT_SUCCESS(Status))
331 {
332 ERR("LsarStartRpcServer() failed (Status 0x%08lx)\n", Status);
333 return Status;
334 }
335
336 return STATUS_SUCCESS;
337}
338
339
341{
342 return RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, len);
343}
344
345
347{
348 RtlFreeHeap(RtlGetProcessHeap(), 0, ptr);
349}
350
351/* EOF */
unsigned char BOOLEAN
NTSTATUS LsapInitAuthPackages(VOID)
Definition: authpackage.c:474
NTSTATUS StartAuthenticationPort(VOID)
Definition: authport.c:327
LONG NTSTATUS
Definition: precomp.h:26
#define ERR(fmt,...)
Definition: precomp.h:57
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
BOOLEAN NTAPI RtlGetNtProductType(_Out_ PNT_PRODUCT_TYPE ProductType)
Definition: version.c:96
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
NTSTATUS LsapInitDatabase(VOID)
Definition: database.c:539
NTSTATUS LsapInitSids(VOID)
Definition: lookup.c:182
VOID LsapInitNotificationList(VOID)
Definition: notify.c:28
VOID LsapInitLogonSessions(VOID)
Definition: session.c:36
NTSTATUS LsapRmInitializeServer(VOID)
Definition: srm.c:167
enum _NT_PRODUCT_TYPE NT_PRODUCT_TYPE
@ NtProductWinNt
Definition: shellpath.c:64
_In_ FILTER_INFORMATION_CLASS InformationClass
Definition: fltkernel.h:1713
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
Status
Definition: gdiplustypes.h:25
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSTATUS LsarStartRpcServer(VOID)
Definition: lsarpc.c:40
NTSTATUS WINAPI LsapInitLsa(VOID)
Definition: lsasrv.c:275
NT_PRODUCT_TYPE LsapProductType
Definition: lsasrv.c:13
VOID NTAPI LsaIFree_LSAPR_CR_CIPHER_VALUE(IN PLSAPR_CR_CIPHER_VALUE Ptr)
Definition: lsasrv.c:41
VOID NTAPI LsaIFree_LSAPR_PRIVILEGE_ENUM_BUFFER(IN PLSAPR_PRIVILEGE_ENUM_BUFFER Ptr)
Definition: lsasrv.c:158
VOID NTAPI LsaIFree_LSAPR_POLICY_INFORMATION(IN POLICY_INFORMATION_CLASS InformationClass, IN PLSAPR_POLICY_INFORMATION PolicyInformation)
Definition: lsasrv.c:51
VOID NTAPI LsaIFree_LSAPR_TRANSLATED_SIDS(IN PLSAPR_TRANSLATED_SIDS Ptr)
Definition: lsasrv.c:260
VOID NTAPI LsaIFree_LSAPR_REFERENCED_DOMAIN_LIST(IN PLSAPR_REFERENCED_DOMAIN_LIST Ptr)
Definition: lsasrv.c:192
VOID NTAPI LsaIFree_LSAPR_SR_SECURITY_DESCRIPTOR(IN PLSAPR_SR_SECURITY_DESCRIPTOR Ptr)
Definition: lsasrv.c:220
VOID NTAPI LsaIFree_LSAPR_TRANSLATED_NAMES(IN PLSAPR_TRANSLATED_NAMES Ptr)
Definition: lsasrv.c:235
VOID NTAPI LsaIFree_LSAPR_ACCOUNT_ENUM_BUFFER(IN PLSAPR_ACCOUNT_ENUM_BUFFER Ptr)
Definition: lsasrv.c:19
VOID NTAPI LsaIFree_LSAPR_PRIVILEGE_SET(IN PLSAPR_PRIVILEGE_SET Ptr)
Definition: lsasrv.c:181
static PVOID ptr
Definition: dispmode.c:27
#define SE_CREATE_TOKEN_PRIVILEGE
Definition: security.c:656
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
@ PolicyModificationInformation
Definition: ntsecapi.h:251
@ PolicyAuditEventsInformation
Definition: ntsecapi.h:244
@ PolicyDnsDomainInformationInt
Definition: ntsecapi.h:255
@ PolicyDefaultQuotaInformation
Definition: ntsecapi.h:250
@ PolicyReplicaSourceInformation
Definition: ntsecapi.h:249
@ PolicyLsaServerRoleInformation
Definition: ntsecapi.h:248
@ PolicyAuditFullSetInformation
Definition: ntsecapi.h:252
@ PolicyDnsDomainInformation
Definition: ntsecapi.h:254
@ PolicyPrimaryDomainInformation
Definition: ntsecapi.h:245
@ PolicyAuditLogInformation
Definition: ntsecapi.h:243
@ PolicyAuditFullQueryInformation
Definition: ntsecapi.h:253
@ PolicyLocalAccountDomainInformation
Definition: ntsecapi.h:256
@ PolicyPdAccountInformation
Definition: ntsecapi.h:246
@ PolicyAccountDomainInformation
Definition: ntsecapi.h:247
enum _POLICY_INFORMATION_CLASS POLICY_INFORMATION_CLASS
#define midl_user_free
Definition: rpc.h:45
#define __RPC_FAR
Definition: rpc.h:56
#define __RPC_USER
Definition: rpc.h:65
#define midl_user_allocate
Definition: rpc.h:44
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACE(s)
Definition: solgame.cpp:4
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define WINAPI
Definition: msvc.h:6