2007-01-24
Ldap学习日记 - Add, Edit, Search, Delete entry
关键字: ldap
1. 添加一个新的entry
其中值得注意的是:
a. 在给属性集合添加属性的时候,必须先添加"objectclass"属性,否则会报告 object class vialate 异常。
b. 在使用连接将生成的新entry对象实际加入服务器的时候,必须先使用拥有添加权限的用户authenticate到服务器。
LDAPAttributeSet attributes = new LDAPAttributeSet();
LDAPAttribute attribute = null;
String [] objectClass = {"top", "person", "organizationalPerson", "inetOrgPerson"};
attribute = new LDAPAttribute("objectclass", objectClass);
attributes.add(attribute);
attribute = new LDAPAttribute("uid", user.getUserId());
attributes.add(attribute);
attribute = new LDAPAttribute("userpassword", user.getPassword());
attributes.add(attribute);
Name name = user.getUserInfo().getName();
attribute = new LDAPAttribute("givenname", name.getFirstName());
attributes.add(attribute);
attribute = new LDAPAttribute("sn", name.getLastName());
attributes.add(attribute);
attribute = new LDAPAttribute("cn", name.toString());
attributes.add(attribute);
LDAPConnection conn = LdapUtils.getAuthenedConnection();
conn.add(LdapUtils.getDnForUser(userId), attributes);
其中值得注意的是:
a. 在给属性集合添加属性的时候,必须先添加"objectclass"属性,否则会报告 object class vialate 异常。
b. 在使用连接将生成的新entry对象实际加入服务器的时候,必须先使用拥有添加权限的用户authenticate到服务器。
发表评论
- 浏览: 18848 次
- 性别:

- 来自: 上海

- 详细资料
搜索本博客
链接
最新评论
-
apachet转发请求到tomcat ...
其实不用改tomcat或apache的文件,程序改为: String par ...
-- by xieboxin -
apachet转发请求到tomcat ...
谢谢了我今天才刚解决了, 以前就是奇怪用tomcat好的,用了apache后还 ...
-- by xuxiangpan888 -
apachet转发请求到tomcat ...
很老的问题了,一般实际开发都是这样做的,至少我们用的tomcat5.0.28是这 ...
-- by jhj823900 -
jBPM的Scheduler模块和Sp ...
提示个方法。。用JobExecutorServlet方法来代替你的Schedul ...
-- by gabriel80 -
spring 学习日记 - 基于 ...
ms可以这样 <bean class="org.springframewo ...
-- by sgfgh






评论排行榜