Active Directory Authentication, Part 2
After getting some advise about the previous piece of code, I decided to dig deeper, and here is what I have now:
public bool IsValidLogin(string username, string password)
{
ActiveDirectoryMembershipProvider membershipProvider = new ActiveDirectoryMembershipProvider();
NameValueCollection args = new NameValueCollection();
args["connectionStringName"] = connectionStringName;
membershipProvider.Initialize("Extranet", args);
return membershipProvider.ValidateUser(username, password);
}
I would probably want to cache the provider, but this is the easiest way I could find to do it, and if something isn't working, I can blame Microsoft :-). I don't think that I need to worry about thread-safety issues, because providers must be thread-safe anyway.

Comments
Comment preview