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

  • SEARCH
  • Home
  • 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 4621038
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:38:35+00:00 2026-05-22T02:38:35+00:00

I am trying to implement windows authentication in my ASP.NET MVC2 application. I’ve followed

  • 0

I am trying to implement windows authentication in my ASP.NET MVC2 application.
I’ve followed all the steps suggested by the official documentation:

<authentication mode="Windows" />

<authorization>
  <deny users="?" />
</authorization>

I’ve specified NTLM Authentication. So far so good. Everything works fine.
I would like to check the users logged-in against my database.
I would like to fetch roles from my table and then manage the authorization using a custom attribute.
I don’t want to use membership and roles provider.
I’already have my tables Users/Roles in place cause they’ve been used for an Internet App (this is the Intranet App).

In my Internet App I had a form where the user inputs the data. The form is posted to a controller which checks everything and creates a cookie with the user (and roles) of the logged-in user.

In my global.asax I’ve trapped the AuthenticateRequest event where I read the cookie and create a custom principal which I use all over the app to check the authorizations.

How can I do implement this with Windows Authentication?

  • 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-22T02:38:36+00:00Added an answer on May 22, 2026 at 2:38 am

    Just create a new principal and assign it to the user and thread in Global.asax (or use an action filter).

    protected void Application_AuthenticateRequest(object sender, EventArgs args)
    {
      if(HttpContext.Current != null)
      {
         String [] roles = GetRolesFromSomeDataTable(HttpContext.Current.User.Identity.Name);
    
         GenericPrincipal principal = new GenericPrincipal(HttpContext.Current.User.Identity, roles);
    
         Thread.CurrentPrincipal = HttpContext.Current.User = principal;
      }
    }
    

    If a user doesn’t have any role that matches, they can be barred from the app using the web.config authoirzation element:

    <authorization>
      <allow roles="blah,whatever"/>
      <deny users="*"/>               
    </authorization>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to figure out how to implement an ASP.NET page with Windows
I'm trying to implement a Load / Save function for a Windows Forms application.
I'm trying to implement a basic Health/Stamina/Mana readout in a Windows Forms application, and
I'm trying to implement authentication with Devise in my Rails application (Rails 2.3.8, Devise
I am trying to implement application that is supported to android,iphone,blackberry,windows mobile,symbian, webos (palm).
I'm trying to implement binding validation using Silverlight on Windows Phone, but all I
All I am currently trying implement something along the lines of dim l_stuff as
trying to implement a dialog-box style behaviour using a separate div section with all
We are trying to implement a REST API for an application we have now.
I am trying to implement in windows scripting host the same function as windows

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.