C#和Active Directory:测试OU是否存在

编程入门 行业动态 更新时间:2024-10-28 16:30:31
本文介绍了C#和Active Directory:测试OU是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在使用C#创建Active Directory之前,如何测试Active Directory中是否存在组织单位?

How can i Test if and Organizational Unit Exists in Active Directory before creating it with C# ?

推荐答案

有一个<$您可以使用 DirectoryEntry 上的c $ c> .Exists()方法-假设您具有正确 LDAP OU的路径!

There's a .Exists() method on the DirectoryEntry which you can use - assuming you have the correct LDAP path for your OU!

if (DirectoryEntry.Exists("LDAP://" + objectPath)) { // ...... }

您的主要问题是是:您使用的路径是错误-用户是通用容器,因此需要解决像这样:

Your main problem will be: the path you're using is wrong - the Users is a generic container and thus needs to be addressed like this:

LDAP://192.168.0.1/CN=Users

请注意 CN = 前缀。如果您有实际的组织单位,则必须在其前面加上 OU =

Note the CN= prefix. If you had an actual organizational unit, it would have to be prefixed with OU=

查看方法:(几乎)所有内容活动目录

更多推荐

C#和Active Directory:测试OU是否存在

本文发布于:2023-11-09 03:23:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571263.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:是否存在   测试   Active   Directory   OU

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!