Change your own password Directory Services

Lee Taylor 31 Reputation points
2021-12-10T21:43:05.497+00:00

I am using .Net Directory services to allow my app to change the password of the logged in user, however I am getting Access Denied when I execute the SetPassword function, which does not make any sense, I can change my password when I <CTRL+ALT+DEL> or <CTRL+ALT+END> in remote desktop. Anyone with any advice?

I have ...
Dim adUser As UserPrincipal = UserPrincipal.Current
adUser.SetPassword(sPWd)

Developer technologies .NET .NET Runtime
Developer technologies VB
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2021-12-11T17:19:50.74+00:00

    SetPassword is an admin reset, so you need admin permissions. You probably wanted ChangePassword() which changes the password. For security, like the change password utility, you need the old password.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Cristian SPIRIDON 4,486 Reputation points Volunteer Moderator
    2021-12-11T05:29:01.437+00:00

    Hi,

    My understanding is that you need to be admin to use that function. It will not change the password but reset it.

    And you need to meet the password complexity requirements.

    Hope this helps!

    0 comments No comments

  2. Jiachen Li-MSFT 34,221 Reputation points Microsoft External Staff
    2021-12-13T05:38:43.45+00:00

    Hi @Lee Taylor ,
    If you want the user to change the login password by himself, please use ChangePassword() to allow the user to provide the old password and the new password to change the password.
    SetPassword() requires the caller to have administrator rights.
    You can check the specific usage through the link above.
    Best Regards.
    Jiachen Li

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.