我有一個使用System.DirectoryServices.AccountManagement類的.NET 3.5 Web應用程序。當我搜索一些用戶時,我得到一個PrincipalOperationException:從服務器返回一個引用。如果我使用自己的LDAP代碼實現了舊式的學習方式,那麼我可以啓用追蹤引薦。我是否需要重寫我的代碼?有沒有辦法啓用引用追逐UserPrincipal.FindByIdentity()?
我的代碼如下所示:
using (var principalContext = new PrincipalContext(ContextType.Domain, null, adPath))
{
// Find the principal object for which you wish to enumerate group
// membership.
using (var userPrincipal = UserPrincipal.FindByIdentity(principalContext, identity))
{
if (userPrincipal != null)
{
Name = userPrincipal.DisplayName;
DistinguishedName = userPrincipal.DistinguishedName;
EmailAddress = userPrincipal.EmailAddress;
Sid = userPrincipal.Sid.Value;
}
}
}
我adPath可以在2個值之一。其中一個值是最近加入的域,可以使用不同的工具訪問。我相信這是.NET庫如何進行LDAP調用的問題。
也許您可以至少添加更多標籤[.net-3.5],[windows-server-2008]或[windows-server]。 – JPBlanc 2011-04-07 05:50:37