Author: ekohl
Date: Sun Oct 21 17:51:36 2012
New Revision: 57590
URL:
http://svn.reactos.org/svn/reactos?rev=57590&view=rev
Log:
[SAMLIB]
- Implement SamDeleteAlias, SamDeleteGroup, SamGetGroupsForUser, SamGetMembersInGroup,
SamQuerySecurityObject, SamSetMemberAttributesOfGroup and SamSetSecurityObject.
- Add stub for SamRidToSid.
Modified:
trunk/reactos/dll/win32/samlib/samlib.c
trunk/reactos/dll/win32/samlib/samlib.spec
trunk/reactos/include/ddk/ntsam.h
trunk/reactos/include/reactos/idl/sam.idl
Modified: trunk/reactos/dll/win32/samlib/samlib.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samlib/samlib.c?…
==============================================================================
--- trunk/reactos/dll/win32/samlib/samlib.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/samlib/samlib.c [iso-8859-1] Sun Oct 21 17:51:36 2012
@@ -382,6 +382,62 @@
NTSTATUS
NTAPI
+SamDeleteAlias(IN SAM_HANDLE AliasHandle)
+{
+ SAMPR_HANDLE LocalAliasHandle;
+ NTSTATUS Status;
+
+ TRACE("SamDeleteAlias(%p)\n", AliasHandle);
+
+ LocalAliasHandle = (SAMPR_HANDLE)AliasHandle;
+
+ if (LocalAliasHandle == NULL)
+ return STATUS_INVALID_HANDLE;
+
+ RpcTryExcept
+ {
+ Status = SamrDeleteAlias(&LocalAliasHandle);
+ }
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = I_RpcMapWin32Status(RpcExceptionCode());
+ }
+ RpcEndExcept;
+
+ return Status;
+}
+
+
+NTSTATUS
+NTAPI
+SamDeleteGroup(IN SAM_HANDLE GroupHandle)
+{
+ SAMPR_HANDLE LocalGroupHandle;
+ NTSTATUS Status;
+
+ TRACE("SamDeleteGroup(%p)\n", GroupHandle);
+
+ LocalGroupHandle = (SAMPR_HANDLE)GroupHandle;
+
+ if (LocalGroupHandle == NULL)
+ return STATUS_INVALID_HANDLE;
+
+ RpcTryExcept
+ {
+ Status = SamrDeleteGroup(&LocalGroupHandle);
+ }
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = I_RpcMapWin32Status(RpcExceptionCode());
+ }
+ RpcEndExcept;
+
+ return Status;
+}
+
+
+NTSTATUS
+NTAPI
SamDeleteUser(IN SAM_HANDLE UserHandle)
{
SAMPR_HANDLE LocalUserHandle;
@@ -667,6 +723,50 @@
NTSTATUS
NTAPI
+SamGetGroupsForUser(IN SAM_HANDLE UserHandle,
+ OUT PGROUP_MEMBERSHIP *Groups,
+ OUT PULONG MembershipCount)
+{
+ PSAMPR_GET_GROUPS_BUFFER GroupsBuffer = NULL;
+ NTSTATUS Status;
+
+ TRACE("SamGetGroupsForUser(%p %p %p)\n",
+ UserHandle, Groups, MembershipCount);
+
+ RpcTryExcept
+ {
+ Status = SamrGetGroupsForUser((SAMPR_HANDLE)UserHandle,
+ &GroupsBuffer);
+ if (NT_SUCCESS(Status))
+ {
+ *Groups = GroupsBuffer->Groups;
+ *MembershipCount = GroupsBuffer->MembershipCount;
+
+ MIDL_user_free(GroupsBuffer);
+ }
+ else
+ {
+ if (GroupsBuffer != NULL)
+ {
+ if (GroupsBuffer->Groups != NULL)
+ MIDL_user_free(GroupsBuffer->Groups);
+
+ MIDL_user_free(GroupsBuffer);
+ }
+ }
+ }
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = I_RpcMapWin32Status(RpcExceptionCode());
+ }
+ RpcEndExcept;
+
+ return Status;
+}
+
+
+NTSTATUS
+NTAPI
SamGetMembersInAlias(IN SAM_HANDLE AliasHandle,
OUT PSID **MemberIds,
OUT PULONG MemberCount)
@@ -696,6 +796,55 @@
*MemberIds = (PSID *)SidArray.Sids;
}
+ }
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = I_RpcMapWin32Status(RpcExceptionCode());
+ }
+ RpcEndExcept;
+
+ return Status;
+}
+
+
+NTSTATUS
+NTAPI
+SamGetMembersInGroup(IN SAM_HANDLE GroupHandle,
+ OUT PULONG *MemberIds,
+ OUT PULONG *Attributes,
+ OUT PULONG MemberCount)
+{
+ PSAMPR_GET_MEMBERS_BUFFER MembersBuffer = NULL;
+ NTSTATUS Status;
+
+ TRACE("SamGetMembersInGroup(%p %p %p %p)\n",
+ GroupHandle, MemberIds, Attributes, MemberCount);
+
+ RpcTryExcept
+ {
+ Status = SamrGetMembersInGroup((SAMPR_HANDLE)GroupHandle,
+ &MembersBuffer);
+ if (NT_SUCCESS(Status))
+ {
+ *MemberIds = MembersBuffer->Members;
+ *Attributes = MembersBuffer->Attributes;
+ *MemberCount = MembersBuffer->MemberCount;
+
+ MIDL_user_free(MembersBuffer);
+ }
+ else
+ {
+ if (MembersBuffer != NULL)
+ {
+ if (MembersBuffer->Members != NULL)
+ MIDL_user_free(MembersBuffer->Members);
+
+ if (MembersBuffer->Attributes != NULL)
+ MIDL_user_free(MembersBuffer->Attributes);
+
+ MIDL_user_free(MembersBuffer);
+ }
+ }
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
@@ -1147,6 +1296,53 @@
NTSTATUS
NTAPI
+SamQuerySecurityObject(IN SAM_HANDLE ObjectHandle,
+ IN SECURITY_INFORMATION SecurityInformation,
+ OUT PSECURITY_DESCRIPTOR *SecurityDescriptor)
+{
+ SAMPR_SR_SECURITY_DESCRIPTOR LocalSecurityDescriptor;
+ PSAMPR_SR_SECURITY_DESCRIPTOR pLocalSecurityDescriptor;
+ NTSTATUS Status;
+
+ TRACE("SamQuerySecurityObject(%p %lu %p)\n",
+ ObjectHandle, SecurityInformation, SecurityDescriptor);
+
+ LocalSecurityDescriptor.Length = 0;
+ LocalSecurityDescriptor.SecurityDescriptor = NULL;
+
+ RpcTryExcept
+ {
+ pLocalSecurityDescriptor = &LocalSecurityDescriptor;
+
+ Status = SamrQuerySecurityObject((SAMPR_HANDLE)ObjectHandle,
+ SecurityInformation,
+ &pLocalSecurityDescriptor);
+ }
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = I_RpcMapWin32Status(RpcExceptionCode());
+ }
+ RpcEndExcept;
+
+ *SecurityDescriptor = LocalSecurityDescriptor.SecurityDescriptor;
+
+ return Status;
+}
+
+
+NTSTATUS
+NTAPI
+SamRidToSid(IN SAM_HANDLE ObjectHandle,
+ IN ULONG Rid,
+ OUT PSID *Sid)
+{
+ UNIMPLEMENTED;
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+
+NTSTATUS
+NTAPI
SamSetInformationAlias(IN SAM_HANDLE AliasHandle,
IN ALIAS_INFORMATION_CLASS AliasInformationClass,
IN PVOID Buffer)
@@ -1255,6 +1451,88 @@
NTSTATUS
NTAPI
+SamSetMemberAttributesOfGroup(IN SAM_HANDLE GroupHandle,
+ IN ULONG MemberId,
+ IN ULONG Attributes)
+{
+ NTSTATUS Status;
+
+ TRACE("SamSetMemberAttributesOfGroup(%p %lu 0x%lx)\n",
+ GroupHandle, MemberId, Attributes);
+
+ RpcTryExcept
+ {
+ Status = SamrSetMemberAttributesOfGroup((SAMPR_HANDLE)GroupHandle,
+ MemberId,
+ Attributes);
+ }
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = I_RpcMapWin32Status(RpcExceptionCode());
+ }
+ RpcEndExcept;
+
+ return Status;
+}
+
+
+NTSTATUS
+NTAPI
+SamSetSecurityObject(IN SAM_HANDLE ObjectHandle,
+ IN SECURITY_INFORMATION SecurityInformation,
+ IN PSECURITY_DESCRIPTOR SecurityDescriptor)
+{
+ SAMPR_SR_SECURITY_DESCRIPTOR DescriptorToPass;
+ ULONG Length;
+ NTSTATUS Status;
+
+ TRACE("SamSetSecurityObject(%p %lu %p)\n",
+ ObjectHandle, SecurityInformation, SecurityDescriptor);
+
+ /* Retrieve the length of the relative security descriptor */
+ Length = 0;
+ Status = RtlMakeSelfRelativeSD(SecurityDescriptor,
+ NULL,
+ &Length);
+ if (Status != STATUS_BUFFER_TOO_SMALL)
+ return STATUS_INVALID_PARAMETER;
+
+
+ /* Allocate a buffer for the security descriptor */
+ DescriptorToPass.Length = Length;
+ DescriptorToPass.SecurityDescriptor = MIDL_user_allocate(Length);
+ if (DescriptorToPass.SecurityDescriptor == NULL)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ /* Convert the given security descriptor to a relative security descriptor */
+ Status = RtlMakeSelfRelativeSD(SecurityDescriptor,
+
(PSECURITY_DESCRIPTOR)DescriptorToPass.SecurityDescriptor,
+ &Length);
+ if (!NT_SUCCESS(Status))
+ goto done;
+
+ RpcTryExcept
+ {
+ Status = SamrSetSecurityObject((SAMPR_HANDLE)ObjectHandle,
+ SecurityInformation,
+ &DescriptorToPass);
+ }
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = I_RpcMapWin32Status(RpcExceptionCode());
+ }
+ RpcEndExcept;
+
+done:
+ if (DescriptorToPass.SecurityDescriptor != NULL)
+ MIDL_user_free(DescriptorToPass.SecurityDescriptor);
+
+ return Status;
+}
+
+
+NTSTATUS
+NTAPI
SamShutdownSamServer(IN SAM_HANDLE ServerHandle)
{
UNIMPLEMENTED;
Modified: trunk/reactos/dll/win32/samlib/samlib.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samlib/samlib.sp…
==============================================================================
--- trunk/reactos/dll/win32/samlib/samlib.spec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/samlib/samlib.spec [iso-8859-1] Sun Oct 21 17:51:36 2012
@@ -11,8 +11,8 @@
@ stdcall SamCreateGroupInDomain(ptr ptr long ptr ptr)
@ stdcall SamCreateUser2InDomain(ptr ptr long long ptr ptr ptr)
@ stdcall SamCreateUserInDomain(ptr ptr long ptr ptr)
-@ stub SamDeleteAlias
-@ stub SamDeleteGroup
+@ stdcall SamDeleteAlias(ptr)
+@ stdcall SamDeleteGroup(ptr)
@ stdcall SamDeleteUser(ptr)
@ stdcall SamEnumerateAliasesInDomain(ptr ptr ptr long ptr)
@ stdcall SamEnumerateDomainsInSamServer(ptr ptr ptr long ptr)
@@ -22,9 +22,9 @@
@ stdcall SamGetAliasMembership(ptr long ptr ptr ptr)
@ stub SamGetCompatibilityMode
@ stub SamGetDisplayEnumerationIndex
-@ stub SamGetGroupsForUser
+@ stdcall SamGetGroupsForUser(ptr ptr ptr)
@ stdcall SamGetMembersInAlias(ptr ptr ptr)
-@ stub SamGetMembersInGroup
+@ stdcall SamGetMembersInGroup(ptr ptr ptr ptr)
@ stdcall SamLookupDomainInSamServer(ptr ptr ptr)
@ stdcall SamLookupIdsInDomain(ptr long ptr ptr ptr)
@ stdcall SamLookupNamesInDomain(ptr long ptr ptr ptr)
@@ -37,18 +37,18 @@
@ stdcall SamQueryInformationDomain(ptr long ptr)
@ stdcall SamQueryInformationGroup(ptr long ptr)
@ stdcall SamQueryInformationUser(ptr long ptr)
-@ stub SamQuerySecurityObject
+@ stdcall SamQuerySecurityObject(ptr long ptr)
@ stub SamRemoveMemberFromAlias
@ stub SamRemoveMemberFromForeignDomain
@ stub SamRemoveMemberFromGroup
@ stub SamRemoveMultipleMembersFromAlias
-@ stub SamRidToSid
+@ stdcall SamRidToSid(ptr long ptr)
@ stdcall SamSetInformationAlias(ptr long ptr)
@ stdcall SamSetInformationDomain(ptr long ptr)
@ stdcall SamSetInformationGroup(ptr long ptr)
@ stdcall SamSetInformationUser(ptr long ptr)
-@ stub SamSetMemberAttributesOfGroup
-@ stub SamSetSecurityObject
+@ stdcall SamSetMemberAttributesOfGroup(ptr long long)
+@ stdcall SamSetSecurityObject(ptr long ptr)
@ stdcall SamShutdownSamServer(ptr)
@ stub SamTestPrivateFunctionsDomain
@ stub SamTestPrivateFunctionsUser
Modified: trunk/reactos/include/ddk/ntsam.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/ntsam.h?rev=57…
==============================================================================
--- trunk/reactos/include/ddk/ntsam.h [iso-8859-1] (original)
+++ trunk/reactos/include/ddk/ntsam.h [iso-8859-1] Sun Oct 21 17:51:36 2012
@@ -270,6 +270,12 @@
GroupAdminCommentInformation,
GroupReplicationInformation
} GROUP_INFORMATION_CLASS;
+
+typedef struct _GROUP_MEMBERSHIP
+{
+ ULONG RelativeId;
+ ULONG Attributes;
+} GROUP_MEMBERSHIP, *PGROUP_MEMBERSHIP;
typedef enum _USER_INFORMATION_CLASS
{
@@ -375,6 +381,14 @@
NTSTATUS
NTAPI
+SamDeleteAlias(IN SAM_HANDLE AliasHandle);
+
+NTSTATUS
+NTAPI
+SamDeleteGroup(IN SAM_HANDLE GroupHandle);
+
+NTSTATUS
+NTAPI
SamDeleteUser(IN SAM_HANDLE UserHandle);
NTSTATUS
@@ -424,8 +438,21 @@
NTSTATUS
NTAPI
+SamGetGroupsForUser(IN SAM_HANDLE UserHandle,
+ OUT PGROUP_MEMBERSHIP *Groups,
+ OUT PULONG MembershipCount);
+
+NTSTATUS
+NTAPI
SamGetMembersInAlias(IN SAM_HANDLE AliasHandle,
OUT PSID **MemberIds,
+ OUT PULONG MemberCount);
+
+NTSTATUS
+NTAPI
+SamGetMembersInGroup(IN SAM_HANDLE GroupHandle,
+ OUT PULONG *MemberIds,
+ OUT PULONG *Attributes,
OUT PULONG MemberCount);
NTSTATUS
@@ -504,8 +531,20 @@
NTSTATUS
NTAPI
+SamQuerySecurityObject(IN SAM_HANDLE ObjectHandle,
+ IN SECURITY_INFORMATION SecurityInformation,
+ OUT PSECURITY_DESCRIPTOR *SecurityDescriptor);
+
+NTSTATUS
+NTAPI
SamRemoveMemberFromAlias(IN SAM_HANDLE AliasHandle,
IN PSID MemberId);
+
+NTSTATUS
+NTAPI
+SamRidToSid(IN SAM_HANDLE ObjectHandle,
+ IN ULONG Rid,
+ OUT PSID *Sid);
NTSTATUS
NTAPI
@@ -533,6 +572,18 @@
NTSTATUS
NTAPI
+SamSetMemberAttributesOfGroup(IN SAM_HANDLE GroupHandle,
+ IN ULONG MemberId,
+ IN ULONG Attributes);
+
+NTSTATUS
+NTAPI
+SamSetSecurityObject(IN SAM_HANDLE ObjectHandle,
+ IN SECURITY_INFORMATION SecurityInformation,
+ IN PSECURITY_DESCRIPTOR SecurityDescriptor);
+
+NTSTATUS
+NTAPI
SamShutdownSamServer(IN SAM_HANDLE ServerHandle);
#ifdef __cplusplus
Modified: trunk/reactos/include/reactos/idl/sam.idl
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/idl/sam.id…
==============================================================================
--- trunk/reactos/include/reactos/idl/sam.idl [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/idl/sam.idl [iso-8859-1] Sun Oct 21 17:51:36 2012
@@ -99,11 +99,13 @@
[size_is(Length)] unsigned char* SecurityDescriptor;
} SAMPR_SR_SECURITY_DESCRIPTOR, *PSAMPR_SR_SECURITY_DESCRIPTOR;
+cpp_quote("#ifndef _NTSAM_")
typedef struct _GROUP_MEMBERSHIP
{
unsigned long RelativeId;
unsigned long Attributes;
} GROUP_MEMBERSHIP, *PGROUP_MEMBERSHIP;
+cpp_quote("#endif")
typedef struct _SAMPR_GET_GROUPS_BUFFER
{