I know that the following function returns the current Windows username in the format domain \ username.
Convert.ToString( WindowsIdentity.GetCurrent().Name );
But how do I get a username in the format username@domain ?
EDIT:
I am responding to this edit as everyone who answered has the same basic idea.
From what I was given to understand, parsing a name from the domain\username format and creating it as username@domain unsafe or not recommended. I believe this is because there is no guarantee that the two domain names are the same in different formats. For example, in the company where I work, part of the domain format domain\username based on cancellation, but in username@domain this is the name of the company. This is what requires a DNS lookup.
I was hoping there was an API that performed this DNS lookup. I think I should have put this information in my original question. Unfortunately.
security c # windows active-directory windows-identity
Tony vitabile
source share