[LSASRV]
[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 VOID
121 NTAPI
122 LsaIFree_LSAPR_PRIVILEGE_SET(IN PLSAPR_PRIVILEGE_SET Ptr)
123 {
124 if (Ptr != NULL)
125 {
126 midl_user_free(Ptr);
127 }
128 }
129
130
131 NTSTATUS WINAPI
132 LsapInitLsa(VOID)
133 {
134 HANDLE hEvent;
135 DWORD dwError;
136 NTSTATUS Status;
137
138 TRACE("LsapInitLsa() called\n");
139
140 /* Initialize the well known SIDs */
141 LsapInitSids();
142
143 /* Initialize the LSA database */
144 LsapInitDatabase();
145
146 /* Initialize logon sessions */
147 LsapInitLogonSessions();
148
149 /* Initialize registered authentication packages */
150 Status = LsapInitAuthPackages();
151 if (!NT_SUCCESS(Status))
152 {
153 ERR("LsapInitAuthPackages() failed (Status 0x%08lx)\n", Status);
154 return Status;
155 }
156
157 /* Start the authentication port thread */
158 Status = StartAuthenticationPort();
159 if (!NT_SUCCESS(Status))
160 {
161 ERR("StartAuthenticationPort() failed (Status 0x%08lx)\n", Status);
162 return Status;
163 }
164
165 /* Start the RPC server */
166 LsarStartRpcServer();
167
168 TRACE("Creating notification event!\n");
169 /* Notify the service manager */
170 hEvent = CreateEventW(NULL,
171 TRUE,
172 FALSE,
173 L"LSA_RPC_SERVER_ACTIVE");
174 if (hEvent == NULL)
175 {
176 dwError = GetLastError();
177 TRACE("Failed to create the notication event (Error %lu)\n", dwError);
178
179 if (dwError == ERROR_ALREADY_EXISTS)
180 {
181 hEvent = OpenEventW(GENERIC_WRITE,
182 FALSE,
183 L"LSA_RPC_SERVER_ACTIVE");
184 if (hEvent == NULL)
185 {
186 ERR("Could not open the notification event (Error %lu)\n", GetLastError());
187 return STATUS_UNSUCCESSFUL;
188 }
189 }
190 }
191
192 TRACE("Set notification event!\n");
193 SetEvent(hEvent);
194
195 /* NOTE: Do not close the event handle!!!! */
196
197 return STATUS_SUCCESS;
198 }
199
200
201 NTSTATUS WINAPI
202 ServiceInit(VOID)
203 {
204 TRACE("ServiceInit() called\n");
205 return STATUS_SUCCESS;
206 }
207
208
209 void __RPC_FAR * __RPC_USER midl_user_allocate(SIZE_T len)
210 {
211 return RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, len);
212 }
213
214
215 void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
216 {
217 RtlFreeHeap(RtlGetProcessHeap(), 0, ptr);
218 }
219
220 /* EOF */