【发布时间】:2011-12-21 13:19:17
【问题描述】:
我正在从活动目录访问用户信息。我的代码在我的本地 PC 上运行良好(有 windows xp,不在域上)。代码是
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "domainName", "ActiveDirectoryID", "Password");
UserPrincipal qbeUser = new UserPrincipal(ctx);
PrincipalSearcher srch = new PrincipalSearcher(qbeUser);
qbeUser.SamAccountName = "AnyOther_AD_ID"; //To get any one's info
foreach (var found in srch.FindAll())
{
UserPrincipal foundUser = found as UserPrincipal;
if (foundUser != null)
{
emailAddress = foundUser.EmailAddress;
}
}
但是当我将我的应用程序部署到服务器 pc(Windows 服务器 2003,在域上)时。它给出了错误“身份验证机制未知”。 让我印象深刻的问题是服务器,在域上无法访问 AD 信息,但我的本地电脑,不在域上可以访问 AD 信息(我得到了 AD_Id 和密码)。
【问题讨论】:
-
我正在使用 windows 身份验证并在 web.config 文件中将 impersonate 设置为 true。
标签: .net authentication active-directory asp.net-membership account-management