How can I check a user/password combination on an ActiveDirectory without putting the password in a String?

Posted by Jean Hominal on Stack Overflow See other posts from Stack Overflow or by Jean Hominal
Published on 2011-04-05T06:51:39Z Indexed on 2012/10/01 15:38 UTC
Read the original article Hit count: 203

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?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about active-directory