Commit 1daf9a1e authored by Kai Blin's avatar Kai Blin Committed by Alexandre Julliard

netapi32: Implement NetUserChangePassword.

parent 2207f20b
...@@ -813,6 +813,23 @@ NET_API_STATUS WINAPI NetUserModalsGet( ...@@ -813,6 +813,23 @@ NET_API_STATUS WINAPI NetUserModalsGet(
NET_API_STATUS WINAPI NetUserChangePassword(LPCWSTR domainname, LPCWSTR username, NET_API_STATUS WINAPI NetUserChangePassword(LPCWSTR domainname, LPCWSTR username,
LPCWSTR oldpassword, LPCWSTR newpassword) LPCWSTR oldpassword, LPCWSTR newpassword)
{ {
FIXME("(%s, %s, ..., ...)\n", debugstr_w(domainname), debugstr_w(username)); struct sam_user *user;
return NERR_InternalError;
TRACE("(%s, %s, ..., ...)\n", debugstr_w(domainname), debugstr_w(username));
if(domainname)
FIXME("Ignoring domainname %s.\n", debugstr_w(domainname));
if((user = NETAPI_FindUser(username)) == NULL)
return NERR_UserNotFound;
if(lstrcmpW(user->user_password, oldpassword) != 0)
return ERROR_INVALID_PASSWORD;
if(lstrlenW(newpassword) > PWLEN)
return ERROR_PASSWORD_RESTRICTION;
lstrcpyW(user->user_password, newpassword);
return NERR_Success;
} }
...@@ -254,9 +254,29 @@ static void run_userhandling_tests(void) ...@@ -254,9 +254,29 @@ static void run_userhandling_tests(void)
if(ret != NERR_Success) if(ret != NERR_Success)
return; return;
ret = pNetUserChangePassword(NULL, sNonexistentUser, sTestUserOldPass,
sTestUserNewPass);
ok(ret == NERR_UserNotFound,
"Changing password for nonexistent user returned 0x%08x.\n", ret);
ret = pNetUserChangePassword(NULL, sTestUserName, sTestUserOldPass,
sTestUserOldPass);
ok(ret == NERR_Success,
"Changing old password to old password returned 0x%08x.\n", ret);
ret = pNetUserChangePassword(NULL, sTestUserName, sTestUserNewPass,
sTestUserOldPass);
ok(ret == ERROR_INVALID_PASSWORD,
"Trying to change password giving an invalid password returned 0x%08x.\n", ret);
ret = pNetUserChangePassword(NULL, sTestUserName, sTestUserOldPass,
sTooLongPassword);
ok(ret == ERROR_PASSWORD_RESTRICTION,
"Changing to a password that's too long returned 0x%08x.\n", ret);
ret = pNetUserChangePassword(NULL, sTestUserName, sTestUserOldPass, ret = pNetUserChangePassword(NULL, sTestUserName, sTestUserOldPass,
sTestUserNewPass); sTestUserNewPass);
todo_wine ok(ret == NERR_Success, "Changing the password failed.\n"); ok(ret == NERR_Success, "Changing the password correctly returned 0x%08x.\n", ret);
ret = pNetUserDel(NULL, sTestUserName); ret = pNetUserDel(NULL, sTestUserName);
ok(ret == NERR_Success, "Deleting the user failed.\n"); ok(ret == NERR_Success, "Deleting the user failed.\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment