Mohd Afzaal
Mohd Afzaal

Reputation: 3

UserPrincipal.FindByIdentity gives user name or password incorrect exception

I am trying to connect to AD using PrincipalContext and admin credentials. After the connectivity is done i am validating user credentails. Once the user credentials are validated i am using UserPrincipal.FindByIdentity which always throws an exception "user name or password is incorrect". Below is my code

PrincipalContext pricipalContext = null;
pricipalContext = new PrincipalContext(ContextType.ApplicationDirectory, server, userdomainLdappath, "adminUsername", "adminPassword");
pricipalContext.ValidateCredentials("clientUsername", "clientPassword");
UserPrincipal usp = UserPrincipal.FindByIdentity(pricipalContext, "clientUsername");

Upvotes: 0

Views: 784

Answers (1)

Gabriel Luci
Gabriel Luci

Reputation: 40928

I'm pretty sure that ValidateCredentials uses the client credentials to connect to AD (that's how it validates). So your FindByIdentity line is the first time adminUsername/adminPassword are validated. So I suspect your admin credentials may be incorrect.

Upvotes: 0

Related Questions