2009-12-28 11:59:20 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: Local Security Authority Server DLL
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* FILE: dll/win32/lsasrv/lsasrv.c
|
|
|
|
* PURPOSE: Main file
|
|
|
|
* COPYRIGHT: Copyright 2006-2009 Eric Kohl
|
|
|
|
*/
|
|
|
|
|
2008-12-06 21:33:49 +00:00
|
|
|
#include "lsasrv.h"
|
2005-07-31 12:11:56 +00:00
|
|
|
|
2009-12-28 11:59:20 +00:00
|
|
|
/* FUNCTIONS ***************************************************************/
|
|
|
|
|
2013-03-17 10:49:46 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
LsaIFree_LSAPR_POLICY_INFORMATION(IN POLICY_INFORMATION_CLASS InformationClass,
|
|
|
|
IN PLSAPR_POLICY_INFORMATION PolicyInformation)
|
|
|
|
{
|
|
|
|
if (PolicyInformation != NULL)
|
|
|
|
{
|
|
|
|
switch (InformationClass)
|
|
|
|
{
|
|
|
|
case PolicyAuditLogInformation: /* 1 */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PolicyAuditEventsInformation: /* 2 */
|
|
|
|
if (PolicyInformation->PolicyAuditEventsInfo.EventAuditingOptions != NULL)
|
|
|
|
midl_user_free(PolicyInformation->PolicyAuditEventsInfo.EventAuditingOptions);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PolicyPrimaryDomainInformation: /* 3 */
|
|
|
|
if (PolicyInformation->PolicyPrimaryDomInfo.Name.Buffer != NULL)
|
|
|
|
midl_user_free(PolicyInformation->PolicyPrimaryDomInfo.Name.Buffer);
|
|
|
|
|
|
|
|
if (PolicyInformation->PolicyPrimaryDomInfo.Sid != NULL)
|
|
|
|
midl_user_free(PolicyInformation->PolicyPrimaryDomInfo.Sid);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PolicyPdAccountInformation: /* 4 */
|
|
|
|
if (PolicyInformation->PolicyPdAccountInfo.Name.Buffer != NULL)
|
|
|
|
midl_user_free(PolicyInformation->PolicyPdAccountInfo.Name.Buffer);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PolicyAccountDomainInformation: /* 5 */
|
|
|
|
if (PolicyInformation->PolicyAccountDomainInfo.DomainName.Buffer != NULL)
|
|
|
|
midl_user_free(PolicyInformation->PolicyAccountDomainInfo.DomainName.Buffer);
|
|
|
|
|
|
|
|
if (PolicyInformation->PolicyAccountDomainInfo.Sid != NULL)
|
|
|
|
midl_user_free(PolicyInformation->PolicyAccountDomainInfo.Sid);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PolicyLsaServerRoleInformation: /* 6 */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PolicyReplicaSourceInformation: /* 7 */
|
|
|
|
if (PolicyInformation->PolicyReplicaSourceInfo.ReplicaSource.Buffer != NULL)
|
|
|
|
midl_user_free(PolicyInformation->PolicyReplicaSourceInfo.ReplicaSource.Buffer);
|
|
|
|
|
|
|
|
if (PolicyInformation->PolicyReplicaSourceInfo.ReplicaAccountName.Buffer != NULL)
|
|
|
|
midl_user_free(PolicyInformation->PolicyReplicaSourceInfo.ReplicaAccountName.Buffer);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PolicyDefaultQuotaInformation: /* 8 */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PolicyModificationInformation: /* 9 */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PolicyAuditFullSetInformation: /* 10 (0xA) */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PolicyAuditFullQueryInformation: /* 11 (0xB) */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PolicyDnsDomainInformation: /* 12 (0xC) */
|
|
|
|
if (PolicyInformation->PolicyDnsDomainInfo.Name.Buffer != NULL)
|
|
|
|
midl_user_free(PolicyInformation->PolicyDnsDomainInfo.Name.Buffer);
|
|
|
|
|
|
|
|
if (PolicyInformation->PolicyDnsDomainInfo.DnsDomainName.Buffer != NULL)
|
|
|
|
midl_user_free(PolicyInformation->PolicyDnsDomainInfo.DnsDomainName.Buffer);
|
|
|
|
|
|
|
|
if (PolicyInformation->PolicyDnsDomainInfo.DnsForestName.Buffer != NULL)
|
|
|
|
midl_user_free(PolicyInformation->PolicyDnsDomainInfo.DnsForestName.Buffer);
|
|
|
|
|
|
|
|
if (PolicyInformation->PolicyDnsDomainInfo.Sid != NULL)
|
|
|
|
midl_user_free(PolicyInformation->PolicyDnsDomainInfo.Sid);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PolicyDnsDomainInformationInt: /* 13 (0xD) */
|
|
|
|
if (PolicyInformation->PolicyDnsDomainInfoInt.Name.Buffer != NULL)
|
|
|
|
midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.Name.Buffer);
|
|
|
|
|
|
|
|
if (PolicyInformation->PolicyDnsDomainInfoInt.DnsDomainName.Buffer != NULL)
|
|
|
|
midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.DnsDomainName.Buffer);
|
|
|
|
|
|
|
|
if (PolicyInformation->PolicyDnsDomainInfoInt.DnsForestName.Buffer != NULL)
|
|
|
|
midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.DnsForestName.Buffer);
|
|
|
|
|
|
|
|
if (PolicyInformation->PolicyDnsDomainInfoInt.Sid != NULL)
|
|
|
|
midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.Sid);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PolicyLocalAccountDomainInformation: /* 14 (0xE) */
|
|
|
|
if (PolicyInformation->PolicyLocalAccountDomainInfo.DomainName.Buffer != NULL)
|
|
|
|
midl_user_free(PolicyInformation->PolicyLocalAccountDomainInfo.DomainName.Buffer);
|
|
|
|
|
|
|
|
if (PolicyInformation->PolicyLocalAccountDomainInfo.Sid != NULL)
|
|
|
|
midl_user_free(PolicyInformation->PolicyLocalAccountDomainInfo.Sid);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ERR("Invalid InformationClass: %lu\n", InformationClass);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
midl_user_free(PolicyInformation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-01 23:25:26 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
LsaIFree_LSAPR_PRIVILEGE_SET(IN PLSAPR_PRIVILEGE_SET Ptr)
|
|
|
|
{
|
|
|
|
if (Ptr != NULL)
|
|
|
|
{
|
|
|
|
midl_user_free(Ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-30 11:42:05 +00:00
|
|
|
NTSTATUS WINAPI
|
2005-07-31 12:11:56 +00:00
|
|
|
LsapInitLsa(VOID)
|
|
|
|
{
|
2006-01-15 13:19:57 +00:00
|
|
|
HANDLE hEvent;
|
2008-12-13 14:47:07 +00:00
|
|
|
DWORD dwError;
|
2013-03-03 19:43:33 +00:00
|
|
|
NTSTATUS Status;
|
2006-01-15 13:19:57 +00:00
|
|
|
|
2009-12-28 11:59:20 +00:00
|
|
|
TRACE("LsapInitLsa() called\n");
|
2006-01-15 13:19:57 +00:00
|
|
|
|
2010-07-31 11:24:16 +00:00
|
|
|
/* Initialize the well known SIDs */
|
|
|
|
LsapInitSids();
|
|
|
|
|
2011-09-20 23:15:51 +00:00
|
|
|
/* Initialize the LSA database */
|
|
|
|
LsapInitDatabase();
|
|
|
|
|
2013-09-30 19:49:46 +00:00
|
|
|
/* Initialize logon sessions */
|
|
|
|
LsapInitLogonSessions();
|
|
|
|
|
2013-03-03 19:43:33 +00:00
|
|
|
/* Initialize registered authentication packages */
|
|
|
|
Status = LsapInitAuthPackages();
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
ERR("LsapInitAuthPackages() failed (Status 0x%08lx)\n", Status);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Start the authentication port thread */
|
|
|
|
Status = StartAuthenticationPort();
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
ERR("StartAuthenticationPort() failed (Status 0x%08lx)\n", Status);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-12-13 14:47:07 +00:00
|
|
|
/* Start the RPC server */
|
2006-01-15 13:19:57 +00:00
|
|
|
LsarStartRpcServer();
|
|
|
|
|
2012-09-19 12:26:22 +00:00
|
|
|
TRACE("Creating notification event!\n");
|
2008-12-13 14:47:07 +00:00
|
|
|
/* Notify the service manager */
|
|
|
|
hEvent = CreateEventW(NULL,
|
|
|
|
TRUE,
|
|
|
|
FALSE,
|
|
|
|
L"LSA_RPC_SERVER_ACTIVE");
|
|
|
|
if (hEvent == NULL)
|
2006-01-15 13:19:57 +00:00
|
|
|
{
|
2008-12-13 14:47:07 +00:00
|
|
|
dwError = GetLastError();
|
2012-09-19 12:26:22 +00:00
|
|
|
TRACE("Failed to create the notication event (Error %lu)\n", dwError);
|
2008-12-13 14:47:07 +00:00
|
|
|
|
|
|
|
if (dwError == ERROR_ALREADY_EXISTS)
|
|
|
|
{
|
|
|
|
hEvent = OpenEventW(GENERIC_WRITE,
|
|
|
|
FALSE,
|
|
|
|
L"LSA_RPC_SERVER_ACTIVE");
|
2010-09-12 16:29:43 +00:00
|
|
|
if (hEvent == NULL)
|
2008-12-13 14:47:07 +00:00
|
|
|
{
|
2012-09-19 12:26:22 +00:00
|
|
|
ERR("Could not open the notification event (Error %lu)\n", GetLastError());
|
2010-09-12 16:29:43 +00:00
|
|
|
return STATUS_UNSUCCESSFUL;
|
2008-12-13 14:47:07 +00:00
|
|
|
}
|
|
|
|
}
|
2006-01-15 13:19:57 +00:00
|
|
|
}
|
2008-12-13 14:47:07 +00:00
|
|
|
|
2012-09-19 12:26:22 +00:00
|
|
|
TRACE("Set notification event!\n");
|
2008-12-13 14:47:07 +00:00
|
|
|
SetEvent(hEvent);
|
|
|
|
|
|
|
|
/* NOTE: Do not close the event handle!!!! */
|
|
|
|
|
2006-01-15 13:19:57 +00:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-12-06 21:33:49 +00:00
|
|
|
|
2010-10-16 08:48:25 +00:00
|
|
|
NTSTATUS WINAPI
|
|
|
|
ServiceInit(VOID)
|
|
|
|
{
|
|
|
|
TRACE("ServiceInit() called\n");
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-07 20:15:12 +00:00
|
|
|
void __RPC_FAR * __RPC_USER midl_user_allocate(SIZE_T len)
|
2006-01-15 13:19:57 +00:00
|
|
|
{
|
|
|
|
return RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, len);
|
|
|
|
}
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
|
2006-01-15 13:19:57 +00:00
|
|
|
void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
|
|
|
|
{
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, ptr);
|
2005-07-31 12:11:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|