2

我正在从活动目录访问用户信息。我的代码在我的本地 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 server 2003,在域上)。它给出了错误“身份验证机制未知”。让我印象深刻的问题是服务器,即域上的服务器无法访问 AD 信息,但我的本地电脑,不在域上可以访问 AD 信息(我得到了 AD_Id 和密码)。

4

1 回答 1

0

尝试为用户主体或搜索者提供登录凭据。我以前也经历过同样的事情,如果我为我的 AD 连接提供了用户名和密码,它就会起作用。

于 2011-12-21T14:38:33.787 回答