asp.net操作ldap

tyhAaron 2010-11-19 10:15:19
最近有个需求要做单点登录统一身份验证,在网上找了几天资料终于把OpenLdap服务器搭建好了,然后也通过 asp.net访问ldap服务器上的数据了。现在我能获取到数据,问题是我现在想管理这些数据,请问下C#里有方法能直接操作(添删改目录和属性)这些数据吗?
...全文
258 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
tyhAaron 2010-11-22
  • 打赏
  • 举报
回复
跪求高手们。。。。。。。。。。。。。
lowiqloweq 2010-11-19
  • 打赏
  • 举报
回复
[Quote=引用楼主 tyhaaron 的回复:]
最近有个需求要做单点登录统一身份验证,在网上找了几天资料终于把OpenLdap服务器搭建好了,然后也通过 asp.net访问ldap服务器上的数据了。现在我能获取到数据,问题是我现在想管理这些数据,请问下C#里有方法能直接操作(添删改目录和属性)这些数据吗?
[/Quote]

你好,我想问问你是怎样获取数据的?我有修改的代码。
protected void Button2_Click(object sender, EventArgs e)
{
string mobile = TextBox4.Text.Trim();
string mail = TextBox5.Text.Trim();

string dnstr = Session["dnstr"].ToString();
string pwd = Session["pwd"].ToString();
try
{
LdapClient c = new LdapClient("服务器地址", LdapClient.DefaultPort, true, false);
c.ldap_simple_bind_s(dnstr, pwd);
ListDictionary attrval = new ListDictionary();
attrval["objectClass"] = new string[] { "uidObject", "inetOrgPerson" };
attrval["mobile"] =mobile;
attrval["mail"] = mail;
c.ldap_mod_replace(dnstr, attrval);

String str = "<script language=\"jscript\">confirm(\"资料更新成功!\")</script>";
Response.Write(str);

}
catch (ldap_net.Exceptions.LDAPException ee)
{
MessageBox.alert(this.Page, ee.Message);
}
}
以上是更改电话和邮箱的代码。不知对你有没有用。

111,125

社区成员

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

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

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