* Implement NetUserChangePassword
* Implement NetUserGetGroups
* Implement NetUserSetGroups
- * Implement NetUserSetInfo
* NetUserGetLocalGroups does not support LG_INCLUDE_INDIRECT yet.
* Add missing information levels.
* ...
} ENUM_CONTEXT, *PENUM_CONTEXT;
-static PSID
-CreateSidFromSidAndRid(PSID SrcSid,
- ULONG RelativeId)
-{
- UCHAR RidCount;
- PSID DstSid;
- ULONG i;
- ULONG DstSidSize;
- PULONG p, q;
-
- RidCount = *RtlSubAuthorityCountSid(SrcSid);
- if (RidCount >= 8)
- return NULL;
-
- DstSidSize = RtlLengthRequiredSid(RidCount + 1);
-
- DstSid = RtlAllocateHeap(RtlGetProcessHeap(),
- 0,
- DstSidSize);
- if (DstSid == NULL)
- return NULL;
-
- RtlInitializeSid(DstSid,
- RtlIdentifierAuthoritySid(SrcSid),
- RidCount + 1);
-
- for (i = 0; i < (ULONG)RidCount; i++)
- {
- p = RtlSubAuthoritySid(SrcSid, i);
- q = RtlSubAuthoritySid(DstSid, i);
- *q = *p;
- }
-
- q = RtlSubAuthoritySid(DstSid, (ULONG)RidCount);
- *q = RelativeId;
-
- return DstSid;
-}
-
-
static
ULONG
GetAccountFlags(ULONG AccountControl)
static
NET_API_STATUS
-BuildUserInfoBuffer(PUSER_ACCOUNT_INFORMATION UserInfo,
+BuildUserInfoBuffer(PUSER_ALL_INFORMATION UserInfo,
DWORD level,
ULONG RelativeId,
LPVOID *Buffer)
{
+ UNICODE_STRING LogonServer = RTL_CONSTANT_STRING(L"\\\\*");
LPVOID LocalBuffer = NULL;
PUSER_INFO_0 UserInfo0;
PUSER_INFO_1 UserInfo1;
if (UserInfo->FullName.Length > 0)
Size += UserInfo->FullName.Length + sizeof(WCHAR);
- /* FIXME: usri2_usr_comment */
- /* FIXME: usri2_parms */
+ if (UserInfo->UserComment.Length > 0)
+ Size += UserInfo->UserComment.Length + sizeof(WCHAR);
+
+ if (UserInfo->Parameters.Length > 0)
+ Size += UserInfo->Parameters.Length + sizeof(WCHAR);
if (UserInfo->WorkStations.Length > 0)
Size += UserInfo->WorkStations.Length + sizeof(WCHAR);
- /* FIXME: usri2_logon_hours */
- /* FIXME: usri2_logon_server */
+ if (UserInfo->LogonHours.UnitsPerWeek > 0)
+ Size += (((ULONG)UserInfo->LogonHours.UnitsPerWeek) + 7) / 8;
+
+ if (LogonServer.Length > 0)
+ Size += LogonServer.Length + sizeof(WCHAR);
break;
case 3:
if (UserInfo->FullName.Length > 0)
Size += UserInfo->FullName.Length + sizeof(WCHAR);
- /* FIXME: usri3_usr_comment */
- /* FIXME: usri3_parms */
+ if (UserInfo->UserComment.Length > 0)
+ Size += UserInfo->UserComment.Length + sizeof(WCHAR);
+
+ if (UserInfo->Parameters.Length > 0)
+ Size += UserInfo->Parameters.Length + sizeof(WCHAR);
if (UserInfo->WorkStations.Length > 0)
Size += UserInfo->WorkStations.Length + sizeof(WCHAR);
- /* FIXME: usri3_logon_hours */
- /* FIXME: usri3_logon_server */
+ if (UserInfo->LogonHours.UnitsPerWeek > 0)
+ Size += (((ULONG)UserInfo->LogonHours.UnitsPerWeek) + 7) / 8;
+
+ if (LogonServer.Length > 0)
+ Size += LogonServer.Length + sizeof(WCHAR);
if (UserInfo->ProfilePath.Length > 0)
Size += UserInfo->ProfilePath.Length + sizeof(WCHAR);
if (UserInfo->AdminComment.Length > 0)
Size += UserInfo->AdminComment.Length + sizeof(WCHAR);
- /* FIXME: usri10_usr_comment */
+ if (UserInfo->UserComment.Length > 0)
+ Size += UserInfo->UserComment.Length + sizeof(WCHAR);
if (UserInfo->FullName.Length > 0)
Size += UserInfo->FullName.Length + sizeof(WCHAR);
Ptr = (LPWSTR)((ULONG_PTR)Ptr + UserInfo->FullName.Length + sizeof(WCHAR));
}
- /* FIXME: usri2_usr_comment */
- /* FIXME: usri2_parms */
+ if (UserInfo->UserComment.Length > 0)
+ {
+ UserInfo2->usri2_usr_comment = Ptr;
+
+ memcpy(UserInfo2->usri2_usr_comment,
+ UserInfo->UserComment.Buffer,
+ UserInfo->UserComment.Length);
+ UserInfo2->usri2_usr_comment[UserInfo->UserComment.Length / sizeof(WCHAR)] = UNICODE_NULL;
+
+ Ptr = (LPWSTR)((ULONG_PTR)Ptr + UserInfo->UserComment.Length + sizeof(WCHAR));
+ }
+
+ if (UserInfo->Parameters.Length > 0)
+ {
+ UserInfo2->usri2_parms = Ptr;
+
+ memcpy(UserInfo2->usri2_parms,
+ UserInfo->Parameters.Buffer,
+ UserInfo->Parameters.Length);
+ UserInfo2->usri2_parms[UserInfo->Parameters.Length / sizeof(WCHAR)] = UNICODE_NULL;
+
+ Ptr = (LPWSTR)((ULONG_PTR)Ptr + UserInfo->Parameters.Length + sizeof(WCHAR));
+ }
if (UserInfo->WorkStations.Length > 0)
{
&UserInfo2->usri2_acct_expires);
UserInfo2->usri2_max_storage = USER_MAXSTORAGE_UNLIMITED;
+ UserInfo2->usri2_units_per_week = UserInfo->LogonHours.UnitsPerWeek;
+
+ if (UserInfo->LogonHours.UnitsPerWeek > 0)
+ {
+ UserInfo2->usri2_logon_hours = (PVOID)Ptr;
- /* FIXME: usri2_units_per_week */
- /* FIXME: usri2_logon_hours */
+ memcpy(UserInfo2->usri2_logon_hours,
+ UserInfo->LogonHours.LogonHours,
+ (((ULONG)UserInfo->LogonHours.UnitsPerWeek) + 7) / 8);
+
+ Ptr = (LPWSTR)((ULONG_PTR)Ptr + (((ULONG)UserInfo->LogonHours.UnitsPerWeek) + 7) / 8);
+ }
UserInfo2->usri2_bad_pw_count = UserInfo->BadPasswordCount;
UserInfo2->usri2_num_logons = UserInfo->LogonCount;
- /* FIXME: usri2_logon_server */
- /* FIXME: usri2_country_code */
- /* FIXME: usri2_code_page */
+ if (LogonServer.Length > 0)
+ {
+ UserInfo2->usri2_logon_server = Ptr;
+ memcpy(UserInfo2->usri2_logon_server,
+ LogonServer.Buffer,
+ LogonServer.Length);
+ UserInfo2->usri2_logon_server[LogonServer.Length / sizeof(WCHAR)] = UNICODE_NULL;
+
+ Ptr = (LPWSTR)((ULONG_PTR)Ptr + LogonServer.Length + sizeof(WCHAR));
+ }
+
+ UserInfo2->usri2_country_code = UserInfo->CountryCode;
+ UserInfo2->usri2_code_page = UserInfo->CodePage;
break;
case 3:
Ptr = (LPWSTR)((ULONG_PTR)Ptr + UserInfo->FullName.Length + sizeof(WCHAR));
}
- /* FIXME: usri3_usr_comment */
- /* FIXME: usri3_parms */
+ if (UserInfo->UserComment.Length > 0)
+ {
+ UserInfo3->usri3_usr_comment = Ptr;
+
+ memcpy(UserInfo3->usri3_usr_comment,
+ UserInfo->UserComment.Buffer,
+ UserInfo->UserComment.Length);
+ UserInfo3->usri3_usr_comment[UserInfo->UserComment.Length / sizeof(WCHAR)] = UNICODE_NULL;
+
+ Ptr = (LPWSTR)((ULONG_PTR)Ptr + UserInfo->UserComment.Length + sizeof(WCHAR));
+ }
+
+ if (UserInfo->Parameters.Length > 0)
+ {
+ UserInfo3->usri3_parms = Ptr;
+
+ memcpy(UserInfo3->usri3_parms,
+ UserInfo->Parameters.Buffer,
+ UserInfo->Parameters.Length);
+ UserInfo3->usri3_parms[UserInfo->Parameters.Length / sizeof(WCHAR)] = UNICODE_NULL;
+
+ Ptr = (LPWSTR)((ULONG_PTR)Ptr + UserInfo->Parameters.Length + sizeof(WCHAR));
+ }
if (UserInfo->WorkStations.Length > 0)
{
&UserInfo3->usri3_acct_expires);
UserInfo3->usri3_max_storage = USER_MAXSTORAGE_UNLIMITED;
+ UserInfo3->usri3_units_per_week = UserInfo->LogonHours.UnitsPerWeek;
+
+ if (UserInfo->LogonHours.UnitsPerWeek > 0)
+ {
+ UserInfo3->usri3_logon_hours = (PVOID)Ptr;
- /* FIXME: usri3_units_per_week */
- /* FIXME: usri3_logon_hours */
+ memcpy(UserInfo3->usri3_logon_hours,
+ UserInfo->LogonHours.LogonHours,
+ (((ULONG)UserInfo->LogonHours.UnitsPerWeek) + 7) / 8);
+
+ Ptr = (LPWSTR)((ULONG_PTR)Ptr + (((ULONG)UserInfo->LogonHours.UnitsPerWeek) + 7) / 8);
+ }
UserInfo3->usri3_bad_pw_count = UserInfo->BadPasswordCount;
UserInfo3->usri3_num_logons = UserInfo->LogonCount;
- /* FIXME: usri3_logon_server */
- /* FIXME: usri3_country_code */
- /* FIXME: usri3_code_page */
+ if (LogonServer.Length > 0)
+ {
+ UserInfo3->usri3_logon_server = Ptr;
+
+ memcpy(UserInfo3->usri3_logon_server,
+ LogonServer.Buffer,
+ LogonServer.Length);
+ UserInfo3->usri3_logon_server[LogonServer.Length / sizeof(WCHAR)] = UNICODE_NULL;
+ Ptr = (LPWSTR)((ULONG_PTR)Ptr + LogonServer.Length + sizeof(WCHAR));
+ }
+
+ UserInfo3->usri3_country_code = UserInfo->CountryCode;
+ UserInfo3->usri3_code_page = UserInfo->CodePage;
UserInfo3->usri3_user_id = RelativeId;
UserInfo3->usri3_primary_group_id = UserInfo->PrimaryGroupId;
Ptr = (LPWSTR)((ULONG_PTR)Ptr + UserInfo->AdminComment.Length + sizeof(WCHAR));
}
- /* FIXME: usri10_usr_comment */
+ if (UserInfo->UserComment.Length > 0)
+ {
+ UserInfo10->usri10_usr_comment = Ptr;
+
+ memcpy(UserInfo10->usri10_usr_comment,
+ UserInfo->UserComment.Buffer,
+ UserInfo->UserComment.Length);
+ UserInfo10->usri10_usr_comment[UserInfo->UserComment.Length / sizeof(WCHAR)] = UNICODE_NULL;
+
+ Ptr = (LPWSTR)((ULONG_PTR)Ptr + UserInfo->UserComment.Length + sizeof(WCHAR));
+ }
if (UserInfo->FullName.Length > 0)
{
static
VOID
-FreeUserInfo(PUSER_ACCOUNT_INFORMATION UserInfo)
+FreeUserInfo(PUSER_ALL_INFORMATION UserInfo)
{
if (UserInfo->UserName.Buffer != NULL)
SamFreeMemory(UserInfo->UserName.Buffer);
if (UserInfo->WorkStations.Buffer != NULL)
SamFreeMemory(UserInfo->WorkStations.Buffer);
+ if (UserInfo->UserComment.Buffer != NULL)
+ SamFreeMemory(UserInfo->UserComment.Buffer);
+
+ if (UserInfo->Parameters.Buffer != NULL)
+ SamFreeMemory(UserInfo->Parameters.Buffer);
+
+ if (UserInfo->PrivateData.Buffer != NULL)
+ SamFreeMemory(UserInfo->PrivateData.Buffer);
+
if (UserInfo->LogonHours.LogonHours != NULL)
SamFreeMemory(UserInfo->LogonHours.LogonHours);
DWORD Level)
{
USER_ALL_INFORMATION UserAllInfo;
+ PUSER_INFO_0 UserInfo0;
PUSER_INFO_1 UserInfo1;
+ PUSER_INFO_2 UserInfo2;
PUSER_INFO_3 UserInfo3;
+ PUSER_INFO_1003 UserInfo1003;
+ PUSER_INFO_1006 UserInfo1006;
+ PUSER_INFO_1007 UserInfo1007;
+ PUSER_INFO_1009 UserInfo1009;
+ PUSER_INFO_1011 UserInfo1011;
+ PUSER_INFO_1012 UserInfo1012;
+ PUSER_INFO_1013 UserInfo1013;
+ PUSER_INFO_1014 UserInfo1014;
+ PUSER_INFO_1052 UserInfo1052;
+ PUSER_INFO_1053 UserInfo1053;
NET_API_STATUS ApiStatus = NERR_Success;
NTSTATUS Status = STATUS_SUCCESS;
switch (Level)
{
+ case 0:
+ UserInfo0 = (PUSER_INFO_0)UserInfo;
+
+ RtlInitUnicodeString(&UserAllInfo.UserName,
+ UserInfo0->usri0_name);
+
+ UserAllInfo.WhichFields |= USER_ALL_USERNAME;
+ break;
+
case 1:
UserInfo1 = (PUSER_INFO_1)UserInfo;
-// RtlInitUnicodeString(&UserAllInfo.UserName,
-// UserInfo1->usri1_name);
- RtlInitUnicodeString(&UserAllInfo.AdminComment,
- UserInfo1->usri1_comment);
+ // usri1_name ignored
- RtlInitUnicodeString(&UserAllInfo.HomeDirectory,
- UserInfo1->usri1_home_dir);
+ if (UserInfo1->usri1_password != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.NtPassword,
+ UserInfo1->usri1_password);
+ UserAllInfo.NtPasswordPresent = TRUE;
+ UserAllInfo.WhichFields |= USER_ALL_NTPASSWORDPRESENT;
+ }
- RtlInitUnicodeString(&UserAllInfo.ScriptPath,
- UserInfo1->usri1_script_path);
+ // usri1_password_age ignored
- RtlInitUnicodeString(&UserAllInfo.NtPassword,
- UserInfo1->usri1_password);
- UserAllInfo.NtPasswordPresent = TRUE;
+// UserInfo1->usri1_priv
+
+ if (UserInfo1->usri1_home_dir != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.HomeDirectory,
+ UserInfo1->usri1_home_dir);
+ UserAllInfo.WhichFields |= USER_ALL_HOMEDIRECTORY;
+ }
+
+ if (UserInfo1->usri1_comment != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.AdminComment,
+ UserInfo1->usri1_comment);
+ UserAllInfo.WhichFields |= USER_ALL_ADMINCOMMENT;
+ }
// UserInfo1->usri1_flags
-// UserInfo1->usri1_priv
+// UserAllInfo.WhichFields |= USER_ALL_USERACCOUNTCONTROL;
- UserAllInfo.WhichFields =
- USER_ALL_ADMINCOMMENT |
- USER_ALL_HOMEDIRECTORY |
- USER_ALL_SCRIPTPATH |
- USER_ALL_NTPASSWORDPRESENT
-// USER_ALL_USERACCOUNTCONTROL
- ;
+ if (UserInfo1->usri1_script_path != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.ScriptPath,
+ UserInfo1->usri1_script_path);
+ UserAllInfo.WhichFields |= USER_ALL_SCRIPTPATH;
+ }
break;
+ case 2:
+ UserInfo2 = (PUSER_INFO_2)UserInfo;
+
+ // usri2_name ignored
+
+ if (UserInfo2->usri2_password != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.NtPassword,
+ UserInfo2->usri2_password);
+ UserAllInfo.NtPasswordPresent = TRUE;
+ UserAllInfo.WhichFields |= USER_ALL_NTPASSWORDPRESENT;
+ }
+
+ // usri2_password_age ignored
+
+// UserInfo2->usri2_priv;
+
+ if (UserInfo2->usri2_home_dir != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.HomeDirectory,
+ UserInfo2->usri2_home_dir);
+ UserAllInfo.WhichFields |= USER_ALL_HOMEDIRECTORY;
+ }
+
+ if (UserInfo2->usri2_comment != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.AdminComment,
+ UserInfo2->usri2_comment);
+ UserAllInfo.WhichFields |= USER_ALL_ADMINCOMMENT;
+ }
+
+// UserInfo2->usri2_flags;
+
+ if (UserInfo2->usri2_script_path != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.ScriptPath,
+ UserInfo2->usri2_script_path);
+ UserAllInfo.WhichFields |= USER_ALL_SCRIPTPATH;
+ }
+
+// UserInfo2->usri2_auth_flags;
+
+ if (UserInfo2->usri2_full_name != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.FullName,
+ UserInfo2->usri2_full_name);
+ UserAllInfo.WhichFields |= USER_ALL_FULLNAME;
+ }
+
+ if (UserInfo2->usri2_usr_comment != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.UserComment,
+ UserInfo2->usri2_usr_comment);
+ UserAllInfo.WhichFields |= USER_ALL_USERCOMMENT;
+ }
+
+ if (UserInfo2->usri2_parms != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.Parameters,
+ UserInfo2->usri2_parms);
+ UserAllInfo.WhichFields |= USER_ALL_PARAMETERS;
+ }
+
+ if (UserInfo2->usri2_workstations != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.WorkStations,
+ UserInfo2->usri2_workstations);
+ UserAllInfo.WhichFields |= USER_ALL_WORKSTATIONS;
+ }
+
+ // usri2_last_logon ignored
+ // usri2_last_logoff ignored
+
+// UserInfo2->usri2_acct_expires;
+// UserInfo2->usri2_max_storage;
+// UserInfo2->usri2_units_per_week;
+// UserInfo2->usri2_logon_hours;
+
+ // usri2_bad_pw_count ignored
+ // usri2_num_logons ignored
+ // usri2_logon_server ignored
+
+// UserInfo2->usri2_country_code;
+// UserInfo2->usri2_code_page;
+ break;
case 3:
UserInfo3 = (PUSER_INFO_3)UserInfo;
-// LPWSTR usri3_name;
-
- RtlInitUnicodeString(&UserAllInfo.NtPassword,
- UserInfo3->usri3_password);
- UserAllInfo.NtPasswordPresent = TRUE;
-
-// DWORD usri3_password_age; // ignored
-// DWORD usri3_priv;
-
- RtlInitUnicodeString(&UserAllInfo.HomeDirectory,
- UserInfo3->usri3_home_dir);
-
- RtlInitUnicodeString(&UserAllInfo.AdminComment,
- UserInfo3->usri3_comment);
-
-// DWORD usri3_flags;
-
- RtlInitUnicodeString(&UserAllInfo.ScriptPath,
- UserInfo3->usri3_script_path);
-
-// DWORD usri3_auth_flags;
-
- RtlInitUnicodeString(&UserAllInfo.FullName,
- UserInfo3->usri3_full_name);
-
-// LPWSTR usri3_usr_comment;
-// LPWSTR usri3_parms;
-// LPWSTR usri3_workstations;
-// DWORD usri3_last_logon;
-// DWORD usri3_last_logoff;
-// DWORD usri3_acct_expires;
-// DWORD usri3_max_storage;
-// DWORD usri3_units_per_week;
-// PBYTE usri3_logon_hours;
-// DWORD usri3_bad_pw_count;
-// DWORD usri3_num_logons;
-// LPWSTR usri3_logon_server;
-// DWORD usri3_country_code;
-// DWORD usri3_code_page;
-// DWORD usri3_user_id; // ignored
-// DWORD usri3_primary_group_id;
-// LPWSTR usri3_profile;
-// LPWSTR usri3_home_dir_drive;
-// DWORD usri3_password_expired;
-
- UserAllInfo.WhichFields =
- USER_ALL_NTPASSWORDPRESENT |
- USER_ALL_HOMEDIRECTORY |
- USER_ALL_ADMINCOMMENT |
- USER_ALL_SCRIPTPATH |
- USER_ALL_FULLNAME
-// USER_ALL_USERACCOUNTCONTROL
- ;
+ // usri3_name ignored
+
+ if (UserInfo3->usri3_password != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.NtPassword,
+ UserInfo3->usri3_password);
+ UserAllInfo.NtPasswordPresent = TRUE;
+ UserAllInfo.WhichFields |= USER_ALL_NTPASSWORDPRESENT;
+ }
+
+ // usri3_password_age ignored
+
+// UserInfo3->usri3_priv;
+
+ if (UserInfo3->usri3_home_dir != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.HomeDirectory,
+ UserInfo3->usri3_home_dir);
+ UserAllInfo.WhichFields |= USER_ALL_HOMEDIRECTORY;
+ }
+
+ if (UserInfo3->usri3_comment != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.AdminComment,
+ UserInfo3->usri3_comment);
+ UserAllInfo.WhichFields |= USER_ALL_ADMINCOMMENT;
+ }
+
+// UserInfo3->usri3_flags;
+// UserAllInfo.WhichFields |= USER_ALL_USERACCOUNTCONTROL;
+
+ if (UserInfo3->usri3_script_path != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.ScriptPath,
+ UserInfo3->usri3_script_path);
+ UserAllInfo.WhichFields |= USER_ALL_SCRIPTPATH;
+ }
+
+// UserInfo3->usri3_auth_flags;
+
+ if (UserInfo3->usri3_full_name != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.FullName,
+ UserInfo3->usri3_full_name);
+ UserAllInfo.WhichFields |= USER_ALL_FULLNAME;
+ }
+
+ if (UserInfo3->usri3_usr_comment != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.UserComment,
+ UserInfo3->usri3_usr_comment);
+ UserAllInfo.WhichFields |= USER_ALL_USERCOMMENT;
+ }
+
+ if (UserInfo3->usri3_parms != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.Parameters,
+ UserInfo3->usri3_parms);
+ UserAllInfo.WhichFields |= USER_ALL_PARAMETERS;
+ }
+
+ if (UserInfo3->usri3_workstations != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.WorkStations,
+ UserInfo3->usri3_workstations);
+ UserAllInfo.WhichFields |= USER_ALL_WORKSTATIONS;
+ }
+
+ // usri3_last_logon ignored
+ // usri3_last_logoff ignored
+
+// UserInfo3->usri3_acct_expires;
+// UserInfo3->usri3_max_storage;
+// UserInfo3->usri3_units_per_week;
+// UserInfo3->usri3_logon_hours;
+
+ // usri3_bad_pw_count ignored
+ // usri3_num_logons ignored
+ // usri3_logon_server ignored
+
+// UserInfo3->usri3_country_code;
+// UserInfo3->usri3_code_page;
+
+ // usri3_user_id ignored
+
+// UserInfo3->usri3_primary_group_id;
+
+ if (UserInfo3->usri3_profile != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.ProfilePath,
+ UserInfo3->usri3_profile);
+ UserAllInfo.WhichFields |= USER_ALL_PROFILEPATH;
+ }
+
+ if (UserInfo3->usri3_home_dir_drive != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.HomeDirectoryDrive,
+ UserInfo3->usri3_home_dir_drive);
+ UserAllInfo.WhichFields |= USER_ALL_HOMEDIRECTORYDRIVE;
+ }
+
+// UserInfo3->usri3_password_expired;
+ break;
+
+// case 4:
+// case 21:
+// case 22:
+
+ case 1003:
+ UserInfo1003 = (PUSER_INFO_1003)UserInfo;
+
+ if (UserInfo1003->usri1003_password != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.NtPassword,
+ UserInfo1003->usri1003_password);
+ UserAllInfo.NtPasswordPresent = TRUE;
+ UserAllInfo.WhichFields |= USER_ALL_NTPASSWORDPRESENT;
+ }
+ break;
+
+// case 1005:
+
+ case 1006:
+ UserInfo1006 = (PUSER_INFO_1006)UserInfo;
+
+ if (UserInfo1006->usri1006_home_dir != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.HomeDirectory,
+ UserInfo1006->usri1006_home_dir);
+ UserAllInfo.WhichFields |= USER_ALL_HOMEDIRECTORY;
+ }
+ break;
+
+ case 1007:
+ UserInfo1007 = (PUSER_INFO_1007)UserInfo;
+
+ if (UserInfo1007->usri1007_comment != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.AdminComment,
+ UserInfo1007->usri1007_comment);
+ UserAllInfo.WhichFields |= USER_ALL_ADMINCOMMENT;
+ }
+ break;
+
+// case 1008:
+
+ case 1009:
+ UserInfo1009 = (PUSER_INFO_1009)UserInfo;
+
+ if (UserInfo1009->usri1009_script_path != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.ScriptPath,
+ UserInfo1009->usri1009_script_path);
+ UserAllInfo.WhichFields |= USER_ALL_SCRIPTPATH;
+ }
+ break;
+
+// case 1010:
+
+ case 1011:
+ UserInfo1011 = (PUSER_INFO_1011)UserInfo;
+
+ if (UserInfo1011->usri1011_full_name != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.FullName,
+ UserInfo1011->usri1011_full_name);
+ UserAllInfo.WhichFields |= USER_ALL_FULLNAME;
+ }
+ break;
+
+ case 1012:
+ UserInfo1012 = (PUSER_INFO_1012)UserInfo;
+
+ if (UserInfo1012->usri1012_usr_comment != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.UserComment,
+ UserInfo1012->usri1012_usr_comment);
+ UserAllInfo.WhichFields |= USER_ALL_USERCOMMENT;
+ }
+ break;
+
+ case 1013:
+ UserInfo1013 = (PUSER_INFO_1013)UserInfo;
+
+ if (UserInfo1013->usri1013_parms != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.Parameters,
+ UserInfo1013->usri1013_parms);
+ UserAllInfo.WhichFields |= USER_ALL_PARAMETERS;
+ }
+ break;
+
+ case 1014:
+ UserInfo1014 = (PUSER_INFO_1014)UserInfo;
+
+ if (UserInfo1014->usri1014_workstations != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.WorkStations,
+ UserInfo1014->usri1014_workstations);
+ UserAllInfo.WhichFields |= USER_ALL_WORKSTATIONS;
+ }
+ break;
+
+// case 1017:
+// case 1020:
+// case 1024:
+// case 1051:
+
+ case 1052:
+ UserInfo1052 = (PUSER_INFO_1052)UserInfo;
+
+ if (UserInfo1052->usri1052_profile != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.ProfilePath,
+ UserInfo1052->usri1052_profile);
+ UserAllInfo.WhichFields |= USER_ALL_PROFILEPATH;
+ }
+ break;
+
+ case 1053:
+ UserInfo1053 = (PUSER_INFO_1053)UserInfo;
+
+ if (UserInfo1053->usri1053_home_dir_drive != NULL)
+ {
+ RtlInitUnicodeString(&UserAllInfo.HomeDirectoryDrive,
+ UserInfo1053->usri1053_home_dir_drive);
+ UserAllInfo.WhichFields |= USER_ALL_HOMEDIRECTORYDRIVE;
+ }
break;
default:
TRACE("(%s, %d, %p, %p)\n", debugstr_w(servername), level, bufptr, parm_err);
/* Check the info level */
- if (level < 1 || level > 4)
- return ERROR_INVALID_LEVEL;
+ switch (level)
+ {
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ break;
+
+ default:
+ return ERROR_INVALID_LEVEL;
+ }
if (servername != NULL)
RtlInitUnicodeString(&ServerName, servername);
LPVOID Buffer = NULL;
ULONG i;
SAM_HANDLE UserHandle = NULL;
- PUSER_ACCOUNT_INFORMATION UserInfo = NULL;
+ PUSER_ALL_INFORMATION UserInfo = NULL;
NET_API_STATUS ApiStatus = NERR_Success;
NTSTATUS Status = STATUS_SUCCESS;
- FIXME("(%s %d 0x%d %p %d %p %p %p) stub!\n", debugstr_w(servername), level,
+ TRACE("(%s %d 0x%d %p %d %p %p %p)\n", debugstr_w(servername), level,
filter, bufptr, prefmaxlen, entriesread, totalentries, resume_handle);
*entriesread = 0;
}
Status = SamQueryInformationUser(UserHandle,
- UserAccountInformation,
+ UserAllInformation,
(PVOID *)&UserInfo);
if (!NT_SUCCESS(Status))
{
SAM_HANDLE UserHandle = NULL;
PULONG RelativeIds = NULL;
PSID_NAME_USE Use = NULL;
- PUSER_ACCOUNT_INFORMATION UserInfo = NULL;
+ PUSER_ALL_INFORMATION UserInfo = NULL;
LPVOID Buffer = NULL;
NET_API_STATUS ApiStatus = NERR_Success;
NTSTATUS Status = STATUS_SUCCESS;
}
Status = SamQueryInformationUser(UserHandle,
- UserAccountInformation,
+ UserAllInformation,
(PVOID *)&UserInfo);
if (!NT_SUCCESS(Status))
{
}
/* Build the User SID from the Account Domain SID and the users RID */
- UserSid = CreateSidFromSidAndRid(AccountDomainSid,
- RelativeIds[0]);
- if (UserSid == NULL)
+ ApiStatus = BuildSidFromSidAndRid(AccountDomainSid,
+ RelativeIds[0],
+ &UserSid);
+ if (ApiStatus != NERR_Success)
{
- ERR("CreateSidFromSidAndRid failed!\n");
- ApiStatus = ERROR_NOT_ENOUGH_MEMORY;
+ ERR("BuildSidFromSidAndRid failed!\n");
goto done;
}
SamFreeMemory(Use);
if (UserSid != NULL)
- RtlFreeHeap(RtlGetProcessHeap(), 0, UserSid);
+ NetApiBufferFree(UserSid);
if (AccountDomainSid != NULL)
RtlFreeHeap(RtlGetProcessHeap(), 0, AccountDomainSid);
LPBYTE buf,
LPDWORD parm_err)
{
- FIXME("(%s %s %lu %p %p)\n",
+ UNICODE_STRING ServerName;
+ UNICODE_STRING UserName;
+ SAM_HANDLE ServerHandle = NULL;
+ SAM_HANDLE AccountDomainHandle = NULL;
+ SAM_HANDLE UserHandle = NULL;
+ NET_API_STATUS ApiStatus = NERR_Success;
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ TRACE("(%s %s %lu %p %p)\n",
debugstr_w(servername), debugstr_w(username), level, buf, parm_err);
- return ERROR_ACCESS_DENIED;
+
+ if (parm_err != NULL)
+ *parm_err = PARM_ERROR_NONE;
+
+ /* Check the info level */
+ switch (level)
+ {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+// case 4:
+// case 21:
+// case 22:
+ case 1003:
+// case 1005:
+ case 1006:
+ case 1007:
+// case 1008:
+ case 1009:
+// case 1010:
+ case 1011:
+ case 1012:
+ case 1013:
+ case 1014:
+// case 1017:
+// case 1020:
+// case 1024:
+// case 1051:
+ case 1052:
+ case 1053:
+ break;
+
+ default:
+ return ERROR_INVALID_LEVEL;
+ }
+
+ if (servername != NULL)
+ RtlInitUnicodeString(&ServerName, servername);
+
+ RtlInitUnicodeString(&UserName, username);
+
+ /* Connect to the SAM Server */
+ Status = SamConnect((servername != NULL) ? &ServerName : NULL,
+ &ServerHandle,
+ SAM_SERVER_CONNECT | SAM_SERVER_LOOKUP_DOMAIN,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("SamConnect failed (Status %08lx)\n", Status);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+
+ /* Open the Account Domain */
+ Status = OpenAccountDomain(ServerHandle,
+ (servername != NULL) ? &ServerName : NULL,
+ DOMAIN_LIST_ACCOUNTS | DOMAIN_LOOKUP,
+ &AccountDomainHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("OpenAccountDomain failed (Status %08lx)\n", Status);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+
+ /* Open the User Account */
+ ApiStatus = OpenUserByName(AccountDomainHandle,
+ &UserName,
+ USER_ALL_ACCESS,
+ &UserHandle);
+ if (ApiStatus != NERR_Success)
+ {
+ ERR("OpenUserByName failed (ApiStatus %lu)\n", ApiStatus);
+ goto done;
+ }
+
+ /* Set user information */
+ ApiStatus = SetUserInfo(UserHandle,
+ buf,
+ level);
+ if (ApiStatus != NERR_Success)
+ {
+ ERR("SetUserInfo failed (Status %lu)\n", ApiStatus);
+ }
+
+done:
+ if (UserHandle != NULL)
+ SamCloseHandle(UserHandle);
+
+ if (AccountDomainHandle != NULL)
+ SamCloseHandle(AccountDomainHandle);
+
+ if (ServerHandle != NULL)
+ SamCloseHandle(ServerHandle);
+
+ return ApiStatus;
}
/* EOF */