|
-
April 29th, 2008, 04:12 PM
#1
Get domain name of current user belongs to?
Instead of WindowsIdentity.GetCurrent().Name to get {Domain}\{User}.
Is there other way to get the domain name?
-
April 29th, 2008, 07:50 PM
#2
Re: Get domain name of current user belongs to?
Code:
Environment.UserDomainName
-
April 30th, 2008, 03:51 AM
#3
Re: Get domain name of current user belongs to?
I would recommend to extract it from the Name property of WindowsIdentity object
Code:
System.Security.Principal.WindowsIdentity.GetCurrent().Name
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post. 
-
April 30th, 2008, 11:42 AM
#4
Re: Get domain name of current user belongs to?
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.
-
May 2nd, 2008, 12:55 PM
#5
Re: Get domain name of current user belongs to?
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.
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post. 
-
May 2nd, 2008, 02:18 PM
#6
Re: Get domain name of current user belongs to?
WHOAMI (W2K8 Server - Domain)
WHOAMI (XP Media Center)
Not sure why one is capitalized.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|