locked
Access is denied, While resetting passord RRS feed

  • Question

  • User430178104 posted

    Hi,
    I am using below code to reset windows password. but it is throwing below error.

    Error: System.UnauthorizedAccessException: Access is denied.

    using (var context = new PrincipalContext(ContextType.Machine, domain))
                    using (var user = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, userName))
                    {
                        user.SetPassword(newPassword);
                    }

    Thursday, January 24, 2019 6:09 AM

All replies