There is even a more simple method provided to you by the Windows API using advapi32.dll .
Example:
[DllImport("advapi32.dll", EntryPoint = "LogonUserW", SetLastError = true, CharSet = CharSet.Auto)]
public static extern bool LogOnUser(string lpszUserName, string lpszDomain, string lpszPassword,
int dwLogOnType, int dwLogOnProvider, ref IntPtr phToken);
this method returns simply true or false if the user is indeed in the domain and has entered its Password correctly.
Then you just make your own sign in method checking authentication against advapi32.dll .
public ActionResult SignIn(SignInModel model)
{
string domainName = CheckSignIn.GetDomainName(model.User.UserName);
string userName = CheckSignIn.GetUserName(model.User.UserName);
IntPtr token = IntPtr.Zero;
bool result = CheckSignIn.LogOnUser(userName, domainName, model.User.UniqueUserCode, 2, 0, ref token);
if (result)
{
if (!string.IsNullOrEmpty(Request.QueryString["ReturnUrl"]) && Request.QueryString["ReturnUrl"] != "/")
{
FormsAuthentication.RedirectFromLoginPage(model.User.UserName, false);
}
else
{
FormsAuthentication.SetAuthCookie(model.User.UserName, false);
return RedirectToAction("MyVoyages", "Voyage");
}
}
return SignIn(true);
}
simple, yet powerfull.