netapi32: Implement NetUserChangePassword.

This commit is contained in:
Kai Blin 2007-03-24 09:02:04 +01:00 committed by Alexandre Julliard
parent 2207f20b5f
commit 1daf9a1e51
2 changed files with 40 additions and 3 deletions

View File

@ -813,6 +813,23 @@ NET_API_STATUS WINAPI NetUserModalsGet(
NET_API_STATUS WINAPI NetUserChangePassword(LPCWSTR domainname, LPCWSTR username,
LPCWSTR oldpassword, LPCWSTR newpassword)
{
FIXME("(%s, %s, ..., ...)\n", debugstr_w(domainname), debugstr_w(username));
return NERR_InternalError;
struct sam_user *user;
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;
}

View File

@ -254,9 +254,29 @@ static void run_userhandling_tests(void)
if(ret != NERR_Success)
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,
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);
ok(ret == NERR_Success, "Deleting the user failed.\n");