I am using a default ASP.NET 4.5 framework's ASP.NET MVC 5 project template. It has identity authentication framework configured with it.
I want to use Window's Active Directory with my project, so I followed this article - http://www.schiffhauer.com/mvc-5-and-active-directory-authentication/
And in my AccountController's login method I have
if (Membership.ValidateUser(model.Email, model.Password))
{
CustomFormsAuthentication.SetAuthenticationCookie(model.Email, model, model.RememberMe);
return RedirectToAction("Index", "Home");
}
Where CustomFormsAuthentication class has
public static class CustomFormsAuthentication
{
public static void SetAuthenticationCookie(string username, object obj, bool isPersistent)
{
const int version = 1;
var json = new JavaScriptSerializer().Serialize(obj);
var cookieStoreTime = isPersistent ? DateTime.Now.AddDays(7): DateTime.Now.AddDays(1);
var ticket = new FormsAuthenticationTicket(version, username, DateTime.Now, cookieStoreTime, isPersistent, json);
HttpContext.Current.Response.Cookies.Set(new HttpCookie(FormsAuthentication.FormsCookieName,
FormsAuthentication.Encrypt(ticket)) {Expires = cookieStoreTime});
}
}
But the user is never authenticated. The User.Identity.IsAuthenticated still shows false.
How do I go about this ?