if (User->User.Sid == NULL)
{
ERR("Could not create the user SID\n");
- return STATUS_UNSUCCESSFUL;
+ return STATUS_INSUFFICIENT_RESOURCES;
}
User->User.Attributes = 0;
static
NTSTATUS
-BuildTokenGroups(IN PSID AccountDomainSid,
- IN PLUID LogonId,
- OUT PTOKEN_GROUPS *Groups,
- OUT PSID *PrimaryGroupSid)
+BuildTokenPrimaryGroup(OUT PTOKEN_PRIMARY_GROUP PrimaryGroup,
+ IN PSID AccountDomainSid,
+ IN ULONG RelativeId)
+{
+ PrimaryGroup->PrimaryGroup = AppendRidToSid(AccountDomainSid,
+ RelativeId);
+ if (PrimaryGroup->PrimaryGroup == NULL)
+ {
+ ERR("Could not create the primary group SID\n");
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ return STATUS_SUCCESS;
+}
+
+
+static
+NTSTATUS
+BuildTokenGroups(OUT PTOKEN_GROUPS *Groups,
+ IN PSID AccountDomainSid)
{
SID_IDENTIFIER_AUTHORITY SystemAuthority = {SECURITY_NT_AUTHORITY};
PTOKEN_GROUPS TokenGroups;
TokenGroups->Groups[GroupCount].Sid = Sid;
TokenGroups->Groups[GroupCount].Attributes =
SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
- *PrimaryGroupSid = Sid;
GroupCount++;
}
-static
-NTSTATUS
-BuildTokenPrimaryGroup(PTOKEN_PRIMARY_GROUP PrimaryGroup,
- PSID PrimaryGroupSid)
-{
- ULONG RidCount;
- ULONG Size;
-
- RidCount = *RtlSubAuthorityCountSid(PrimaryGroupSid);
- Size = RtlLengthRequiredSid(RidCount);
-
- PrimaryGroup->PrimaryGroup = DispatchTable.AllocateLsaHeap(Size);
- if (PrimaryGroup->PrimaryGroup == NULL)
- {
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- RtlCopyMemory(PrimaryGroup->PrimaryGroup,
- PrimaryGroupSid,
- Size);
-
- return STATUS_SUCCESS;
-}
-
static
NTSTATUS
BuildTokenPrivileges(PTOKEN_PRIVILEGES *TokenPrivileges)
NTSTATUS
BuildTokenInformationBuffer(PLSA_TOKEN_INFORMATION_V1 *TokenInformation,
PRPC_SID AccountDomainSid,
- ULONG RelativeId,
- PLUID LogonId)
+ PSAMPR_USER_INFO_BUFFER UserInfo)
{
PLSA_TOKEN_INFORMATION_V1 Buffer = NULL;
- PSID PrimaryGroupSid = NULL;
ULONG i;
NTSTATUS Status = STATUS_SUCCESS;
Status = BuildTokenUser(&Buffer->User,
(PSID)AccountDomainSid,
- RelativeId);
+ UserInfo->All.UserId);
if (!NT_SUCCESS(Status))
goto done;
- Status = BuildTokenGroups((PSID)AccountDomainSid,
- LogonId,
- &Buffer->Groups,
- &PrimaryGroupSid);
+ Status = BuildTokenPrimaryGroup(&Buffer->PrimaryGroup,
+ (PSID)AccountDomainSid,
+ UserInfo->All.PrimaryGroupId);
if (!NT_SUCCESS(Status))
goto done;
- Status = BuildTokenPrimaryGroup(&Buffer->PrimaryGroup,
- PrimaryGroupSid);
+ Status = BuildTokenGroups(&Buffer->Groups,
+ (PSID)AccountDomainSid);
if (!NT_SUCCESS(Status))
goto done;
/* Build and fill the token information buffer */
Status = BuildTokenInformationBuffer((PLSA_TOKEN_INFORMATION_V1*)TokenInformation,
AccountDomainSid,
- RelativeIds.Element[0],
- LogonId);
+ UserInfo);
if (!NT_SUCCESS(Status))
{
TRACE("BuildTokenInformationBuffer failed (Status %08lx)\n", Status);