gpt4 book ai didi

c# - 从 C# 访问 AD 时出现 "A referral was returned from the server"异常

转载 作者:IT王子 更新时间:2023-10-29 04:37:23 26 4
gpt4 key购买 nike

DirectoryEntry oDE = new DirectoryEntry("LDAP://DC=Test1,DC=Test2,DC=gov,DC=lk");

using (DirectorySearcher ds = new DirectorySearcher(oDE))
{
ds.PropertiesToLoad.Add("name");
ds.PropertiesToLoad.Add("userPrincipalName");

ds.Filter = "(&(objectClass=user))";

SearchResultCollection results = ds.FindAll();

foreach (SearchResult result in results)
{
Console.WriteLine("{0} - {1}",
result.Properties["name"][0].ToString(),
result.Properties["userPrincipalName"][0].ToString());
}
}

SearchResultCollection results = ds.FindAll(); 行我得到一个异常:

A referral was returned from the server

为什么会出现该异常,这意味着什么?

最佳答案

可能您提供的路径不正确。检查一下。

我会推荐这篇文章 Howto: (Almost) Everything In Active Directory via C#这在过去确实帮助了我处理 AD。

关于c# - 从 C# 访问 AD 时出现 "A referral was returned from the server"异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6954170/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com