Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# LdapConnection与DirectoryEntry_C#_Active Directory_Directoryentry - Fatal编程技术网

C# LdapConnection与DirectoryEntry

C# LdapConnection与DirectoryEntry,c#,active-directory,directoryentry,C#,Active Directory,Directoryentry,有人能解释一下在ActiveDirectory中使用LdapConnection/SearchRequest和DirectoryEntry/DirectorySearcher搜索用户之间的区别吗 哪一个最适合与AD交互?在大多数情况下,您应该使用DirectoryEntry/DirectorySearcher(System.DirectoryServices或S.DS)与AD交互。它允许您用更少的代码更轻松地完成任务。但是对于LdapConnection/SearchRequest(System

有人能解释一下在ActiveDirectory中使用LdapConnection/SearchRequest和DirectoryEntry/DirectorySearcher搜索用户之间的区别吗


哪一个最适合与AD交互?

在大多数情况下,您应该使用DirectoryEntry/DirectorySearcher(System.DirectoryServices或S.DS)与AD交互。它允许您用更少的代码更轻松地完成任务。但是对于LdapConnection/SearchRequest(System.DirectoryServices.Protocols或S.DS.P),它提供了更多的控制,因为它提供了较低级别的LDAP访问。对于与LDAP兼容的目录而不是AD,最好使用s.DS.P

使用S.DS.p,一般来说,与S.DS相比,您需要编写更多的代码来实现相同的功能

例如,对于S.DS.p中的分页搜索,您需要处理每一页结果的请求和响应。但是在S.DS中,您只需要设置DirectorySearcher.PageSize,然后从DirectorySearcher.FindAll()获得所有页面中的所有结果


有些东西你必须使用S.DS.p,比如幻影根搜索或者你想手动处理“更多数据可用”。但这些情况并不常见,至少在我从事S.DS编码的岁月中不需要。

这是个好问题。我一直使用DirectoryEntry for AD和LdapConnection for generic Ldap解决方案,但我从未对它们进行过比较。@empi Hi我需要你的帮助,你能帮忙吗?LdapConnection与DirectoryEntry