活动目录,求救!

LiJun12112003 2006-09-25 11:27:49
private string ADPath = "LDAP://61.153.24.235/CN=Users;DC=DomainName";

DirectoryEntry entry = new DirectoryEntry(ADPath, userName, password, AuthenticationTypes.None);

ADPath 怎么设置?后面的CN,DC具体填写什么值?
...全文
302 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangwei155 2006-09-25
  • 打赏
  • 举报
回复
学习
Knight94 2006-09-25
  • 打赏
  • 举报
回复
参看别人写的例子
http://www.codeproject.com/dotnet/activedirquery.asp
http://www.codeproject.com/dotnet/ActiveDONavigator.asp
http://www.codeproject.com/info/search.asp?cats=3&cats=5&cats=6&searchkw=active+directory&Submit1=Search&author=&sd=15+Nov+1999&ed=24+Sep+2006
myminimouse 2006-09-25
  • 打赏
  • 举报
回复
假设你的域是a.b,而你的域管理器里有一个组织单位是c
那string strPath = "LDAP://OU=c,DC=a,DC=b";
这样写就可以了
cangwu_lee 2006-09-25
  • 打赏
  • 举报
回复
路过 学习了
LiJun12112003 2006-09-25
  • 打赏
  • 举报
回复
ad服务器的地址就是这个阿
ralpha08 2006-09-25
  • 打赏
  • 举报
回复
LDAP://你的服务器地址
LiJun12112003 2006-09-25
  • 打赏
  • 举报
回复
提示 :"该服务器不可操作。"
ralpha08 2006-09-25
  • 打赏
  • 举报
回复
LDAP://61.153.24.235
LiJun12112003 2006-09-25
  • 打赏
  • 举报
回复

string LDAPPath= System.Configuration.ConfigurationSettings.AppSettings["LDAPPath"];

webConfig里面怎么写?
ralpha08 2006-09-25
  • 打赏
  • 举报
回复
private static string CheckLoginReturnUID(string username, string userpwd)

{

username= username.Trim();

userpwd = userpwd.Trim();



string Result= "";

bool isValid= false;

string LDAPPath= System.Configuration.ConfigurationSettings.AppSettings["LDAPPath"];



// 查询域用户

DirectoryEntry entry = new DirectoryEntry(LDAPPath, username, userpwd);

try

{

// 绑定到本机 AdsObject 以强制身份验证。

DirectorySearcher search = new DirectorySearcher(entry);

search.Filter = "(SAMAccountName=" + username + ")";

search.PropertiesToLoad.Add("cn");

SearchResult sr = search.FindOne();

isValid= (sr!=null);

}

catch (System.Runtime.InteropServices.COMException e)

{

// "用户名密码错误,登录失败。";

e.HelpLink= "about:blank";

}



if (isValid)

{

// 读取并保存EHR数据

SaveEHRData(@"ap\"+username,null,null);

// 取域用户用户的ID

string strSql= TSonyDB.sqlFormat("select user_id from v_ADUser where user_name=#s", @"ap\"+username);

TSonyDB DB_User= new TSonyDB(strSql);

Result= DB_User["user_id"];

}

else

{

// 验证数据库用户,并取ID

string strSql= TSonyDB.sqlFormat("select user_id from userinfo where user_name=#s and user_pwd=#s", username, userpwd);

TSonyDB DB_User= new TSonyDB(strSql);

isValid= !DB_User.EOF;

if (isValid)

Result= DB_User["user_id"];

}



// 返回结果

return Result;

}

LiJun12112003 2006-09-25
  • 打赏
  • 举报
回复
如果我想在整个域中通过用户名和密码查找是否存在这个用户(验证)应该怎么写呢?

111,125

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧