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