mirror of
https://github.com/reactos/reactos.git
synced 2024-12-31 19:42:51 +00:00
[SAMLIB]
- Implement SamDeleteAlias, SamDeleteGroup, SamGetGroupsForUser, SamGetMembersInGroup, SamQuerySecurityObject, SamSetMemberAttributesOfGroup and SamSetSecurityObject. - Add stub for SamRidToSid. svn path=/trunk/; revision=57590
This commit is contained in:
parent
5563b4393e
commit
b3643a80d5
4 changed files with 339 additions and 8 deletions
|
@ -380,6 +380,62 @@ SamCreateUserInDomain(IN SAM_HANDLE DomainHandle,
|
|||
}
|
||||
|
||||
|
||||
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)
|
||||
|
@ -665,6 +721,50 @@ SamGetAliasMembership(IN SAM_HANDLE DomainHandle,
|
|||
}
|
||||
|
||||
|
||||
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,
|
||||
|
@ -707,6 +807,55 @@ SamGetMembersInAlias(IN SAM_HANDLE AliasHandle,
|
|||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
Status = I_RpcMapWin32Status(RpcExceptionCode());
|
||||
}
|
||||
RpcEndExcept;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
SamLookupDomainInSamServer(IN SAM_HANDLE ServerHandle,
|
||||
|
@ -1145,6 +1294,53 @@ SamQueryInformationUser(IN SAM_HANDLE UserHandle,
|
|||
}
|
||||
|
||||
|
||||
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,
|
||||
|
@ -1253,6 +1449,88 @@ SamSetInformationUser(IN SAM_HANDLE UserHandle,
|
|||
}
|
||||
|
||||
|
||||
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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -271,6 +271,12 @@ typedef enum _GROUP_INFORMATION_CLASS
|
|||
GroupReplicationInformation
|
||||
} GROUP_INFORMATION_CLASS;
|
||||
|
||||
typedef struct _GROUP_MEMBERSHIP
|
||||
{
|
||||
ULONG RelativeId;
|
||||
ULONG Attributes;
|
||||
} GROUP_MEMBERSHIP, *PGROUP_MEMBERSHIP;
|
||||
|
||||
typedef enum _USER_INFORMATION_CLASS
|
||||
{
|
||||
UserGeneralInformation = 1,
|
||||
|
@ -373,6 +379,14 @@ SamCreateUserInDomain(IN SAM_HANDLE DomainHandle,
|
|||
OUT PSAM_HANDLE UserHandle,
|
||||
OUT PULONG RelativeId);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
SamDeleteAlias(IN SAM_HANDLE AliasHandle);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
SamDeleteGroup(IN SAM_HANDLE GroupHandle);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
SamDeleteUser(IN SAM_HANDLE UserHandle);
|
||||
|
@ -422,12 +436,25 @@ SamGetAliasMembership(IN SAM_HANDLE DomainHandle,
|
|||
OUT PULONG MembershipCount,
|
||||
OUT PULONG *Aliases);
|
||||
|
||||
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
|
||||
NTAPI
|
||||
SamLookupDomainInSamServer(IN SAM_HANDLE ServerHandle,
|
||||
|
@ -502,11 +529,23 @@ SamQueryInformationUser(IN SAM_HANDLE UserHandle,
|
|||
IN USER_INFORMATION_CLASS UserInformationClass,
|
||||
OUT PVOID *Buffer);
|
||||
|
||||
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
|
||||
SamSetInformationAlias(IN SAM_HANDLE AliasHandle,
|
||||
|
@ -531,6 +570,18 @@ SamSetInformationUser(IN SAM_HANDLE UserHandle,
|
|||
IN USER_INFORMATION_CLASS UserInformationClass,
|
||||
IN PVOID Buffer);
|
||||
|
||||
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);
|
||||
|
|
|
@ -99,11 +99,13 @@ typedef struct _SAMPR_SR_SECURITY_DESCRIPTOR
|
|||
[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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue