C# Active Directory: Get domain name of user?

前端 未结 4 409
难免孤独
难免孤独 2020-12-02 13:43

I know that this type of question has been asked before, but other methods are failing me right now.

As it stands our windows service polls AD, given an LDAP (i.e. L

4条回答
  •  悲哀的现实
    2020-12-02 13:59

    You can retrieve the name of the domain that the current user is on using the Environment.UserDomainName Property.

    string domainName;
    domainName = System.Environment.UserDomainName;
    

提交回复
热议问题