获取新用户的活动目录容器对象
我想在活动目录域中创建一个可以添加新用户的容器对象树。我可以递归访问域并获取目录中的所有内容,但我想将范围限制为仅对用户有效的容器。
LDAP 查询会是什么样子来获取适合用户对象的节点的子节点?有更好的方法吗?
如果您好奇的话,我正在使用 c#、System.DirectoryServices 和 .net 3.5。
谢谢!
I want to create a tree of container objects in an active directory domain that a new user can be added to. I can recurse through the domain and get everything within the directory, but I want to limit my scope to ONLY containers that are valid for users.
What would an LDAP query look like to grab the children of a node that were suitable for a user object? Is there a better way to do this?
I'm using c#, System.DirectoryServices, and .net 3.5 if you are curious.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看优秀的 MSDN 文章在 .NET Framework 3.5 中管理目录安全主体 如果您还没有使用 .NET 3.5 中的
System.DirectoryServices.AccountManagement
中的新功能,请了解如何使用。为了绑定到您的容器,您需要知道它的 LDAP 路径,这样您就可以基于该容器建立一个上下文:
通过此上下文,您现在可以在该上下文中搜索某些类型的主体:
这可行吗为你?这就是您要找的吗?
Check out the excellent MSDN article Managing Directory Security Principals in the .NET Framework 3.5 on how to use the new features in
System.DirectoryServices.AccountManagement
in .NET 3.5, if you haven't already.In order to bind to your container, you need to know it's LDAP path and with this, you can establish a context based on that container:
With this context, you can now e.g. search for certain types of principals in that context:
Does that work for you? Is that what you're looking for?
如果我正确理解您的问题,您想知道的是 Active Directory 中什么样的对象可以包含用户对象。
我想你可以从AD架构分区中得到答案。我快速检查了运行 Windows 2003 AD 的架构分区。允许将User对象分配给OU、容器、builtinDomain和domainDNS >。
我没有检查Windows 2008,但我相信应该是一样的。很多人都知道OU和容器是什么。很少有人知道builtinDomain和domainDNS是什么。我怀疑它对你的情况是否有用。 builtinDomain是一个特殊的容器,用于包含内置帐户。默认情况下,AD 在
CN=Builtin,DC=yourdomain,DC=com
创建了一个 builtinDomain。 domainDNS 是您的根域路径DC=yourdomain,DC=com
。这是一个在特定节点下查找 Active Directory 中所有类型对象的函数。如果您认为 builtinDomain 和 domainDNS 对您的情况没有意义,只需将其从 LDAP 过滤器中取出即可。
If I understand your question correctly, what you want to know is what kind of objects in Active Directory can contain User object.
I think you can get the answer from the AD schema partition. I had a quick check on my schema partition which is running Windows 2003 AD. The User object is allowed to be assigned to OU, container, builtinDomain and domainDNS.
I didn't check Windows 2008 but I believe it should be the same. Many people know what OU and container are. Few people know what builtinDomain and domainDNS are. I doubt if it's useful in your case. builtinDomain is a special container used to contain the built-in account. By default, AD created a builtinDomain at
CN=Builtin,DC=yourdomain,DC=com
. domainDNS is your root domain pathDC=yourdomain,DC=com
.Here is a function to find all kinds of objects in Active Directory under a particular node. If you think builtinDomain and domainDNS is not meaningful in your case, just take it out from the LDAP filter.