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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:10:11+00:00 2026-06-11T02:10:11+00:00

I know that the following function returns the current Windows user’s name in domain\username

  • 0

I know that the following function returns the current Windows user’s name in domain\username format.

Convert.ToString( WindowsIdentity.GetCurrent().Name );

But how do I obtain the user’s name in username@domain format?

EDIT:

I’m responding in this edit as everyone who has replied has the same basic idea.

From what I’ve been given to understand, parsing the name from domain\username format and constructing it as username@domain is not safe or advised. I believe this is so because there is no guarantee that the two domain names are the same in the different formats. For example, in the company where I work, the domain part of the domain\username format is based upon deparment, but in the username@domain, it’s the company name. It’s the kind of thing that requires a DNS lookup.

I was hoping that there was an API that did this DNS lookup. I guess I should have put this information into my original question. Sorry.

  • 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-11T02:10:13+00:00Added an answer on June 11, 2026 at 2:10 am

    All of the code to take the name in Domain\user name format and parse it will not work in all situations. The answer is you have to make calls to Active Directory to get the User Principal Name. It turns out that I can’t rely on Active Directory being installed on the desktop, since many police departments don’t install the directory on their laptops in case it is stolen while a cop is not in the car. (Talk about gutsy, stealing a computer out of a police vehicle!)

    We have come up with our own solution for our situation. We store the user names in our database in Domain\user name format. When the program starts up, it checks to see if the current windows user name (in the same format) is in the database. If it is, the program uses that user as the current user and runs. If the current Windows user is not in our database, the program falls back to our previous code.

    This way, the user can log into the machine using any format for their user name and they authenticate with Windows. Our program always gets the user name in the same format and it always checks the user name in that format. Windows authenticates the user and not us.

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

Sidebar

Related Questions

I get that error with the following code. anyone know why? function validateAdminInput(){ var
Given int a; , I know that the following returns the largest value that
I am writing a function that would take table-name as argument. I know the
I know that the following code should show and hide a tiny circular progress
I know that the following works but it is not that readable, is there
I know that using the following codes will make each column have unique values,
I know that by typing the following: :%s/iwanthis/replacedbythis/g will change all the matching words
I know that if I have the following group of numbers { 0, 1,
Why can I not do something like the following when I know that the
With the following piece of code, how do i know that anything was inserted

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.