私は次のコードを使用しています:
private string GetTitle(string userName)
{
string title = string.Empty;
try
{
DirectoryEntry myLdapConnection = createDirectoryEntry();
DirectorySearcher search = new DirectorySearcher(myLdapConnection);
search.ReferralChasing = ReferralChasingOption.All;
search.Filter = "(cn=" + userName + ")";
search.PropertiesToLoad.Add("title");
SearchResult result = search.FindOne();
if (result != null)
{
// create new object from search result
DirectoryEntry entryToUpdate = result.GetDirectoryEntry();
title = entryToUpdate.Properties["title"][0].ToString();
}
else Console.WriteLine("User not found!");
}
catch (Exception e)
{
Console.WriteLine("Exception caught:\n\n" + e.ToString());
}
return title;
}
次のエラーが表示されます。
A referral was returned from the server.
行から:SearchResult result = search.FindOne();
どうすればこれを解決できますか?