Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4256902
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:25:05+00:00 2026-05-21T05:25:05+00:00

I have a couple of table on my database that specify witch users (

  • 0

I have a couple of table on my database that specify witch users ( Depending on your AD Username) can actually use the current ASP.NET MVC 2 app I’m building.

My question is how ( or more likely where and where do I put it? On the master page?? ) do i write a method that gets the AD user out of the HTTP context and validates it against the database to see if you can actually use the app? If you can… the idea it’s to write a couple of keys in the Session object with the information I need ( Role, Full Name, etc ).

I’m quite confused regarding how I should accomplish this and if it’s actually the right way… Keep in mind that I have an admin section and non-admin section in my app.

Any thoughts?

Edit: Keep in mind that I do not care to authenticate the user through a form. All I want to check is if according to my database and your AD username you can use my app. If you can write to session in order to perish the information I need. Otherwise just throw an error page.

This is what I’ve implemented so far, is this the way to go?
What’s the second method for? ( I’m sorry I’m kind of new to c#) What I want to do it’s actually throw a view if yo’re 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;
} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T05:25:06+00:00Added an answer on May 21, 2026 at 5:25 am

    You could activate and use Windows (NTLM) authentication and then write a custom [Authorize] attribute where you could fetch the currently connected AD user and perform the additional check of whether he is authorized or not to use the application against your data store. Then you would decorate controllers/actions that require authorization with this custom attribute.


    UPDATE:

    Here’s an example of how such custom attribute might look like:

    public class MyAuthorizeAttribute : AuthorizeAttribute
    {
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            var isAuthorized = base.AuthorizeCore(httpContext);
            if (isAuthorized)
            {
                // The user is authorized so far => check his credentials against
                // the custom data store 
                return IsUserAllowedAccess(httpContext.User.Identity.Name);
            }
            return isAuthorized;
        }
    
        private bool IsUserAllowedAccess(string username)
        {
            throw new NotImplementedException();
        }
    }
    

    and then:

    [MyAuthorize]
    public class FooController: Controller
    {
        public ActionResult Index()
        {
            ...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL database table with a couple thousand rows. The table is
I have a couple of triggers on a table that I want to keep
I have a couple of tables in my database, one called Task , and
I have a SQL Server 2000 database with around a couple of hundred tables.
I have a couple of mdb files with the exact table structure. I have
I have a couple of tables in a SQL 2008 server that I need
I have a couple of tables which are used to log user activity for
I'll have couple of python functions I must interface with from the assembly code.
I have a couple of questions regarding VBScript and ASP Classic: What is the
I have a couple of files containing a value in each line. EDIT :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.