如何检测,如果我的程序在Active Directory环境中运行?我的、环境、程序、Active

2023-09-08 12:16:43 作者:缄默

我如何检测,如果我的程序在Active Directory环境中运行?

How do I detect if my program runs in an Active Directory environment?

我使用C#和.NET 2.0

I'm using C# and .Net 2.0

推荐答案

尝试获得Environment.UserDomainName并将其与Environment.MachineName。如果这两个是相同的则很可能是该用户不具有域。如果它们不相同,那么用户登录到其必须有一个目录服务器的域

Try getting Environment.UserDomainName and comparing it to Environment.MachineName. If the two are the same then it's likely that the user does not have a domain. If they are not the same then the user is logged into a domain which must have a directory server.