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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:26:30+00:00 2026-06-02T07:26:30+00:00

When we log into our Windows machines at work, we use CORP\username. Given a

  • 0

When we log into our Windows machines at work, we use “CORP\username”.

Given a user’s SID and the domain controller where they logged in, how do I derive that string? I’m using the DirectoryServices APIs added in .NET 3.5, like this:

PrincipalContext domaincontroller = new PrincipalContext(ContextType.Domain, "192.168.30.115");
UserPrincipal user = UserPrincipal.FindByIdentity(domaincontroller, IdentityType.Sid, "S-1-5-21-293182769-1777760488-2957165303-1798");

I’ve dug around the domaincontroller object and user object, and see lots of stuff like this:

user.Name:              john smith
user.DisplayName:       john smith
user.UserPrincipalName: john.smith@corp.mycompany.com
user.SamAccountName:    john.smith

If I dig deep in the private guts of the UserPrinciple object, I find two fields labelled “domainFlatName” and “FlatDomainName” which contain exactly what I want (screen shot below). What do these mean, and how I can get to them via a public interface?

Object Inspector Screenshot

  • 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-02T07:26:34+00:00Added an answer on June 2, 2026 at 7:26 am

    Getting this value is unfortunately non-trivial. The attribute you want is nETBIOSName which is stored on the crossRef object representing the domain in the configuration NC.

    Given you know the DN of the domain (e.g. fabrikam.com is DC=fabrikam,DC=com), you can do a search of the configuration naming context for (&(objectClass=crossRef)(nCName=DC=fabrikam,DC=com)) and grab the nETBIOSName off of there.

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

Sidebar

Related Questions

Our users log into the production database as a fairly low-level user, with SELECT
Please log into my website using: username: test password: test and then go to
I log into Oracle using my own user account, which we can call my_account
I have a problem with a client, who cannot log in to our system.
I am trying to log into facebook here is my code: <body> <form id=form1
How can I let my users to log into a phpBB forum by entering
I really like Logback's support to log into a DB. However, I'm having trouble
We host online reports that a client will log into and view. The reports
I was wondering if it is possible to log into a site with the
I'm trying to create an app that multiple users would log into a server

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.