Author: ekohl
Date: Sat Jan 12 16:22:46 2013
New Revision: 58160
URL:
http://svn.reactos.org/svn/reactos?rev=58160&view=rev
Log:
[SAMSRV]
- Move domain specific helper functions to a separate file.
- Implement SampRemoveAccountNameFromDomain.
Added:
trunk/reactos/dll/win32/samsrv/domain.c (with props)
Modified:
trunk/reactos/dll/win32/samsrv/CMakeLists.txt
trunk/reactos/dll/win32/samsrv/database.c
trunk/reactos/dll/win32/samsrv/samsrv.h
Modified: trunk/reactos/dll/win32/samsrv/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samsrv/CMakeList…
==============================================================================
--- trunk/reactos/dll/win32/samsrv/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/samsrv/CMakeLists.txt [iso-8859-1] Sat Jan 12 16:22:46 2013
@@ -9,6 +9,7 @@
list(APPEND SOURCE
database.c
+ domain.c
group.c
registry.c
samrpc.c
Modified: trunk/reactos/dll/win32/samsrv/database.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samsrv/database.…
==============================================================================
--- trunk/reactos/dll/win32/samsrv/database.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/samsrv/database.c [iso-8859-1] Sat Jan 12 16:22:46 2013
@@ -488,190 +488,6 @@
NTSTATUS
-SampSetAccountNameInDomain(IN PSAM_DB_OBJECT DomainObject,
- IN LPCWSTR lpContainerName,
- IN LPCWSTR lpAccountName,
- IN ULONG ulRelativeId)
-{
- OBJECT_ATTRIBUTES ObjectAttributes;
- UNICODE_STRING KeyName;
- UNICODE_STRING ValueName;
- HANDLE ContainerKeyHandle = NULL;
- HANDLE NamesKeyHandle = NULL;
- NTSTATUS Status;
-
- TRACE("SampSetAccountNameInDomain()\n");
-
- /* Open the container key */
- RtlInitUnicodeString(&KeyName, lpContainerName);
-
- InitializeObjectAttributes(&ObjectAttributes,
- &KeyName,
- OBJ_CASE_INSENSITIVE,
- DomainObject->KeyHandle,
- NULL);
-
- Status = NtOpenKey(&ContainerKeyHandle,
- KEY_ALL_ACCESS,
- &ObjectAttributes);
- if (!NT_SUCCESS(Status))
- return Status;
-
- /* Open the 'Names' key */
- RtlInitUnicodeString(&KeyName, L"Names");
-
- InitializeObjectAttributes(&ObjectAttributes,
- &KeyName,
- OBJ_CASE_INSENSITIVE,
- ContainerKeyHandle,
- NULL);
-
- Status = NtOpenKey(&NamesKeyHandle,
- KEY_ALL_ACCESS,
- &ObjectAttributes);
- if (!NT_SUCCESS(Status))
- goto done;
-
- /* Set the alias value */
- RtlInitUnicodeString(&ValueName, lpAccountName);
-
- Status = NtSetValueKey(NamesKeyHandle,
- &ValueName,
- 0,
- REG_DWORD,
- (LPVOID)&ulRelativeId,
- sizeof(ULONG));
-
-done:
- if (NamesKeyHandle)
- NtClose(NamesKeyHandle);
-
- if (ContainerKeyHandle)
- NtClose(ContainerKeyHandle);
-
- return Status;
-}
-
-
-NTSTATUS
-SampCheckAccountNameInDomain(IN PSAM_DB_OBJECT DomainObject,
- IN LPCWSTR lpAccountName)
-{
- HANDLE AccountKey;
- HANDLE NamesKey;
- NTSTATUS Status;
-
- TRACE("SampCheckAccountNameInDomain()\n");
-
- Status = SampRegOpenKey(DomainObject->KeyHandle,
- L"Aliases",
- KEY_READ,
- &AccountKey);
- if (NT_SUCCESS(Status))
- {
- Status = SampRegOpenKey(AccountKey,
- L"Names",
- KEY_READ,
- &NamesKey);
- if (NT_SUCCESS(Status))
- {
- Status = SampRegQueryValue(NamesKey,
- lpAccountName,
- NULL,
- NULL,
- NULL);
- if (Status == STATUS_SUCCESS)
- {
- SampRegCloseKey(NamesKey);
- Status = STATUS_ALIAS_EXISTS;
- }
- else if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
- Status = STATUS_SUCCESS;
- }
-
- SampRegCloseKey(AccountKey);
- }
-
- if (!NT_SUCCESS(Status))
- {
- TRACE("Checking for alias account failed (Status 0x%08lx)\n", Status);
- return Status;
- }
-
- Status = SampRegOpenKey(DomainObject->KeyHandle,
- L"Groups",
- KEY_READ,
- &AccountKey);
- if (NT_SUCCESS(Status))
- {
- Status = SampRegOpenKey(AccountKey,
- L"Names",
- KEY_READ,
- &NamesKey);
- if (NT_SUCCESS(Status))
- {
- Status = SampRegQueryValue(NamesKey,
- lpAccountName,
- NULL,
- NULL,
- NULL);
- if (Status == STATUS_SUCCESS)
- {
- SampRegCloseKey(NamesKey);
- Status = STATUS_ALIAS_EXISTS;
- }
- else if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
- Status = STATUS_SUCCESS;
- }
-
- SampRegCloseKey(AccountKey);
- }
-
- if (!NT_SUCCESS(Status))
- {
- TRACE("Checking for group account failed (Status 0x%08lx)\n", Status);
- return Status;
- }
-
- Status = SampRegOpenKey(DomainObject->KeyHandle,
- L"Users",
- KEY_READ,
- &AccountKey);
- if (NT_SUCCESS(Status))
- {
- Status = SampRegOpenKey(AccountKey,
- L"Names",
- KEY_READ,
- &NamesKey);
- if (NT_SUCCESS(Status))
- {
- Status = SampRegQueryValue(NamesKey,
- lpAccountName,
- NULL,
- NULL,
- NULL);
- if (Status == STATUS_SUCCESS)
- {
- SampRegCloseKey(NamesKey);
- Status = STATUS_ALIAS_EXISTS;
- }
- else if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
- Status = STATUS_SUCCESS;
- }
-
- SampRegCloseKey(AccountKey);
- }
-
- if (!NT_SUCCESS(Status))
- {
- TRACE("Checking for user account failed (Status 0x%08lx)\n", Status);
- }
-
- return Status;
-}
-
-
-NTSTATUS
SampSetObjectAttribute(PSAM_DB_OBJECT DbObject,
LPWSTR AttributeName,
ULONG AttributeType,
Added: trunk/reactos/dll/win32/samsrv/domain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samsrv/domain.c?…
==============================================================================
--- trunk/reactos/dll/win32/samsrv/domain.c (added)
+++ trunk/reactos/dll/win32/samsrv/domain.c [iso-8859-1] Sat Jan 12 16:22:46 2013
@@ -1,0 +1,259 @@
+/*
+ * PROJECT: Local Security Authority Server DLL
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: dll/win32/samsrv/domain.c
+ * PURPOSE: Domain specific helper functions
+ * COPYRIGHT: Copyright 2013 Eric Kohl
+ */
+
+/* INCLUDES ****************************************************************/
+
+#include "samsrv.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(samsrv);
+
+
+/* FUNCTIONS ***************************************************************/
+
+NTSTATUS
+SampSetAccountNameInDomain(IN PSAM_DB_OBJECT DomainObject,
+ IN LPCWSTR lpContainerName,
+ IN LPCWSTR lpAccountName,
+ IN ULONG ulRelativeId)
+{
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING KeyName;
+ UNICODE_STRING ValueName;
+ HANDLE ContainerKeyHandle = NULL;
+ HANDLE NamesKeyHandle = NULL;
+ NTSTATUS Status;
+
+ TRACE("SampSetAccountNameInDomain()\n");
+
+ /* Open the container key */
+ RtlInitUnicodeString(&KeyName, lpContainerName);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE,
+ DomainObject->KeyHandle,
+ NULL);
+
+ Status = NtOpenKey(&ContainerKeyHandle,
+ KEY_ALL_ACCESS,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ /* Open the 'Names' key */
+ RtlInitUnicodeString(&KeyName, L"Names");
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE,
+ ContainerKeyHandle,
+ NULL);
+
+ Status = NtOpenKey(&NamesKeyHandle,
+ KEY_ALL_ACCESS,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ goto done;
+
+ /* Set the alias value */
+ RtlInitUnicodeString(&ValueName, lpAccountName);
+
+ Status = NtSetValueKey(NamesKeyHandle,
+ &ValueName,
+ 0,
+ REG_DWORD,
+ (LPVOID)&ulRelativeId,
+ sizeof(ULONG));
+
+done:
+ if (NamesKeyHandle)
+ NtClose(NamesKeyHandle);
+
+ if (ContainerKeyHandle)
+ NtClose(ContainerKeyHandle);
+
+ return Status;
+}
+
+
+NTSTATUS
+SampRemoveAccountNameFromDomain(IN PSAM_DB_OBJECT DomainObject,
+ IN LPCWSTR lpContainerName,
+ IN LPCWSTR lpAccountName)
+{
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING KeyName;
+ HANDLE ContainerKeyHandle = NULL;
+ HANDLE NamesKeyHandle = NULL;
+ NTSTATUS Status;
+
+ TRACE("(%S %S)\n", lpContainerName, lpAccountName);
+
+ /* Open the container key */
+ RtlInitUnicodeString(&KeyName, lpContainerName);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE,
+ DomainObject->KeyHandle,
+ NULL);
+
+ Status = NtOpenKey(&ContainerKeyHandle,
+ KEY_ALL_ACCESS,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ /* Open the 'Names' key */
+ RtlInitUnicodeString(&KeyName, L"Names");
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE,
+ ContainerKeyHandle,
+ NULL);
+
+ Status = NtOpenKey(&NamesKeyHandle,
+ KEY_SET_VALUE,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ goto done;
+
+ /* Delete the account name value */
+ Status = SampRegDeleteValue(NamesKeyHandle,
+ lpAccountName);
+
+done:
+ if (NamesKeyHandle)
+ NtClose(NamesKeyHandle);
+
+ if (ContainerKeyHandle)
+ NtClose(ContainerKeyHandle);
+
+ return Status;
+}
+
+
+NTSTATUS
+SampCheckAccountNameInDomain(IN PSAM_DB_OBJECT DomainObject,
+ IN LPCWSTR lpAccountName)
+{
+ HANDLE AccountKey;
+ HANDLE NamesKey;
+ NTSTATUS Status;
+
+ TRACE("SampCheckAccountNameInDomain()\n");
+
+ Status = SampRegOpenKey(DomainObject->KeyHandle,
+ L"Aliases",
+ KEY_READ,
+ &AccountKey);
+ if (NT_SUCCESS(Status))
+ {
+ Status = SampRegOpenKey(AccountKey,
+ L"Names",
+ KEY_READ,
+ &NamesKey);
+ if (NT_SUCCESS(Status))
+ {
+ Status = SampRegQueryValue(NamesKey,
+ lpAccountName,
+ NULL,
+ NULL,
+ NULL);
+ if (Status == STATUS_SUCCESS)
+ {
+ SampRegCloseKey(NamesKey);
+ Status = STATUS_ALIAS_EXISTS;
+ }
+ else if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
+ Status = STATUS_SUCCESS;
+ }
+
+ SampRegCloseKey(AccountKey);
+ }
+
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("Checking for alias account failed (Status 0x%08lx)\n", Status);
+ return Status;
+ }
+
+ Status = SampRegOpenKey(DomainObject->KeyHandle,
+ L"Groups",
+ KEY_READ,
+ &AccountKey);
+ if (NT_SUCCESS(Status))
+ {
+ Status = SampRegOpenKey(AccountKey,
+ L"Names",
+ KEY_READ,
+ &NamesKey);
+ if (NT_SUCCESS(Status))
+ {
+ Status = SampRegQueryValue(NamesKey,
+ lpAccountName,
+ NULL,
+ NULL,
+ NULL);
+ if (Status == STATUS_SUCCESS)
+ {
+ SampRegCloseKey(NamesKey);
+ Status = STATUS_ALIAS_EXISTS;
+ }
+ else if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
+ Status = STATUS_SUCCESS;
+ }
+
+ SampRegCloseKey(AccountKey);
+ }
+
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("Checking for group account failed (Status 0x%08lx)\n", Status);
+ return Status;
+ }
+
+ Status = SampRegOpenKey(DomainObject->KeyHandle,
+ L"Users",
+ KEY_READ,
+ &AccountKey);
+ if (NT_SUCCESS(Status))
+ {
+ Status = SampRegOpenKey(AccountKey,
+ L"Names",
+ KEY_READ,
+ &NamesKey);
+ if (NT_SUCCESS(Status))
+ {
+ Status = SampRegQueryValue(NamesKey,
+ lpAccountName,
+ NULL,
+ NULL,
+ NULL);
+ if (Status == STATUS_SUCCESS)
+ {
+ SampRegCloseKey(NamesKey);
+ Status = STATUS_ALIAS_EXISTS;
+ }
+ else if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
+ Status = STATUS_SUCCESS;
+ }
+
+ SampRegCloseKey(AccountKey);
+ }
+
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("Checking for user account failed (Status 0x%08lx)\n", Status);
+ }
+
+ return Status;
+}
+
+/* EOF */
Propchange: trunk/reactos/dll/win32/samsrv/domain.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/reactos/dll/win32/samsrv/domain.c
------------------------------------------------------------------------------
svn:keywords = author date id revision
Modified: trunk/reactos/dll/win32/samsrv/samsrv.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samsrv/samsrv.h?…
==============================================================================
--- trunk/reactos/dll/win32/samsrv/samsrv.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/samsrv/samsrv.h [iso-8859-1] Sat Jan 12 16:22:46 2013
@@ -1,6 +1,6 @@
/*
* COPYRIGHT: See COPYING in the top level directory
- * PROJECT: Security Account Manager (SAM) Server
+ * PROJECT: Security Account Manager (LSA) Server
* FILE: reactos/dll/win32/samsrv/samsrv.h
* PURPOSE: Common header file
*
@@ -143,16 +143,6 @@
SampCloseDbObject(PSAM_DB_OBJECT DbObject);
NTSTATUS
-SampCheckAccountNameInDomain(IN PSAM_DB_OBJECT DomainObject,
- IN LPCWSTR lpAccountName);
-
-NTSTATUS
-SampSetAccountNameInDomain(IN PSAM_DB_OBJECT DomainObject,
- IN LPCWSTR lpContainerName,
- IN LPCWSTR lpAccountName,
- IN ULONG ulRelativeId);
-
-NTSTATUS
SampSetObjectAttribute(PSAM_DB_OBJECT DbObject,
LPWSTR AttributeName,
ULONG AttributeType,
@@ -170,6 +160,24 @@
SampGetObjectAttributeString(PSAM_DB_OBJECT DbObject,
LPWSTR AttributeName,
RPC_UNICODE_STRING *String);
+
+
+/* domain.c */
+
+NTSTATUS
+SampSetAccountNameInDomain(IN PSAM_DB_OBJECT DomainObject,
+ IN LPCWSTR lpContainerName,
+ IN LPCWSTR lpAccountName,
+ IN ULONG ulRelativeId);
+
+NTSTATUS
+SampRemoveAccountNameFromDomain(IN PSAM_DB_OBJECT DomainObject,
+ IN LPCWSTR lpContainerName,
+ IN LPCWSTR lpAccountName);
+
+NTSTATUS
+SampCheckAccountNameInDomain(IN PSAM_DB_OBJECT DomainObject,
+ IN LPCWSTR lpAccountName);
/* group.h */