MVC & Windows Authentication
Posted
by TJ
on Geeks with Blogs
See other posts from Geeks with Blogs
or by TJ
Published on Wed, 16 Jun 2010 22:13:15 GMT
Indexed on
2010/06/16
23:32 UTC
Read the original article
Hit count: 334
Changed the ValidateUser function
public bool ValidateUser(string userName, string password)
{
bool validation;
try
{
LdapConnection ldc = new LdapConnection(new LdapDirectoryIdentifier((string)null, false, false));
NetworkCredential nc = new NetworkCredential(userName, password, "domainname.com");
ldc.Credential = nc;
ldc.AuthType = AuthType.Negotiate;
ldc.Bind(nc); // user has authenticated at this point, as the credentials were used to login to the dc.
string myvar = ldc.SessionOptions.DomainName;
validation = true;
}
catch (LdapException)
{
validation = false;
}
return validation;
}
© Geeks with Blogs or respective owner