How can I check a user/password combination on an ActiveDirectory without putting the password in a String?
- by Jean Hominal
I want to check User/Password combination on a Windows domain. Right now I do it with the following code:
bool Login(String username, String password) {
var principalContext = new PrincipalContext(ContextType.Domain);
principalContext.ValidateCredentials(username, password);
}
While it works, the thing that bugs me is that I have to put the password in a String in order to use that API; as I am using a SecureString to store the password everywhere else, I would really like to use some way of checking the username / password combination without having to pass the password as a managed System.String.
What would be the best way of achieving that?