Author: ekohl
Date: Thu May 23 09:42:25 2013
New Revision: 59069
URL:
http://svn.reactos.org/svn/reactos?rev=59069&view=rev
Log:
[SAMSRV]
Move some alias-specific code to alias.c, for later use by the setup code.
Modified:
trunk/reactos/dll/win32/samsrv/alias.c
trunk/reactos/dll/win32/samsrv/samrpc.c
trunk/reactos/dll/win32/samsrv/samsrv.h
Modified: trunk/reactos/dll/win32/samsrv/alias.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samsrv/alias.c?r…
==============================================================================
--- trunk/reactos/dll/win32/samsrv/alias.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/samsrv/alias.c [iso-8859-1] Thu May 23 09:42:25 2013
@@ -39,4 +39,191 @@
AliasObject);
}
+
+NTSTATUS
+SampAddMemberToAlias(IN PSAM_DB_OBJECT AliasObject,
+ IN PRPC_SID MemberId)
+{
+ LPWSTR MemberIdString = NULL;
+ HANDLE MembersKeyHandle = NULL;
+ HANDLE MemberKeyHandle = NULL;
+ ULONG MemberIdLength;
+ NTSTATUS Status;
+
+ TRACE("(%p %p)\n",
+ AliasObject, MemberId);
+
+ ConvertSidToStringSidW(MemberId, &MemberIdString);
+ TRACE("Member SID: %S\n", MemberIdString);
+
+ MemberIdLength = RtlLengthSid(MemberId);
+
+ Status = SampRegCreateKey(AliasObject->KeyHandle,
+ L"Members",
+ KEY_WRITE,
+ &MembersKeyHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampRegCreateKey failed with status 0x%08lx\n", Status);
+ goto done;
+ }
+
+ Status = SampRegSetValue(MembersKeyHandle,
+ MemberIdString,
+ REG_BINARY,
+ MemberId,
+ MemberIdLength);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampRegSetValue failed with status 0x%08lx\n", Status);
+ goto done;
+ }
+
+ Status = SampRegCreateKey(AliasObject->MembersKeyHandle,
+ MemberIdString,
+ KEY_WRITE,
+ &MemberKeyHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampRegCreateKey failed with status 0x%08lx\n", Status);
+ goto done;
+ }
+
+ Status = SampRegSetValue(MemberKeyHandle,
+ AliasObject->Name,
+ REG_BINARY,
+ MemberId,
+ MemberIdLength);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampRegSetValue failed with status 0x%08lx\n", Status);
+ goto done;
+ }
+
+done:
+ if (MemberKeyHandle != NULL)
+ SampRegCloseKey(MemberKeyHandle);
+
+ if (MembersKeyHandle != NULL)
+ SampRegCloseKey(MembersKeyHandle);
+
+ if (MemberIdString != NULL)
+ LocalFree(MemberIdString);
+
+ return Status;
+}
+
+
+NTSTATUS
+NTAPI
+SampRemoveMemberFromAlias(IN PSAM_DB_OBJECT AliasObject,
+ IN PRPC_SID MemberId)
+{
+ LPWSTR MemberIdString = NULL;
+ HANDLE MembersKeyHandle = NULL;
+ HANDLE MemberKeyHandle = NULL;
+ ULONG ulValueCount;
+ NTSTATUS Status;
+
+ TRACE("(%p %p)\n",
+ AliasObject, MemberId);
+
+ ConvertSidToStringSidW(MemberId, &MemberIdString);
+ TRACE("Member SID: %S\n", MemberIdString);
+
+ Status = SampRegOpenKey(AliasObject->MembersKeyHandle,
+ MemberIdString,
+ KEY_WRITE | KEY_QUERY_VALUE,
+ &MemberKeyHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampRegOpenKey failed with status 0x%08lx\n", Status);
+ goto done;
+ }
+
+ Status = SampRegDeleteValue(MemberKeyHandle,
+ AliasObject->Name);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampRegDeleteValue failed with status 0x%08lx\n", Status);
+ goto done;
+ }
+
+ Status = SampRegQueryKeyInfo(MemberKeyHandle,
+ NULL,
+ &ulValueCount);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampRegQueryKeyInfo failed with status 0x%08lx\n", Status);
+ goto done;
+ }
+
+ if (ulValueCount == 0)
+ {
+ SampRegCloseKey(MemberKeyHandle);
+ MemberKeyHandle = NULL;
+
+ Status = SampRegDeleteKey(AliasObject->MembersKeyHandle,
+ MemberIdString);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampRegDeleteKey failed with status 0x%08lx\n", Status);
+ goto done;
+ }
+ }
+
+ Status = SampRegOpenKey(AliasObject->KeyHandle,
+ L"Members",
+ KEY_WRITE | KEY_QUERY_VALUE,
+ &MembersKeyHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampRegOpenKey failed with status 0x%08lx\n", Status);
+ goto done;
+ }
+
+ Status = SampRegDeleteValue(MembersKeyHandle,
+ MemberIdString);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampRegDeleteValue failed with status 0x%08lx\n", Status);
+ goto done;
+ }
+
+ Status = SampRegQueryKeyInfo(MembersKeyHandle,
+ NULL,
+ &ulValueCount);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampRegQueryKeyInfo failed with status 0x%08lx\n", Status);
+ goto done;
+ }
+
+ if (ulValueCount == 0)
+ {
+ SampRegCloseKey(MembersKeyHandle);
+ MembersKeyHandle = NULL;
+
+ Status = SampRegDeleteKey(AliasObject->KeyHandle,
+ L"Members");
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampRegDeleteKey failed with status 0x%08lx\n", Status);
+ goto done;
+ }
+ }
+
+done:
+ if (MemberKeyHandle != NULL)
+ SampRegCloseKey(MemberKeyHandle);
+
+ if (MembersKeyHandle != NULL)
+ SampRegCloseKey(MembersKeyHandle);
+
+ if (MemberIdString != NULL)
+ LocalFree(MemberIdString);
+
+ return Status;
+}
+
/* EOF */
Modified: trunk/reactos/dll/win32/samsrv/samrpc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samsrv/samrpc.c?…
==============================================================================
--- trunk/reactos/dll/win32/samsrv/samrpc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/samsrv/samrpc.c [iso-8859-1] Thu May 23 09:42:25 2013
@@ -4669,7 +4669,7 @@
&AliasObject);
if (!NT_SUCCESS(Status))
{
- TRACE("failed with status 0x%08lx\n", Status);
+ TRACE("SampValidateDbObject failed (Status 0x%08lx)\n", Status);
return Status;
}
@@ -4704,14 +4704,9 @@
IN PRPC_SID MemberId)
{
PSAM_DB_OBJECT AliasObject;
- LPWSTR MemberIdString = NULL;
- HANDLE MembersKeyHandle = NULL;
- HANDLE MemberKeyHandle = NULL;
- ULONG MemberIdLength;
- NTSTATUS Status;
-
- TRACE("SamrAddMemberToAlias(%p %p)\n",
- AliasHandle, MemberId);
+ NTSTATUS Status;
+
+ TRACE("(%p %p)\n", AliasHandle, MemberId);
/* Validate the alias handle */
Status = SampValidateDbObject(AliasHandle,
@@ -4724,62 +4719,12 @@
return Status;
}
- ConvertSidToStringSidW(MemberId, &MemberIdString);
- TRACE("Member SID: %S\n", MemberIdString);
-
- MemberIdLength = RtlLengthSid(MemberId);
-
- Status = SampRegCreateKey(AliasObject->KeyHandle,
- L"Members",
- KEY_WRITE,
- &MembersKeyHandle);
- if (!NT_SUCCESS(Status))
- {
- TRACE("SampRegCreateKey failed with status 0x%08lx\n", Status);
- goto done;
- }
-
- Status = SampRegSetValue(MembersKeyHandle,
- MemberIdString,
- REG_BINARY,
- MemberId,
- MemberIdLength);
- if (!NT_SUCCESS(Status))
- {
- TRACE("SampRegSetValue failed with status 0x%08lx\n", Status);
- goto done;
- }
-
- Status = SampRegCreateKey(AliasObject->MembersKeyHandle,
- MemberIdString,
- KEY_WRITE,
- &MemberKeyHandle);
- if (!NT_SUCCESS(Status))
- {
- TRACE("SampRegCreateKey failed with status 0x%08lx\n", Status);
- goto done;
- }
-
- Status = SampRegSetValue(MemberKeyHandle,
- AliasObject->Name,
- REG_BINARY,
- MemberId,
- MemberIdLength);
- if (!NT_SUCCESS(Status))
- {
- TRACE("SampRegSetValue failed with status 0x%08lx\n", Status);
- goto done;
- }
-
-done:
- if (MemberKeyHandle != NULL)
- SampRegCloseKey(MemberKeyHandle);
-
- if (MembersKeyHandle != NULL)
- SampRegCloseKey(MembersKeyHandle);
-
- if (MemberIdString != NULL)
- LocalFree(MemberIdString);
+ Status = SampAddMemberToAlias(AliasObject,
+ MemberId);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("failed with status 0x%08lx\n", Status);
+ }
return Status;
}
@@ -4792,14 +4737,9 @@
IN PRPC_SID MemberId)
{
PSAM_DB_OBJECT AliasObject;
- LPWSTR MemberIdString = NULL;
- HANDLE MembersKeyHandle = NULL;
- HANDLE MemberKeyHandle = NULL;
- ULONG ulValueCount;
- NTSTATUS Status;
-
- TRACE("SamrRemoveMemberFromAlias(%p %p)\n",
- AliasHandle, MemberId);
+ NTSTATUS Status;
+
+ TRACE("(%p %p)\n", AliasHandle, MemberId);
/* Validate the alias handle */
Status = SampValidateDbObject(AliasHandle,
@@ -4812,100 +4752,12 @@
return Status;
}
- ConvertSidToStringSidW(MemberId, &MemberIdString);
- TRACE("Member SID: %S\n", MemberIdString);
-
- Status = SampRegOpenKey(AliasObject->MembersKeyHandle,
- MemberIdString,
- KEY_WRITE | KEY_QUERY_VALUE,
- &MemberKeyHandle);
- if (!NT_SUCCESS(Status))
- {
- TRACE("SampRegOpenKey failed with status 0x%08lx\n", Status);
- goto done;
- }
-
- Status = SampRegDeleteValue(MemberKeyHandle,
- AliasObject->Name);
- if (!NT_SUCCESS(Status))
- {
- TRACE("SampRegDeleteValue failed with status 0x%08lx\n", Status);
- goto done;
- }
-
- Status = SampRegQueryKeyInfo(MemberKeyHandle,
- NULL,
- &ulValueCount);
- if (!NT_SUCCESS(Status))
- {
- TRACE("SampRegQueryKeyInfo failed with status 0x%08lx\n", Status);
- goto done;
- }
-
- if (ulValueCount == 0)
- {
- SampRegCloseKey(MemberKeyHandle);
- MemberKeyHandle = NULL;
-
- Status = SampRegDeleteKey(AliasObject->MembersKeyHandle,
- MemberIdString);
- if (!NT_SUCCESS(Status))
- {
- TRACE("SampRegDeleteKey failed with status 0x%08lx\n", Status);
- goto done;
- }
- }
-
- Status = SampRegOpenKey(AliasObject->KeyHandle,
- L"Members",
- KEY_WRITE | KEY_QUERY_VALUE,
- &MembersKeyHandle);
- if (!NT_SUCCESS(Status))
- {
- TRACE("SampRegOpenKey failed with status 0x%08lx\n", Status);
- goto done;
- }
-
- Status = SampRegDeleteValue(MembersKeyHandle,
- MemberIdString);
- if (!NT_SUCCESS(Status))
- {
- TRACE("SampRegDeleteValue failed with status 0x%08lx\n", Status);
- goto done;
- }
-
- Status = SampRegQueryKeyInfo(MembersKeyHandle,
- NULL,
- &ulValueCount);
- if (!NT_SUCCESS(Status))
- {
- TRACE("SampRegQueryKeyInfo failed with status 0x%08lx\n", Status);
- goto done;
- }
-
- if (ulValueCount == 0)
- {
- SampRegCloseKey(MembersKeyHandle);
- MembersKeyHandle = NULL;
-
- Status = SampRegDeleteKey(AliasObject->KeyHandle,
- L"Members");
- if (!NT_SUCCESS(Status))
- {
- TRACE("SampRegDeleteKey failed with status 0x%08lx\n", Status);
- goto done;
- }
- }
-
-done:
- if (MemberKeyHandle != NULL)
- SampRegCloseKey(MemberKeyHandle);
-
- if (MembersKeyHandle != NULL)
- SampRegCloseKey(MembersKeyHandle);
-
- if (MemberIdString != NULL)
- LocalFree(MemberIdString);
+ Status = SampRemoveMemberFromAlias(AliasObject,
+ MemberId);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("failed with status 0x%08lx\n", Status);
+ }
return Status;
}
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] Thu May 23 09:42:25 2013
@@ -128,6 +128,15 @@
IN ACCESS_MASK DesiredAccess,
OUT PSAM_DB_OBJECT *AliasObject);
+NTSTATUS
+SampAddMemberToAlias(IN PSAM_DB_OBJECT AliasObject,
+ IN PRPC_SID MemberId);
+
+NTSTATUS
+NTAPI
+SampRemoveMemberFromAlias(IN PSAM_DB_OBJECT AliasObject,
+ IN PRPC_SID MemberId);
+
/* database.c */