我怎样才能获得域名\用户从AD的DirectoryEntry? [英] How can I get DOMAIN\USER from an AD DirectoryEntry?
问题描述
如何获取Windows用户和域从Active Directory的DirectoryEntry(SchemaClassName =用户)的对象?
How can I get the Windows user and domain from an Active Directory DirectoryEntry (SchemaClassName="user") object?
用户名是在sAMAccountName赋属性,但我在哪里可以查找域名?
The user name is in the sAMAccountName property but where can I look up the domain name?
(我不能假设一个固定的域名,因为用户从不同的子域。)
(I can't assume a fixed domain name because the users are from various subdomains.)
推荐答案
我发现了一个分区容器CN =分区,CN =配置,其中包含的所有域。
I found a partitions container in CN=Partitions,CN=Configuration that contains all domains.
在用户匹配的partion您可以从NETBIOSNAME +\+ sAMAccountName赋属性。
When you match the user to the partion you can read the real domain name from the nETBIOSName+"\"+sAMAccountName property.
这篇关于我怎样才能获得域名\用户从AD的DirectoryEntry?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!