#region LoginByAccount(string userName, string passWord)判断用户帐号与密码是否足够以满足身份验证进而登录
/// <summary>
/// 登陆、判断用户帐号与密码是否足够以满足身份验证进而登录
/// </summary>
/// <param name="sAMAccountName">用户帐号</param>
/// <param name="password">密码</param>
/// <returns>如能可正常登录,则返回 true;否则返回 false</returns>
public LoginResult LoginByAccount(string userName, string passWord)
{
try
{
DirectoryEntry entry = new DirectoryEntry(ADPath, userName, passWord, AuthenticationTypes.Secure);
DirectorySearcher mySearcher = new DirectorySearcher(entry);
ADHelperClass.mySearcher=mySearcher;
mySearcher.Filter = "(sAMAccountname="+userName+")";
SearchResult resEnt= mySearcher.FindOne();
int userAccountControl = Convert.ToInt32(resEnt.Properties["userAccountControl"][0]);
entry.Close();
if (!IsAccountActive(userAccountControl))
{
return LoginResult.LOGIN_USER_ACCOUNT_INACTIVE;// 必须在判断用户密码正确前,对帐号激活属性进行判断;否则将出现异常。
}
else
{
this.Department=resEnt.Properties["Department"][0].ToString();
this.Company=resEnt.Properties["Company"][0].ToString();
this.Name=resEnt.Properties["cn"][0].ToString();
this.Title=resEnt.Properties["Title"][0].ToString();
this.Mail=resEnt.Properties["Mail"][0].ToString();
this.ADUser=resEnt.Properties["samaccountname"][0].ToString();
this.ManagerADPath=resEnt.Properties["manager"][0].ToString();
return LoginResult.LOGIN_USER_OK;
}
#region 循环得到所有的属性值
/*foreach (string propertyName in resEnt.Properties.PropertyNames )
{
string oneNode = propertyName + ": " +
resEnt.Properties[propertyName][0].ToString()+"\n";
//this.TextBox1.Text=this.TextBox1.Text+oneNode;
}*/
#endregion
}
catch
{
return LoginResult.LOGIN_USER_DOESNT_EXIST_OR_PASSWORD_INCORRECT;
}
}
#endregion 这些代码在windows2003上运行一切都正常的,但是在windows2000的系统上就出现问题了,得不到活动目录服务的信息,因为,我们的WEB服务器是windows2000的,这个是为什么啊?是不是2000上缺少什么东西?什么服务?或者要装什么服务啊??
求救 。。
/// <summary>
/// 登陆、判断用户帐号与密码是否足够以满足身份验证进而登录
/// </summary>
/// <param name="sAMAccountName">用户帐号</param>
/// <param name="password">密码</param>
/// <returns>如能可正常登录,则返回 true;否则返回 false</returns>
public LoginResult LoginByAccount(string userName, string passWord)
{
try
{
DirectoryEntry entry = new DirectoryEntry(ADPath, userName, passWord, AuthenticationTypes.Secure);
DirectorySearcher mySearcher = new DirectorySearcher(entry);
ADHelperClass.mySearcher=mySearcher;
mySearcher.Filter = "(sAMAccountname="+userName+")";
SearchResult resEnt= mySearcher.FindOne();
int userAccountControl = Convert.ToInt32(resEnt.Properties["userAccountControl"][0]);
entry.Close();
if (!IsAccountActive(userAccountControl))
{
return LoginResult.LOGIN_USER_ACCOUNT_INACTIVE;// 必须在判断用户密码正确前,对帐号激活属性进行判断;否则将出现异常。
}
else
{
this.Department=resEnt.Properties["Department"][0].ToString();
this.Company=resEnt.Properties["Company"][0].ToString();
this.Name=resEnt.Properties["cn"][0].ToString();
this.Title=resEnt.Properties["Title"][0].ToString();
this.Mail=resEnt.Properties["Mail"][0].ToString();
this.ADUser=resEnt.Properties["samaccountname"][0].ToString();
this.ManagerADPath=resEnt.Properties["manager"][0].ToString();
return LoginResult.LOGIN_USER_OK;
}
#region 循环得到所有的属性值
/*foreach (string propertyName in resEnt.Properties.PropertyNames )
{
string oneNode = propertyName + ": " +
resEnt.Properties[propertyName][0].ToString()+"\n";
//this.TextBox1.Text=this.TextBox1.Text+oneNode;
}*/
#endregion
}
catch
{
return LoginResult.LOGIN_USER_DOESNT_EXIST_OR_PASSWORD_INCORRECT;
}
}
#endregion 这些代码在windows2003上运行一切都正常的,但是在windows2000的系统上就出现问题了,得不到活动目录服务的信息,因为,我们的WEB服务器是windows2000的,这个是为什么啊?是不是2000上缺少什么东西?什么服务?或者要装什么服务啊??
求救 。。
解决方案 »
- 未能加载文件或程序集“DLL”或它的某一个依赖项。生成此程序集的运行时比当前加载的运行时新,无法加载此程序集
- datagrid 模板列取值问题
- 做泛域名,blog.123.com/aaa blog.123.com/bbb 无法访问,本地可以,服务器DNS解析也支持泛解析,什么原因啊?
- ASP.net数据库 连接出错
- <%#与<%=有什么区别?怎么使用?
- 获取网页中URL.速度........
- 页面用到FCKeditorV2, 可post后,获取不了fckeditor的值
- 问个freetextbox的问题,大家来帮忙看看
- 高手请进.....一个类似于购物车的问题...谢谢....
- 怎样在DATALIST的绑定项事件发生时,获得绑定项信息!
- 孟子啊,思归啊,救救我吧。关于AD问题。和发送邮件的问题。。再次发贴。100分 高手进。。。。
- 一个非常奇怪的问题,本地一切正常,上传后点击按钮不响应
在2000和2000server上没问题
但是在xp和2003上就不行。
我研究了好多天,
我们最后解决的办法就是:
重装系统......
你的问题我不太清楚,看有没有人知道。
我下载安装了很多2003的一些补丁和差件.
把两个系统的IIS调整的一模一样.
刚刚得到老大回复,WEB服务器不会把2000升级到2003的。
哎。。我怎么就这么命哭啊!~~~~~~
我WEB服务器的访问权限也没的。