Change your own password Directory Services

Lee Taylor 26 Reputation points

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

An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,511 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,101 questions
{count} votes

Accepted answer
  1. Bruce ( 52,836 Reputation points

    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,471 Reputation points


    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 24,751 Reputation points Microsoft Vendor

    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