Asp.net 程序登陆 Active Directory 出错
我做了一段登陆公司域的程序,但出先了很难找的错误,在VS2005里开发环境下可以登陆域帐户,但一旦生成网站,并把网站发布出去,就无法登陆域帐户了,开发和发布后都是在同一台机器上,是已经加入域的机器.返回错误信息是
Error authenticating user. 指定的域不存在,或无法联系。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Exception: Error authenticating user. 指定的域不存在,或无法联系。
源错误:
执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。
堆栈跟踪:
[Exception: Error authenticating user. 指定的域不存在,或无法联系。
]
WebexUser.IsAuthenticated(String domain, String username, String pwd) +327
LogIn_Controls.DoaminUserLogIn(String username, String password) +107
LogIn_Controls.Button1_Click(Object sender, EventArgs e) +94
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
那位高人知道原因? --------------------编程问答-------------------- 网站服务器是否可以访问域啊 --------------------编程问答-------------------- 开发和发布后都在一台机器上,在VS2005调试开发环境下可以登陆域,但一发布后就出现上述错误,调试又不能调试,真让我愁死了,
谁能给个思路. --------------------编程问答-------------------- 这台机器是加入域的 --------------------编程问答-------------------- 权限不够,你可以用一有效域用户模拟登陆后再执行你的代码
--------------------编程问答-------------------- asp.net 项设为 2.0 --------------------编程问答-------------------- asp.net是设置为2.0的
开发调试环境下,用我公司的域帐户是可以登陆的,但在同一台机器上,一旦发布到同一台机器的IIS下,就会出项上述错误.
网上有人说是ASPNET这个用户权限不够,我看了,在这台机器上是隶属于User用户组的,没有问题啊 --------------------编程问答-------------------- 可否把关键代码贴出来看看?我们一直通过web进行域用户的管理,没遇到过此情况 --------------------编程问答-------------------- 我用弹出窗体的办法跟踪,发现在WebMsgBox.Show("begin try... !")弹出后出错的,也就是说
object obj = entry.NativeObject;
出错,
domainAndUsername = "a.company.com\\User1"
_path = "LDAP://DC=a,DC=company,DC=com"
public bool IsAuthenticated(string domain, string username, string pwd)
{
WebMsgBox.Show("begin author !");
string domainAndUsername = domain + @"\" + username;
//domainAndUsername = "a.company.com\\User1"
//_path = "LDAP://DC=a,DC=company,DC=com"
DirectoryEntry entry = new DirectoryEntry(_path, domainAndUsername, pwd);
WebMsgBox.Show("begin try... !");
try
{
object obj = entry.NativeObject;
WebMsgBox.Show("begin new a DirectorySearcher... !"); DirectorySearcher search = new DirectorySearcher(entry);
WebMsgBox.Show("finished new a DirectorySearcher... !");
search.Filter = "(SAMAccountName=" + username + ")";
search.PropertiesToLoad.Add("cn");
WebMsgBox.Show("begin search... !");
SearchResult result = search.FindOne();
WebMsgBox.Show("search complete... !");
if (null == result)
{
return false;
}
//Update the new path to the user in the directory.
_path = result.Path;
_filterAttribute = (string)result.Properties["cn"][0];
return true;
}
catch (Exception ex)
{
throw new Exception("Error authenticating user. " + ex.Message);
//
}
--------------------编程问答-------------------- 郁闷死了,调试状态这一行没有问题的 --------------------编程问答-------------------- 呵呵。。如果我没有猜错的话应该是IE的设置出现了问题,在IE的设置上把关于Script和ActiveX有关的东西都设为有效。。估计就 没有问题了。。 --------------------编程问答-------------------- 我刚在FIREFOX里试了一下,也不行,我感觉不应该和IE设置有关系 --------------------编程问答-------------------- --------------------编程问答-------------------- --------------------编程问答-------------------- 权限问题!
在IIS里设置你的Web Application的虚拟目录的安全认证! --------------------编程问答-------------------- 帮你顶起来
补充:.NET技术 , ASP.NET