I have a couple of tables in my database that indicate that witch users (depending on your AD username) can actually use the current ASP.NET MVC 2 application that I create.
My question is how (or, more likely, where and where do I put it? On the main page?) I am writing a method that takes the AD user out of the HTTP context and checks it against the database to see if you can really use Appendix? If you can ... the idea is to write a key pair in a Session object with the information I need (role, full name, etc.).
I am very confused as to how I should do this, and if this is actually the right way ... Keep in mind that I have an admin and non-admin section in my application.
Any thoughts?
Edit: Keep in mind that I do not want to authenticate the user through the form. All I want to check is that according to my database and AD username you can use my application. If you can write to the session to destroy the information I need. Otherwise, simply discard the error page.
This is what I have implemented so far, is this a way to go? What is the second method for? (Iām sorry, Iām kind of new to C #) What I want to do is actually take a look if you are not authorized ...
protected override bool AuthorizeCore(HttpContextBase httpContext) { var isAuthorized = base.AuthorizeCore(httpContext); if (isAuthorized) { var canUse = this._userRepo.CanUserUseApp(httpContext.User.Identity.Name); if (!canUse) { isAuthorized = false; } } return isAuthorized; }
source share