Hello Everyone,
I have a question regarding windows Identity.
I am using the following code to get the user name of the user which is currently logged in the system
Code:
string pcLoggedInUserName, loggedInuserWithoutDomain = string.Empty;
int indexOfFirstSlash;
pcLoggedInUserName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
indexOfFirstSlash = pcLoggedInUserName.IndexOf('\\');
loggedInuserWithoutDomain = pcLoggedInUserName.Substring(indexOfFirstSlash + 1);
return loggedInuserWithoutDomain;
As you can see I need to get the user name only without the domain name. Right now the WindowsIdentity.GetCurrent().Name returns DOMAIN\\username and I need to get the user name only. I have managed to accomplish that by getting the substring.
My question is this: Does the GetCurrent() function always return the username in the DOMAIN\\username format ( since my logic depends on that) or is it system speciffic?
Thanks in advance
Susan
