当尝试根据角色从 AD 获取所有用户时,我遇到了异常:
\n\n\n\n\nSystem.DirectoryServices.Protocols.DirectoryOperationException: 超出\n 大小限制
\n
在此线程的帮助下: \n LdapConnection SearchRequest 抛出 \xe2\x80\x9c 的异常超出了大小限制我尝试实现分页。
\n\n现在我遇到了一个例外:
\n\n\n\n\n服务器不支持该控件。控制至关重要。
\n
关于如何解决它有什么想法吗?我无需分页即可获得较小的基于角色的用户列表。\n谢谢。
\n\n更新:\n我在iPlanet LDAP 和 C# PageResultRequestControl中找到了检查 AD 是否支持分页的代码,并且得到了支持分页的结果。
\n我正在尝试在iPlanet LDAP上进行分页搜索.这是我的代码:
LdapConnection ldap = new LdapConnection("foo.bar.com:389");
ldap.AuthType = AuthType.Anonymous;
ldap.SessionOptions.ProtocolVersion = 3;
PageResultRequestControl prc = new PageResultRequestControl(1000);
string[] param = new string[] { "givenName" };
SearchRequest req = new SearchRequest("ou=people,dc=bar,dc=com", "(ou=MyDivision)", SearchScope.Subtree, param);
req.Controls.Add(prc);
while (true)
{
SearchResponse sr = (SearchResponse)ldap.SendRequest(req);
... snip ...
}
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我得到一个异常,指出"服务器不支持控件.控件是关键的"在剪辑之前的行上.快速谷歌搜索没有任何结果.iPlanet是否支持分页?如果是这样,我做错了什么?谢谢.
当用户登录网站时,我正在使用以下代码在Active Directory中查找信息.对本地域运行它非常快,但是通过VPN运行到远程可信域,它非常慢(需要大约7或8秒).将dsa.msc从同一个盒子运行到远程域几乎和在本地运行它一样快.
我正在使用属性过滤来检索可能的最小数据量,因此在这种情况下System.DirectoryServices是否存在某些内在缓慢的问题,或者是否有人对如何提高性能有任何提示?
通过VPN的网络连接很好,只有这个代码运行缓慢.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.DirectoryServices;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
using (var LDAPConnection = new DirectoryEntry("LDAP://domain/dc=domain,dc=com", "username", "password"))
{
LDAPConnection.AuthenticationType = AuthenticationTypes.Secure;
using (DirectorySearcher Searcher = new DirectorySearcher(LDAPConnection))
{
Searcher.Filter = "(&(&(objectclass=user)(objectcategory=person))sAMAccountName=username)";
Searcher.PropertiesToLoad.Add("mail");
SearchResult result = Searcher.FindOne(); //this line takes ages!
string EmailAddress = result.Properties["mail"][0].ToString();
Console.WriteLine(EmailAddress);
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)