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 83601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:47:56+00:00 2026-05-10T21:47:56+00:00

I have an application that is using Windows Authentication and a SqlRoleProvider for user

  • 0

I have an application that is using Windows Authentication and a SqlRoleProvider for user authentication and role management respectively. It is working fine with my test users that I have added to the database as defaults. The application requires users to login (using Windows credentials) and then be able to use this internal application as a basic ‘user’. If the user needs to be added to a high level role, an admin would be responsible for this after the first log in.

With that said, how would I add a user to the default role when they first log in? Logically, I know that I would need to call Roles.IsUserInRole() and then add them if they are not; however, where would I do this? I’m having trouble locating which event in the Global.asax to use.

Thanks

EDIT: To expand the scenario a bit, I’m not using a full membership provider system due to requirements on writing new providers to allow the connection string to be stored outside of the web.config. I am not using any form of registration or login page and letting the Windows Integrated Authentication in IIS handle the authentication aspects while my enhanced SqlRoleProvider manages the user roles. The system is working fine for users that I have setup roles via hard coded tests. I am just looking for a way to add new users (who would be authenticated by IIS) to be immediately added to a default ‘Users’ role. I think I found it; however, am now examining ways to make it not fire upon every request for performance reasons.

  • 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. 2026-05-10T21:47:57+00:00Added an answer on May 10, 2026 at 9:47 pm

    I was able to locate the solution after digging and playing around a bit more. I added the following code to my Global.asax file and it is accomplishing what I am hoping for.

    protected void WindowsAuthentication_OnAuthenticate(object sender, WindowsAuthenticationEventArgs e) {     if (!Roles.IsUserInRole(e.Identity.Name, 'Users'))     {         Roles.AddUsersToRole(new string[] { e.Identity.Name }, 'Users');     } } 

    I’m concerned since this code fires with every page request. Is there a better way to limit when this occurs? Should I just add this code to the landing page’s page_load event instead of the Global.asax?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 61k
  • Answers 61k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I'm not sure what your definition of BI is or… May 11, 2026 at 9:44 am
  • added an answer This blog post answers your question quite nicely. I won't… May 11, 2026 at 9:43 am
  • added an answer SELECT keyword FROM words JOIN blacklist WHERE keyword LIKE CONCAT(CONCAT('%',… May 11, 2026 at 9:43 am

Related Questions

I have an application that is using Windows Authentication and a SqlRoleProvider for user
I have an winforms application that was built using MVC. The controller is subscribing
I have a solution that is deployed using ClickOnce. It consists of an application,
I have an application that is installed and updated via ClickOnce. The application downloads
I have an application that is causing a lot of headaches. It's a .NET
I have an application that is made up of the following: A central database
I have an application that is built against OpenSceneGraph (2.6.1) and therefore indirectly OpenGL.
I have an application that is sensitive to the directory it gets invoked from
I have an application that is currently running against a 32-bit SQL Server 2005
I have an application that is database intensive. Most of the applications methods are

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.