验证域用户的问题,高手给指点一下呀,谢谢
我做的一个网站用户登陆是输入域用户名密码来登陆的,我是用DirectoryServices类提供的方法来验证是否合法的域用户,一直验证不成功.原代码如下:其中Bulun是域服务器名 yestem是域名字,我直接传了一个正确的用户名和密码,但一直验证不成功!
public bool CheckDomainUser(string uid, string pwd)
{
bool flag1;
try
{
if (pwd == null || pwd.Trim().Length == 0)
{
return false;
}
//string sPath = "LDAP://DC=yestem,DC=com";
string sPath = "LDAP://Bulun/DC=yestem,DC=com";
DirectoryEntry entry1 = new DirectoryEntry(sPath, uid, pwd, AuthenticationTypes.ServerBind);
object obj1 = System.Runtime.CompilerServices.RuntimeHelpers.GetObjectValue(entry1.NativeObject);
flag1 = true;
}
catch(Exception ex)
{
flag1 = false;
}
return flag1;
} --------------------编程问答-------------------- http://topic.csdn.net/t/20030220/12/1447030.html
http://www.it130.cn/Article/FAQ/.net-jishu/asp.net/2007-2-8/2007020819302900.html --------------------编程问答-------------------- 帮顶 --------------------编程问答-------------------- 不着急,等高手来…… --------------------编程问答-------------------- public bool CheckDomainUser(string uid, string pwd)
{
bool flag1=false;
try
{
if (pwd == null || pwd.Trim().Length == 0)
{
return flag1;
}
System.DirectoryServices.DirectoryEntry ads = new System.DirectoryServices.DirectoryEntry("WinNT://yestem.com", uid, pwd);
try
{
if (ads.Name == "yestem.com")
{
flag1 = true;
}
}
catch (Exception e1)
{
flag1 = true;
}
return flag1;
}
补充:.NET技术 , C#