2 * PROJECT: Local Security Authority Server DLL
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/win32/lsasrv/lsasrv.c
6 * COPYRIGHT: Copyright 2006-2009 Eric Kohl
9 /* INCLUDES ****************************************************************/
13 /* FUNCTIONS ***************************************************************/
17 LsaIFree_LSAPR_ACCOUNT_ENUM_BUFFER(
18 IN PLSAPR_ACCOUNT_ENUM_BUFFER Ptr
)
25 if (Ptr
->Information
!= NULL
)
27 for (i
= 0; i
< Ptr
->EntriesRead
; i
++)
28 midl_user_free(Ptr
->Information
[i
].Sid
);
30 midl_user_free(Ptr
->Information
);
39 LsaIFree_LSAPR_CR_CIPHER_VALUE(
40 IN PLSAPR_CR_CIPHER_VALUE Ptr
)
49 LsaIFree_LSAPR_POLICY_INFORMATION(IN POLICY_INFORMATION_CLASS InformationClass
,
50 IN PLSAPR_POLICY_INFORMATION PolicyInformation
)
52 if (PolicyInformation
!= NULL
)
54 switch (InformationClass
)
56 case PolicyAuditLogInformation
: /* 1 */
59 case PolicyAuditEventsInformation
: /* 2 */
60 if (PolicyInformation
->PolicyAuditEventsInfo
.EventAuditingOptions
!= NULL
)
61 midl_user_free(PolicyInformation
->PolicyAuditEventsInfo
.EventAuditingOptions
);
64 case PolicyPrimaryDomainInformation
: /* 3 */
65 if (PolicyInformation
->PolicyPrimaryDomInfo
.Name
.Buffer
!= NULL
)
66 midl_user_free(PolicyInformation
->PolicyPrimaryDomInfo
.Name
.Buffer
);
68 if (PolicyInformation
->PolicyPrimaryDomInfo
.Sid
!= NULL
)
69 midl_user_free(PolicyInformation
->PolicyPrimaryDomInfo
.Sid
);
72 case PolicyPdAccountInformation
: /* 4 */
73 if (PolicyInformation
->PolicyPdAccountInfo
.Name
.Buffer
!= NULL
)
74 midl_user_free(PolicyInformation
->PolicyPdAccountInfo
.Name
.Buffer
);
77 case PolicyAccountDomainInformation
: /* 5 */
78 if (PolicyInformation
->PolicyAccountDomainInfo
.DomainName
.Buffer
!= NULL
)
79 midl_user_free(PolicyInformation
->PolicyAccountDomainInfo
.DomainName
.Buffer
);
81 if (PolicyInformation
->PolicyAccountDomainInfo
.Sid
!= NULL
)
82 midl_user_free(PolicyInformation
->PolicyAccountDomainInfo
.Sid
);
85 case PolicyLsaServerRoleInformation
: /* 6 */
88 case PolicyReplicaSourceInformation
: /* 7 */
89 if (PolicyInformation
->PolicyReplicaSourceInfo
.ReplicaSource
.Buffer
!= NULL
)
90 midl_user_free(PolicyInformation
->PolicyReplicaSourceInfo
.ReplicaSource
.Buffer
);
92 if (PolicyInformation
->PolicyReplicaSourceInfo
.ReplicaAccountName
.Buffer
!= NULL
)
93 midl_user_free(PolicyInformation
->PolicyReplicaSourceInfo
.ReplicaAccountName
.Buffer
);
96 case PolicyDefaultQuotaInformation
: /* 8 */
99 case PolicyModificationInformation
: /* 9 */
102 case PolicyAuditFullSetInformation
: /* 10 (0xA) */
105 case PolicyAuditFullQueryInformation
: /* 11 (0xB) */
108 case PolicyDnsDomainInformation
: /* 12 (0xC) */
109 if (PolicyInformation
->PolicyDnsDomainInfo
.Name
.Buffer
!= NULL
)
110 midl_user_free(PolicyInformation
->PolicyDnsDomainInfo
.Name
.Buffer
);
112 if (PolicyInformation
->PolicyDnsDomainInfo
.DnsDomainName
.Buffer
!= NULL
)
113 midl_user_free(PolicyInformation
->PolicyDnsDomainInfo
.DnsDomainName
.Buffer
);
115 if (PolicyInformation
->PolicyDnsDomainInfo
.DnsForestName
.Buffer
!= NULL
)
116 midl_user_free(PolicyInformation
->PolicyDnsDomainInfo
.DnsForestName
.Buffer
);
118 if (PolicyInformation
->PolicyDnsDomainInfo
.Sid
!= NULL
)
119 midl_user_free(PolicyInformation
->PolicyDnsDomainInfo
.Sid
);
122 case PolicyDnsDomainInformationInt
: /* 13 (0xD) */
123 if (PolicyInformation
->PolicyDnsDomainInfoInt
.Name
.Buffer
!= NULL
)
124 midl_user_free(PolicyInformation
->PolicyDnsDomainInfoInt
.Name
.Buffer
);
126 if (PolicyInformation
->PolicyDnsDomainInfoInt
.DnsDomainName
.Buffer
!= NULL
)
127 midl_user_free(PolicyInformation
->PolicyDnsDomainInfoInt
.DnsDomainName
.Buffer
);
129 if (PolicyInformation
->PolicyDnsDomainInfoInt
.DnsForestName
.Buffer
!= NULL
)
130 midl_user_free(PolicyInformation
->PolicyDnsDomainInfoInt
.DnsForestName
.Buffer
);
132 if (PolicyInformation
->PolicyDnsDomainInfoInt
.Sid
!= NULL
)
133 midl_user_free(PolicyInformation
->PolicyDnsDomainInfoInt
.Sid
);
136 case PolicyLocalAccountDomainInformation
: /* 14 (0xE) */
137 if (PolicyInformation
->PolicyLocalAccountDomainInfo
.DomainName
.Buffer
!= NULL
)
138 midl_user_free(PolicyInformation
->PolicyLocalAccountDomainInfo
.DomainName
.Buffer
);
140 if (PolicyInformation
->PolicyLocalAccountDomainInfo
.Sid
!= NULL
)
141 midl_user_free(PolicyInformation
->PolicyLocalAccountDomainInfo
.Sid
);
145 ERR("Invalid InformationClass: %lu\n", InformationClass
);
149 midl_user_free(PolicyInformation
);
156 LsaIFree_LSAPR_PRIVILEGE_ENUM_BUFFER(
157 IN PLSAPR_PRIVILEGE_ENUM_BUFFER Ptr
)
163 if (Ptr
->Privileges
!= NULL
)
165 for (i
= 0; i
< Ptr
->Entries
; i
++)
167 if (Ptr
->Privileges
[i
].Name
.Buffer
!= NULL
)
168 midl_user_free(Ptr
->Privileges
[i
].Name
.Buffer
);
171 midl_user_free(Ptr
->Privileges
);
179 LsaIFree_LSAPR_PRIVILEGE_SET(IN PLSAPR_PRIVILEGE_SET Ptr
)
190 LsaIFree_LSAPR_REFERENCED_DOMAIN_LIST(
191 IN PLSAPR_REFERENCED_DOMAIN_LIST Ptr
)
197 if (Ptr
->Domains
!= NULL
)
199 for (i
= 0; i
< Ptr
->Entries
; i
++)
201 if (Ptr
->Domains
[i
].Name
.Buffer
!= NULL
)
202 midl_user_free(Ptr
->Domains
[i
].Name
.Buffer
);
204 if (Ptr
->Domains
[i
].Sid
!= NULL
)
205 midl_user_free(Ptr
->Domains
[i
].Sid
);
208 midl_user_free(Ptr
->Domains
);
218 LsaIFree_LSAPR_SR_SECURITY_DESCRIPTOR(
219 IN PLSAPR_SR_SECURITY_DESCRIPTOR Ptr
)
223 if (Ptr
->SecurityDescriptor
!= NULL
)
224 midl_user_free(Ptr
->SecurityDescriptor
);
233 LsaIFree_LSAPR_TRANSLATED_NAMES(
234 IN PLSAPR_TRANSLATED_NAMES Ptr
)
240 if (Ptr
->Names
!= NULL
)
242 for (i
= 0; i
< Ptr
->Entries
; i
++)
244 if (Ptr
->Names
[i
].Name
.Buffer
!= NULL
)
245 midl_user_free(Ptr
->Names
[i
].Name
.Buffer
);
248 midl_user_free(Ptr
->Names
);
258 LsaIFree_LSAPR_TRANSLATED_SIDS(
259 IN PLSAPR_TRANSLATED_SIDS Ptr
)
263 if (Ptr
->Sids
!= NULL
)
264 midl_user_free(Ptr
->Sids
);
275 BOOLEAN PrivilegeEnabled
;
277 TRACE("LsapInitLsa() called\n");
279 /* Initialize the well known SIDs */
282 /* Initialize the SRM server */
283 Status
= LsapRmInitializeServer();
284 if (!NT_SUCCESS(Status
))
286 ERR("LsapRmInitializeServer() failed (Status 0x%08lx)\n", Status
);
290 /* Initialize the LSA database */
293 /* Initialize logon sessions */
294 LsapInitLogonSessions();
296 /* Initialize the notification list */
297 LsapInitNotificationList();
299 /* Initialize registered authentication packages */
300 Status
= LsapInitAuthPackages();
301 if (!NT_SUCCESS(Status
))
303 ERR("LsapInitAuthPackages() failed (Status 0x%08lx)\n", Status
);
307 /* Enable the token creation privilege for the rest of our lifetime */
308 Status
= RtlAdjustPrivilege(SE_CREATE_TOKEN_PRIVILEGE
, TRUE
, FALSE
, &PrivilegeEnabled
);
309 if (!NT_SUCCESS(Status
))
311 ERR("RtlAdjustPrivilege(SE_CREATE_TOKEN_PRIVILEGE) failed, ignoring (Status 0x%08lx)\n", Status
);
314 /* Start the authentication LPC port thread */
315 Status
= StartAuthenticationPort();
316 if (!NT_SUCCESS(Status
))
318 ERR("StartAuthenticationPort() failed (Status 0x%08lx)\n", Status
);
322 /* Start the RPC server */
323 Status
= LsarStartRpcServer();
324 if (!NT_SUCCESS(Status
))
326 ERR("LsarStartRpcServer() failed (Status 0x%08lx)\n", Status
);
330 return STATUS_SUCCESS
;
334 void __RPC_FAR
* __RPC_USER
midl_user_allocate(SIZE_T len
)
336 return RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY
, len
);
340 void __RPC_USER
midl_user_free(void __RPC_FAR
* ptr
)
342 RtlFreeHeap(RtlGetProcessHeap(), 0, ptr
);