I need find out that my windows currentuser is domain user or local user?
I get My CurrentPrincipal with this:
System.Threading.Thread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Normally the windows NON domain user doesn’t have a UPN name. Like below If I fire WHOAMI with /upn:
Based on this using below code we can find whether the user is domain user or not.
The other lengthy way would be to get the user name in SAM format. Then using DirectoryEntry, DirectorySearcher and other AD API’s iterate through all the joined domain of the machine and find if the user is in any of the domain we iterate.
Find all domains of the machine ex1 and ex2
Here is How to get domain user information from Active Directory in C#