#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上缺少什么东西?什么服务?或者要装什么服务啊??
求救 。。

解决方案 »

  1.   

    我原来也有个项目,
    在2000和2000server上没问题
    但是在xp和2003上就不行。
    我研究了好多天,
    我们最后解决的办法就是:
    重装系统......
    你的问题我不太清楚,看有没有人知道。
      

  2.   

    这个问题我也遇到过,最后不知道怎么就搞好了.
    我下载安装了很多2003的一些补丁和差件.
    把两个系统的IIS调整的一模一样.
      

  3.   

    我们的WEB服务器不可能让我吓整活的啊。哎。。顶啊。
      

  4.   

    jacky125() 你是不是在2000上打2003的补丁和插件哇???具体是哪些啊!
    刚刚得到老大回复,WEB服务器不会把2000升级到2003的。
    哎。。我怎么就这么命哭啊!~~~~~~
    我WEB服务器的访问权限也没的。
      

  5.   

    谢谢 liuredstar(Flying) 哇,你是大好人。