Last post Jul 24, 2017 03:31 PM by PatriceSc
Jul 22, 2017 05:42 AM|bpdesilva|LINK
I need to authenticate windows users using an Active Directory on a MVC application I found many examples forms authentication which is not my requirement. Basically isn't there a replacement for FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
Forms example : 1 2 3 4
Jul 22, 2017 06:44 AM|asyed4u|LINK
welcome to ASP.net forum
here i attached one of alternate way idea;
//step :1 design your own-view for "LOGIN" page
//step 2: action-method....
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, "yourdomain.yourdomain"))
bool isValid = pc.ValidateCredentials(txtUsername.Text.Trim(), txtPassword.Text.Trim());
//write your logic for "keep the logged user state" ..[cookies / session / form authcation..etc]
//step 3 : webconfig
//in web.config "NONE" as authentication mode OR based on your requirement
Jul 22, 2017 12:05 PM|bpdesilva|LINK
//step 3 : webconfig //in web.config "NONE" as authentication mode OR based on your requirement
I have set it to "Windows" do I require other setting or changes . By the way at the beginning of project template selection I used MVC - Webforms and MVC + Authtication settings on the right hand side to windows.
Jul 24, 2017 10:10 AM|AngelinaJolie|LINK
How to authenticate windows users using an Active Directory (MVC4)
Here is the official article on how to Authenticate Users with Windows Authentication (C#):
And it doesn't need FormsAuthentication.SetAuthCookie to set something .
Then we start focusing identity:
Then get User.Identity.Name or something ;
[Authorize(Roles = "Managers")] public ActionResult Index()
User.Identity.Name // get current user name
Jul 24, 2017 03:31 PM|PatriceSc|LINK
And anonymous authentication is disabled ? Could you clarify what is the current situation?
What if you create a test page that shows AuthenticationType, IsAuthenticated and Name for the current User.Identity.