Thursday, August 20, 2020

C# - How to get active domain name

Domain domain;
try {
  domain = Domain.GetCurrentDomain();
  Console.WriteLine( domain.Name );
}
catch ( ActiveDirectoryOperationException e ) {
  Console.WriteLine( "No domain" );
  return;
}
Output:
EU.company.local

No comments:

Post a Comment