From 57f9b8f9abb201fbc392fdb0f8f3aa33632d4048 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Mon, 28 Jan 2013 23:18:10 +0000 Subject: [PATCH] [SAMSRV] Create user routines: - Set fixed user attribute explicitly. - Add missing Parameters attribute. - Add empty (zero-sized) password and password history attributes. svn path=/trunk/; revision=58250 --- reactos/dll/win32/samsrv/samrpc.c | 135 +++++++++++++++++++++++++++++- reactos/dll/win32/samsrv/setup.c | 53 +++++++++++- 2 files changed, 182 insertions(+), 6 deletions(-) diff --git a/reactos/dll/win32/samsrv/samrpc.c b/reactos/dll/win32/samsrv/samrpc.c index 687956620d5..f40d9b4c249 100644 --- a/reactos/dll/win32/samsrv/samrpc.c +++ b/reactos/dll/win32/samsrv/samrpc.c @@ -2165,6 +2165,7 @@ SamrCreateUserInDomain(IN SAMPR_HANDLE DomainHandle, /* Initialize fixed user data */ memset(&FixedUserData, 0, sizeof(SAM_USER_FIXED_DATA)); FixedUserData.Version = 1; + FixedUserData.Reserved = 0; FixedUserData.LastLogon.QuadPart = 0; FixedUserData.LastLogoff.QuadPart = 0; FixedUserData.PasswordLastSet.QuadPart = 0; @@ -2176,6 +2177,12 @@ SamrCreateUserInDomain(IN SAMPR_HANDLE DomainHandle, FixedUserData.UserAccountControl = USER_ACCOUNT_DISABLED | USER_PASSWORD_NOT_REQUIRED | USER_NORMAL_ACCOUNT; + FixedUserData.CountryCode = 0; + FixedUserData.CodePage = 0; + FixedUserData.BadPasswordCount = 0; + FixedUserData.LogonCount = 0; + FixedUserData.AdminCount = 0; + FixedUserData.OperatorCount = 0; /* Set fixed user data attribute */ Status = SampSetObjectAttribute(UserObject, @@ -2309,7 +2316,58 @@ SamrCreateUserInDomain(IN SAMPR_HANDLE DomainHandle, return Status; } - /* FIXME: Set default user attributes */ + /* FIXME: Set LogonHours attribute*/ + /* FIXME: Set Groups attribute*/ + + /* Set LMPwd attribute*/ + Status = SampSetObjectAttribute(UserObject, + L"LMPwd", + REG_BINARY, + NULL, + 0); + if (!NT_SUCCESS(Status)) + { + TRACE("failed with status 0x%08lx\n", Status); + return Status; + } + + /* Set NTPwd attribute*/ + Status = SampSetObjectAttribute(UserObject, + L"NTPwd", + REG_BINARY, + NULL, + 0); + if (!NT_SUCCESS(Status)) + { + TRACE("failed with status 0x%08lx\n", Status); + return Status; + } + + /* Set LMPwdHistory attribute*/ + Status = SampSetObjectAttribute(UserObject, + L"LMPwdHistory", + REG_BINARY, + NULL, + 0); + if (!NT_SUCCESS(Status)) + { + TRACE("failed with status 0x%08lx\n", Status); + return Status; + } + + /* Set NTPwdHistory attribute*/ + Status = SampSetObjectAttribute(UserObject, + L"NTPwdHistory", + REG_BINARY, + NULL, + 0); + if (!NT_SUCCESS(Status)) + { + TRACE("failed with status 0x%08lx\n", Status); + return Status; + } + + /* FIXME: Set SecDesc attribute*/ if (NT_SUCCESS(Status)) { @@ -6811,7 +6869,7 @@ SamrGetGroupsForUser(IN SAMPR_HANDLE UserHandle, TRACE("SamrGetGroupsForUser(%p %p)\n", UserHandle, Groups); - /* Validate the domain handle */ + /* Validate the user handle */ Status = SampValidateDbObject(UserHandle, SamDbUserObject, USER_LIST_GROUPS, @@ -7158,8 +7216,8 @@ SamrCreateUser2InDomain(IN SAMPR_HANDLE DomainHandle, } /* Initialize fixed user data */ - memset(&FixedUserData, 0, sizeof(SAM_USER_FIXED_DATA)); FixedUserData.Version = 1; + FixedUserData.Reserved = 0; FixedUserData.LastLogon.QuadPart = 0; FixedUserData.LastLogoff.QuadPart = 0; FixedUserData.PasswordLastSet.QuadPart = 0; @@ -7171,6 +7229,12 @@ SamrCreateUser2InDomain(IN SAMPR_HANDLE DomainHandle, FixedUserData.UserAccountControl = USER_ACCOUNT_DISABLED | USER_PASSWORD_NOT_REQUIRED | AccountType; + FixedUserData.CountryCode = 0; + FixedUserData.CodePage = 0; + FixedUserData.BadPasswordCount = 0; + FixedUserData.LogonCount = 0; + FixedUserData.AdminCount = 0; + FixedUserData.OperatorCount = 0; /* Set fixed user data attribute */ Status = SampSetObjectAttribute(UserObject, @@ -7292,7 +7356,70 @@ SamrCreateUser2InDomain(IN SAMPR_HANDLE DomainHandle, return Status; } - /* FIXME: Set default user attributes */ + /* Set the Parameters attribute */ + Status = SampSetObjectAttribute(UserObject, + L"Parameters", + REG_SZ, + EmptyString.Buffer, + EmptyString.MaximumLength); + if (!NT_SUCCESS(Status)) + { + TRACE("failed with status 0x%08lx\n", Status); + return Status; + } + + /* FIXME: Set LogonHours attribute*/ + /* FIXME: Set Groups attribute*/ + + /* Set LMPwd attribute*/ + Status = SampSetObjectAttribute(UserObject, + L"LMPwd", + REG_BINARY, + NULL, + 0); + if (!NT_SUCCESS(Status)) + { + TRACE("failed with status 0x%08lx\n", Status); + return Status; + } + + /* Set NTPwd attribute*/ + Status = SampSetObjectAttribute(UserObject, + L"NTPwd", + REG_BINARY, + NULL, + 0); + if (!NT_SUCCESS(Status)) + { + TRACE("failed with status 0x%08lx\n", Status); + return Status; + } + + /* Set LMPwdHistory attribute*/ + Status = SampSetObjectAttribute(UserObject, + L"LMPwdHistory", + REG_BINARY, + NULL, + 0); + if (!NT_SUCCESS(Status)) + { + TRACE("failed with status 0x%08lx\n", Status); + return Status; + } + + /* Set NTPwdHistory attribute*/ + Status = SampSetObjectAttribute(UserObject, + L"NTPwdHistory", + REG_BINARY, + NULL, + 0); + if (!NT_SUCCESS(Status)) + { + TRACE("failed with status 0x%08lx\n", Status); + return Status; + } + + /* FIXME: Set SecDesc attribute*/ if (NT_SUCCESS(Status)) { diff --git a/reactos/dll/win32/samsrv/setup.c b/reactos/dll/win32/samsrv/setup.c index dae35f0034b..6f87a600fc0 100644 --- a/reactos/dll/win32/samsrv/setup.c +++ b/reactos/dll/win32/samsrv/setup.c @@ -232,11 +232,23 @@ SampCreateUserAccount(HKEY hDomainKey, HKEY hNamesKey = NULL; /* Initialize fixed user data */ - memset(&FixedUserData, 0, sizeof(SAM_USER_FIXED_DATA)); FixedUserData.Version = 1; - + FixedUserData.Reserved = 0; + FixedUserData.LastLogon.QuadPart = 0; + FixedUserData.LastLogoff.QuadPart = 0; + FixedUserData.PasswordLastSet.QuadPart = 0; + FixedUserData.AccountExpires.LowPart = MAXULONG; + FixedUserData.AccountExpires.HighPart = MAXLONG; + FixedUserData.LastBadPasswordTime.QuadPart = 0; FixedUserData.UserId = ulRelativeId; + FixedUserData.PrimaryGroupId = DOMAIN_GROUP_RID_USERS; FixedUserData.UserAccountControl = UserAccountControl; + FixedUserData.CountryCode = 0; + FixedUserData.CodePage = 0; + FixedUserData.BadPasswordCount = 0; + FixedUserData.LogonCount = 0; + FixedUserData.AdminCount = 0; + FixedUserData.OperatorCount = 0; swprintf(szAccountKeyName, L"Users\\%08lX", ulRelativeId); @@ -327,6 +339,43 @@ SampCreateUserAccount(HKEY hDomainKey, (LPVOID)lpEmptyString, sizeof(WCHAR)); + /* FIXME: Set LogonHours attribute*/ + /* FIXME: Set Groups attribute*/ + + /* Set LMPwd attribute*/ + RegSetValueEx(hAccountKey, + L"LMPwd", + 0, + REG_BINARY, + NULL, + 0); + + /* Set NTPwd attribute*/ + RegSetValueEx(hAccountKey, + L"NTPwd", + 0, + REG_BINARY, + NULL, + 0); + + /* Set LMPwdHistory attribute*/ + RegSetValueEx(hAccountKey, + L"LMPwdHistory", + 0, + REG_BINARY, + NULL, + 0); + + /* Set NTPwdHistory attribute*/ + RegSetValueEx(hAccountKey, + L"NTPwdHistory", + 0, + REG_BINARY, + NULL, + 0); + + /* FIXME: Set SecDesc attribute*/ + RegCloseKey(hAccountKey); }