a41a32faa6a34787c16ba8a27b9e8b6cfaf8e80b
[reactos.git] / reactos / dll / win32 / lsasrv / lsasrv.c
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 #include "lsasrv.h"
10
11 /* FUNCTIONS ***************************************************************/
12
13 VOID
14 NTAPI
15 LsaIFree_LSAPR_POLICY_INFORMATION(IN POLICY_INFORMATION_CLASS InformationClass,
16 IN PLSAPR_POLICY_INFORMATION PolicyInformation)
17 {
18 if (PolicyInformation != NULL)
19 {
20 switch (InformationClass)
21 {
22 case PolicyAuditLogInformation: /* 1 */
23 break;
24
25 case PolicyAuditEventsInformation: /* 2 */
26 if (PolicyInformation->PolicyAuditEventsInfo.EventAuditingOptions != NULL)
27 midl_user_free(PolicyInformation->PolicyAuditEventsInfo.EventAuditingOptions);
28 break;
29
30 case PolicyPrimaryDomainInformation: /* 3 */
31 if (PolicyInformation->PolicyPrimaryDomInfo.Name.Buffer != NULL)
32 midl_user_free(PolicyInformation->PolicyPrimaryDomInfo.Name.Buffer);
33
34 if (PolicyInformation->PolicyPrimaryDomInfo.Sid != NULL)
35 midl_user_free(PolicyInformation->PolicyPrimaryDomInfo.Sid);
36 break;
37
38 case PolicyPdAccountInformation: /* 4 */
39 if (PolicyInformation->PolicyPdAccountInfo.Name.Buffer != NULL)
40 midl_user_free(PolicyInformation->PolicyPdAccountInfo.Name.Buffer);
41 break;
42
43 case PolicyAccountDomainInformation: /* 5 */
44 if (PolicyInformation->PolicyAccountDomainInfo.DomainName.Buffer != NULL)
45 midl_user_free(PolicyInformation->PolicyAccountDomainInfo.DomainName.Buffer);
46
47 if (PolicyInformation->PolicyAccountDomainInfo.Sid != NULL)
48 midl_user_free(PolicyInformation->PolicyAccountDomainInfo.Sid);
49 break;
50
51 case PolicyLsaServerRoleInformation: /* 6 */
52 break;
53
54 case PolicyReplicaSourceInformation: /* 7 */
55 if (PolicyInformation->PolicyReplicaSourceInfo.ReplicaSource.Buffer != NULL)
56 midl_user_free(PolicyInformation->PolicyReplicaSourceInfo.ReplicaSource.Buffer);
57
58 if (PolicyInformation->PolicyReplicaSourceInfo.ReplicaAccountName.Buffer != NULL)
59 midl_user_free(PolicyInformation->PolicyReplicaSourceInfo.ReplicaAccountName.Buffer);
60 break;
61
62 case PolicyDefaultQuotaInformation: /* 8 */
63 break;
64
65 case PolicyModificationInformation: /* 9 */
66 break;
67
68 case PolicyAuditFullSetInformation: /* 10 (0xA) */
69 break;
70
71 case PolicyAuditFullQueryInformation: /* 11 (0xB) */
72 break;
73
74 case PolicyDnsDomainInformation: /* 12 (0xC) */
75 if (PolicyInformation->PolicyDnsDomainInfo.Name.Buffer != NULL)
76 midl_user_free(PolicyInformation->PolicyDnsDomainInfo.Name.Buffer);
77
78 if (PolicyInformation->PolicyDnsDomainInfo.DnsDomainName.Buffer != NULL)
79 midl_user_free(PolicyInformation->PolicyDnsDomainInfo.DnsDomainName.Buffer);
80
81 if (PolicyInformation->PolicyDnsDomainInfo.DnsForestName.Buffer != NULL)
82 midl_user_free(PolicyInformation->PolicyDnsDomainInfo.DnsForestName.Buffer);
83
84 if (PolicyInformation->PolicyDnsDomainInfo.Sid != NULL)
85 midl_user_free(PolicyInformation->PolicyDnsDomainInfo.Sid);
86 break;
87
88 case PolicyDnsDomainInformationInt: /* 13 (0xD) */
89 if (PolicyInformation->PolicyDnsDomainInfoInt.Name.Buffer != NULL)
90 midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.Name.Buffer);
91
92 if (PolicyInformation->PolicyDnsDomainInfoInt.DnsDomainName.Buffer != NULL)
93 midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.DnsDomainName.Buffer);
94
95 if (PolicyInformation->PolicyDnsDomainInfoInt.DnsForestName.Buffer != NULL)
96 midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.DnsForestName.Buffer);
97
98 if (PolicyInformation->PolicyDnsDomainInfoInt.Sid != NULL)
99 midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.Sid);
100 break;
101
102 case PolicyLocalAccountDomainInformation: /* 14 (0xE) */
103 if (PolicyInformation->PolicyLocalAccountDomainInfo.DomainName.Buffer != NULL)
104 midl_user_free(PolicyInformation->PolicyLocalAccountDomainInfo.DomainName.Buffer);
105
106 if (PolicyInformation->PolicyLocalAccountDomainInfo.Sid != NULL)
107 midl_user_free(PolicyInformation->PolicyLocalAccountDomainInfo.Sid);
108 break;
109
110 default:
111 ERR("Invalid InformationClass: %lu\n", InformationClass);
112 break;
113 }
114
115 midl_user_free(PolicyInformation);
116 }
117 }
118
119
120 NTSTATUS WINAPI
121 LsapInitLsa(VOID)
122 {
123 HANDLE hEvent;
124 DWORD dwError;
125 NTSTATUS Status;
126
127 TRACE("LsapInitLsa() called\n");
128
129 /* Initialize the well known SIDs */
130 LsapInitSids();
131
132 /* Initialize the LSA database */
133 LsapInitDatabase();
134
135 /* Initialize logon sessions */
136 LsapInitLogonSessions();
137
138 /* Initialize registered authentication packages */
139 Status = LsapInitAuthPackages();
140 if (!NT_SUCCESS(Status))
141 {
142 ERR("LsapInitAuthPackages() failed (Status 0x%08lx)\n", Status);
143 return Status;
144 }
145
146 /* Start the authentication port thread */
147 Status = StartAuthenticationPort();
148 if (!NT_SUCCESS(Status))
149 {
150 ERR("StartAuthenticationPort() failed (Status 0x%08lx)\n", Status);
151 return Status;
152 }
153
154 /* Start the RPC server */
155 LsarStartRpcServer();
156
157 TRACE("Creating notification event!\n");
158 /* Notify the service manager */
159 hEvent = CreateEventW(NULL,
160 TRUE,
161 FALSE,
162 L"LSA_RPC_SERVER_ACTIVE");
163 if (hEvent == NULL)
164 {
165 dwError = GetLastError();
166 TRACE("Failed to create the notication event (Error %lu)\n", dwError);
167
168 if (dwError == ERROR_ALREADY_EXISTS)
169 {
170 hEvent = OpenEventW(GENERIC_WRITE,
171 FALSE,
172 L"LSA_RPC_SERVER_ACTIVE");
173 if (hEvent == NULL)
174 {
175 ERR("Could not open the notification event (Error %lu)\n", GetLastError());
176 return STATUS_UNSUCCESSFUL;
177 }
178 }
179 }
180
181 TRACE("Set notification event!\n");
182 SetEvent(hEvent);
183
184 /* NOTE: Do not close the event handle!!!! */
185
186 return STATUS_SUCCESS;
187 }
188
189
190 NTSTATUS WINAPI
191 ServiceInit(VOID)
192 {
193 TRACE("ServiceInit() called\n");
194 return STATUS_SUCCESS;
195 }
196
197
198 void __RPC_FAR * __RPC_USER midl_user_allocate(SIZE_T len)
199 {
200 return RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, len);
201 }
202
203
204 void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
205 {
206 RtlFreeHeap(RtlGetProcessHeap(), 0, ptr);
207 }
208
209 /* EOF */