There gotta be an easy way to do this, I can\'t believe there\'s none. I have scanned through net and found, like, 20 different methods to find in which domain current user is,
Using GetCurrentDomain is the same as Environment.UserDomainName, which works incorrectly if your program is running on a domain computer as a non-domain user. I've used the following code:
try
{
return System.DirectoryServices.ActiveDirectory.Domain.GetComputerDomain().Name;
}
catch (Exception)
{
return Environment.UserDomainName;
}