C#LDAP增加一个用户

一、首先创建一个LDAP连接

二、创建一个LdapEntry,首先要创建LdapAttributeSet(一个包括用户所有信息的属性集)

三、将这个LdapAttributeSet添加到LdapEntry中,再执行新增操作


LdapConnection ldapConn=new LdapConnection();

ldapConn.Connect(ldapHost,ldapPort);//这里需要传入LDAP服务器的IP地址和端口号

ldapConn.Bind(userDn,userPwd);//这里需要的是登陆LDAP服务器的用户名和密码


LdapAttributeSet attribute=new LdapAttributeSet();

attributeSet.Add(new LdapAttribute("objectclass","inetOrgPerson"));//这里先添加了一个objectclass属性

attributeSet.Add(new LdapAttribute("cn","dean"));

//当我们准备好一系列的属性后

string dn="cn=dean";

LdapEntry new Entry =new LdapEntry(dn,attributeSet);//将整个属性集添加到LdapEntry中

LdapConn.Add(newEntry);//将LdapEntry添加到LDAP中



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值