Instead of WindowsIdentity.GetCurrent().Name to get {Domain}\{User}.
Is there other way to get the domain name?
Printable View
Instead of WindowsIdentity.GetCurrent().Name to get {Domain}\{User}.
Is there other way to get the domain name?
Code:Environment.UserDomainName
I would recommend to extract it from the Name property of WindowsIdentity object
Code:System.Security.Principal.WindowsIdentity.GetCurrent().Name
boudino, could you explain a little more? Thanks.
I should explain a little about this problem.
If the user log into windows using a local account. WindowsIdentity.GetCurrent().Name will get {computer name}\{User}.
If the computer name is setup longer than 15 chars. The Netbios name got truncated to the first 15 chars. Comparing the non-truncated computer name to the truncated computer name, I cannot tell they are actually the same name. But I just found out I can use Environment.MachineName, which returns the Netbios name accordingly.
If the user is logged in domain, the part before "\" is name of the domain. If he is loged localy, the computer makes its own domain. But I don't know much about NetBIOS, so sorry, but I cannot help you.
WHOAMI (W2K8 Server - Domain)
WHOAMI (XP Media Center)Quote:
text\administrator
Not sure why one is capitalized.Quote:
MEDIA05HP\David