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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:06:52+00:00 2026-06-09T07:06:52+00:00

The following works great on my local development box. However when I move it

  • 0

The following works great on my local development box. However when I move it to the web server it fails and will not even log the error:

public static List<string> getAuthorizationGrps(string userName)
    {
        List<string> grps = new List<string>();

        try
        {
            PrincipalSearchResult<Principal> groups = UserPrincipal.Current.GetGroups();
            IEnumerable<string> groupNames = groups.Select(x => x.SamAccountName);
            foreach (var name in groupNames)
            {
                grps.Add(name.ToString());
            }
            return grps;
        }
        catch (Exception ex)
        {
            Log.WriteLog("Error in retriving form data: " + ex.Message);
        }
    }

Is there permissions that I must set on the webserver to query the groups? I can get the current user with no problem both locally and on the web server.

Any ideas would be greatly appreciated, I have been fighting this for 2 days now.

  • 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-06-09T07:06:53+00:00Added an answer on June 9, 2026 at 7:06 am

    I assume this is your environment

    Web browser --> Web Server --> Domain Controller
    

    Unless you are running the Web Browser and Web Server or Web Server and Domain Controller on the same machine, you need to set up the Kerberos delegation to make the above code work. I am guessing your dev box is working because you are running Web Browser and Web Server on the same machine.

    You can easily find tons of articles teaching you how to configure Kerberos delegation for IIS and ASP.NET from Google. Here is one example. I won’t cover the details here. The point is that your ASP.NET application is impersonating the client credentials and trying to use that client credentials to query Active Directory. If you don’t have
    delegation setup properly, Windows will think that your impersonated credentials cannot access network. In your case, you cannot access Domain Controller. This is a security measure. It’s just to make sure server cannot do things on behalf of the end user on the network unless it’s explicitly granted to have permissions to do that.

    Another solution is to change your code. So, before you call the GetGroups, you undo the impersonation and becomes the IIS AppPool account again. If your AppPool account is configured to be a domain account, which has enough permission to read the Active Directory, then, you can query Active Directory for the groups of the user.

    Here is a blob talking about this. This is the code that I think it should work without any Kerberos delegation setup. I didn’t test it though.

    public static List<string> getAuthorizationGrps(string userName)          
    {          
        List<string> grps = new List<string>();          
    
        try          
        {
            var currentUser = UserPrincipal.Current;
            RevertToSelf();             
            PrincipalSearchResult<Principal> groups = currentUser.GetGroups();          
            IEnumerable<string> groupNames = groups.Select(x => x.SamAccountName);          
            foreach (var name in groupNames)          
            {          
                grps.Add(name.ToString());          
            }          
            return grps;          
        }          
        catch (Exception ex)          
        {          
            Log.WriteLog("Error in retriving form data: " + ex.Message);          
        }          
    }      
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following works great (thanks to gracious assistance by this community!) Function RangeToArrayToRange(inputRange as
I am using the following which works great. I am just wondering if it
I have the following code that works great for row click, but I want
The following bit of code works great in everything but IE. In IE, the
I've implemented the following code on the site I'm working on which works great,
I have the following code running on my Android device. It works great and
I'm trying to execute the following line: exit | sqlplus username/password@sid @test.sql Works great
I'm currently using the following jQuery plugin: jQuery OEmbed. This plugin works great in
I have the following RewriteRule: RewriteRule ^/people/([A-Za-z0-9\-\_]*)/?$ /people/people_details.cfm?person=$1 [I,L] ...it works great for forwarding
I have the following rewrite set up: RewriteRule r/(.*) scripts/report.php?cp=1&id=$1 It works great to

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.