Author: ekohl
Date: Tue Mar 12 20:07:56 2013
New Revision: 58476
URL:
http://svn.reactos.org/svn/reactos?rev=58476&view=rev
Log:
[SAMSRV]
Add helper functions SampOpenAliasObject, SampOpenGroupObject and
SampRemoveUserFromAllGroups.
Added:
trunk/reactos/dll/win32/samsrv/alias.c (with props)
Modified:
trunk/reactos/dll/win32/samsrv/CMakeLists.txt
trunk/reactos/dll/win32/samsrv/group.c
trunk/reactos/dll/win32/samsrv/samsrv.h
trunk/reactos/dll/win32/samsrv/user.c
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] Tue Mar 12 20:07:56 2013
@@ -8,6 +8,7 @@
spec2def(samsrv.dll samsrv.spec ADD_IMPORTLIB)
list(APPEND SOURCE
+ alias.c
database.c
domain.c
group.c
Added: 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 (added)
+++ trunk/reactos/dll/win32/samsrv/alias.c [iso-8859-1] Tue Mar 12 20:07:56 2013
@@ -1,0 +1,42 @@
+/*
+ * PROJECT: Local Security Authority Server DLL
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: dll/win32/samsrv/alias.c
+ * PURPOSE: Alias specific helper functions
+ * COPYRIGHT: Copyright 2013 Eric Kohl
+ */
+
+/* INCLUDES ****************************************************************/
+
+#include "samsrv.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(samsrv);
+
+
+/* FUNCTIONS ***************************************************************/
+
+NTSTATUS
+SampOpenAliasObject(IN PSAM_DB_OBJECT DomainObject,
+ IN ULONG AliasId,
+ IN ACCESS_MASK DesiredAccess,
+ OUT PSAM_DB_OBJECT *AliasObject)
+{
+ WCHAR szRid[9];
+
+ TRACE("(%p %lu %lx %p)\n",
+ DomainObject, AliasId, DesiredAccess, AliasObject);
+
+ /* Convert the RID into a string (hex) */
+ swprintf(szRid, L"%08lX", AliasId);
+
+ /* Create the user object */
+ return SampOpenDbObject(DomainObject,
+ L"Aliases",
+ szRid,
+ AliasId,
+ SamDbAliasObject,
+ DesiredAccess,
+ AliasObject);
+}
+
+/* EOF */
Propchange: trunk/reactos/dll/win32/samsrv/alias.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/reactos/dll/win32/samsrv/alias.c
------------------------------------------------------------------------------
svn:keywords = author date id revision
Modified: trunk/reactos/dll/win32/samsrv/group.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samsrv/group.c?r…
==============================================================================
--- trunk/reactos/dll/win32/samsrv/group.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/samsrv/group.c [iso-8859-1] Tue Mar 12 20:07:56 2013
@@ -14,6 +14,30 @@
/* FUNCTIONS ***************************************************************/
+
+NTSTATUS
+SampOpenGroupObject(IN PSAM_DB_OBJECT DomainObject,
+ IN ULONG GroupId,
+ IN ACCESS_MASK DesiredAccess,
+ OUT PSAM_DB_OBJECT *GroupObject)
+{
+ WCHAR szRid[9];
+
+ TRACE("(%p %lu %lx %p)\n",
+ DomainObject, GroupId, DesiredAccess, GroupObject);
+
+ /* Convert the RID into a string (hex) */
+ swprintf(szRid, L"%08lX", GroupId);
+
+ /* Create the user object */
+ return SampOpenDbObject(DomainObject,
+ L"Groups",
+ szRid,
+ GroupId,
+ SamDbGroupObject,
+ DesiredAccess,
+ GroupObject);
+}
NTSTATUS
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] Tue Mar 12 20:07:56 2013
@@ -117,6 +117,15 @@
extern PGENERIC_MAPPING pServerMapping;
+/* alias.c */
+
+NTSTATUS
+SampOpenAliasObject(IN PSAM_DB_OBJECT DomainObject,
+ IN ULONG AliasId,
+ IN ACCESS_MASK DesiredAccess,
+ OUT PSAM_DB_OBJECT *AliasObject);
+
+
/* database.c */
NTSTATUS
@@ -193,6 +202,12 @@
/* group.h */
NTSTATUS
+SampOpenGroupObject(IN PSAM_DB_OBJECT DomainObject,
+ IN ULONG GroupId,
+ IN ACCESS_MASK DesiredAccess,
+ OUT PSAM_DB_OBJECT *GroupObject);
+
+NTSTATUS
SampAddMemberToGroup(IN PSAM_DB_OBJECT GroupObject,
IN ULONG MemberId);
@@ -302,6 +317,9 @@
IN ULONG GroupAttributes);
NTSTATUS
+SampRemoveUserFromAllGroups(IN PSAM_DB_OBJECT UserObject);
+
+NTSTATUS
SampSetUserPassword(IN PSAM_DB_OBJECT UserObject,
IN PENCRYPTED_NT_OWF_PASSWORD NtPassword,
IN BOOLEAN NtPasswordPresent,
Modified: trunk/reactos/dll/win32/samsrv/user.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samsrv/user.c?re…
==============================================================================
--- trunk/reactos/dll/win32/samsrv/user.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/samsrv/user.c [iso-8859-1] Tue Mar 12 20:07:56 2013
@@ -321,6 +321,69 @@
NTSTATUS
+SampRemoveUserFromAllGroups(IN PSAM_DB_OBJECT UserObject)
+{
+ PGROUP_MEMBERSHIP GroupsBuffer = NULL;
+ PSAM_DB_OBJECT GroupObject;
+ ULONG Length = 0;
+ ULONG i;
+ NTSTATUS Status;
+
+ SampGetObjectAttribute(UserObject,
+ L"Groups",
+ NULL,
+ NULL,
+ &Length);
+
+ if (Length == 0)
+ return STATUS_SUCCESS;
+
+ GroupsBuffer = midl_user_allocate(Length);
+ if (GroupsBuffer == NULL)
+ {
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ goto done;
+ }
+
+ Status = SampGetObjectAttribute(UserObject,
+ L"Groups",
+ NULL,
+ GroupsBuffer,
+ &Length);
+ if (!NT_SUCCESS(Status))
+ goto done;
+
+ for (i = 0; i < (Length / sizeof(GROUP_MEMBERSHIP)); i++)
+ {
+ Status = SampOpenGroupObject(UserObject->ParentObject,
+ GroupsBuffer[i].RelativeId,
+ 0,
+ &GroupObject);
+ if (!NT_SUCCESS(Status))
+ {
+ goto done;
+ }
+
+ Status = SampRemoveMemberFromGroup(GroupObject,
+ UserObject->RelativeId);
+
+ SampCloseDbObject(GroupObject);
+
+ if (!NT_SUCCESS(Status))
+ {
+ goto done;
+ }
+ }
+
+done:
+ if (GroupsBuffer != NULL)
+ midl_user_free(GroupsBuffer);
+
+ return Status;
+}
+
+
+NTSTATUS
SampSetUserPassword(IN PSAM_DB_OBJECT UserObject,
IN PENCRYPTED_NT_OWF_PASSWORD NtPassword,
IN BOOLEAN NtPasswordPresent,