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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:30:17+00:00 2026-06-01T03:30:17+00:00

Ok, so this was working in my VS test server (naturally), but as soon

  • 0

Ok, so this was working in my VS test server (naturally), but as soon as I publish to IIS, it breaks. What I need for this to work is to be able to get ahold of the GUID (not the SID, please) of the user currenctly logged into the machine. Using DirectoryServices, this was my original implementation:

var guid = UserPrincipal.Current.Guid.ToString();

This is giving me an error that I cannot cast from GroupPrincipal to UserPrincipal. So it sounds like the application is trying to run as a some authenticated group or something. I realize, the normal approach would be something like HttpContext.Current.User.Identity, but I’m not sure what to do with that as it has no Guid property and when I try to convert it to a SID and run an LDAP query, it throws an exception. Can someone help me with the necessary steps to achieve this?

Thanks

UPDATE:
Okay here’s my most current attempt:

protected string GetUserGuid()
    {
        var pc = new PrincipalContext(ContextType.Domain);
        var windowsID = HttpContext.Current.User.Identity;
        var up = UserPrincipal.FindByIdentity(pc, windowsID.Name);
        return up.Guid.ToString();
    }

And the exception I get:

[COMException (0x8007054b): The specified domain either does not exist
or could not be contacted. ]
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +788
System.DirectoryServices.DirectoryEntry.Bind() +44
System.DirectoryServices.DirectoryEntry.get_AdsObject() +42
System.DirectoryServices.PropertyValueCollection.PopulateList() +29
System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry
entry, String propertyName) +63
System.DirectoryServices.PropertyCollection.get_Item(String
propertyName) +163
System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInitNoContainer()
+436 System.DirectoryServices.AccountManagement.PrincipalContext.DoDomainInit()
+51 System.DirectoryServices.AccountManagement.PrincipalContext.Initialize()
+141 System.DirectoryServices.AccountManagement.PrincipalContext.get_QueryCtx()
+42 System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(PrincipalContext
context, Type principalType, Nullable`1 identityType, String
identityValue, DateTime refDate) +29
System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(PrincipalContext
context, String identityValue) +95 TicketsToMe.GetUserGuid() +123
TicketsToMe.Page_Load(Object sender, EventArgs e) +38
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object
o, Object t, EventArgs e) +25 System.Web.UI.Control.LoadRecursive()
+71 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+3048

  • 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-01T03:30:18+00:00Added an answer on June 1, 2026 at 3:30 am

    If something runs locally but not on IIS it can be a permission thing. Have you checked trust level on your IIS? Local VS test server runs on Full trust but IIS (especially 7) website may be set to Medium or lower. This has caused me problems before with similar results i.e. something running locally but not on IIS.

    Also it is worth checking permissions for app pool user.

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

Sidebar

Related Questions

In test server it is working. But production gives this traceback: what different? And
Even using the default test code on my app I can't get this working.
I have added some animation using jquery but it's not working: $('.test-container').click(function(){ $(this).css('background-color', 'rgb(119,
I've had this working for months but I had a power cycle today and
Strangely I had this working before but I reinstalled my system, upgraded to w7
I currently have this working but it requires me to have a static method
I've been working to get our site moved to a public beta server, and
I have installed CakePHP in my test server and it is working fine. When
I need to know of a solution to run a local test server through
I need to get a local setup of Java working so I can start

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.