0

I use LDAP to validate the user/pass, no problem. When I change the password I get "server is not operational"

When I put an invalid user name the UserPrincipal.FindByIdentity it returns null, but when I use a correct userName it throws the error.

my Code:

        public static string ChangePassword(string adminUser, string adminPassword,
        string domain, string container, string userName, string newPassword)
    {
        try
        {
            PrincipalContext principalContext =
                new PrincipalContext(ContextType.Domain, domain, container,
                    adminUser, adminPassword);
            UserPrincipal user = UserPrincipal.FindByIdentity(principalContext, userName);
            if (user == null) return "User Not Found In This Domain";

            user.SetPassword(newPassword);
            return user.Name;
        }
        catch (Exception ex)
        {
            return ex.Message;
        }
    }

Have any configuration in server needed?

NotMe
  • 87,343
  • 27
  • 171
  • 245

0 Answers0