Question

I know my Account Username and password. I am able to login to any PC on the domain.

Console.WriteLine("User Name: " + userName + " Password: " + tb.Text.ToString().Trim());
System.DirectoryServices.AccountManagement.PrincipalContext pc = new System.DirectoryServices.AccountManagement.PrincipalContext(ContextType.Domain, "DOMAIN.TLD");                

// validate the credentials 
bool validatedOnDomain = pc.ValidateCredentials(userName, tb.Text.ToString().Trim());
return validatedOnDomain;

This method keeps returning false.

Am I doing something wrong here? I also know what my password is. Any assitance would be great!

tb -> TextBox where the password is being inputted. I remove all white spaces and trimmed it (in case a user screws up)

Was it helpful?

Solution

Can you try this :

bool validatedOnDomain = pc.ValidateCredentials(userName, tb.Text.ToString().Trim(), ContextOptions.Negotiate); 

You just have to Specifie the options that are used for binding to the server.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top