Machine's domain name in .NET?

前端 未结 6 1017
小蘑菇
小蘑菇 2021-02-03 22:47

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,

6条回答
  •  深忆病人
    2021-02-03 23:20

    To get the current domain of the system on which your progam is running you can use System.DirectoryServices.ActiveDirectory.Domain.

    Domain domain = Domain.GetComputerDomain();
    Console.WriteLine( domain.Name );
    

提交回复
热议问题