java – 使用JNDI添加LDAP条目
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java – 使用JNDI添加LDAP条目,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2621字,纯文字阅读大概需要4分钟。
内容图文
![java – 使用JNDI添加LDAP条目](/upload/InfoBanner/zyjiaocheng/807/fe756df4654245f592f494bee9106dc7.jpg)
我正在尝试使用JNDI向LDAP服务器添加条目.我可以成功读取LDAP服务器中的条目.但是当我尝试添加新条目时,我收到错误.我检查了各种方法,但我失败了.
private String getUserAttribs (String searchAttribValue) throws NamingException{
SearchControls ctls = new SearchControls();
ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
Attributes matchAttrs = new BasicAttributes(true);
matchAttrs.put(new BasicAttribute("uid", searchAttribValue));
NamingEnumeration answer = ctx.search("ou=People,ou=ABCLdapRealm,dc=abcdomain",matchAttrs);
SearchResult item =(SearchResult) answer.next();
// uid userpassword description objectclass wlsmemberof sn cn
return item.toString();
}
这工作正常.
然后我向前迈了一步,试图添加一个条目.代码如下.
public static void bindEntry(DirContext dirContext)throws Exception{
Attributes matchAttrs = new BasicAttributes(true);
// uid userpassword description objectclass wlsmemberof sn cn
matchAttrs.put(new BasicAttribute("uid", "defaultuser"));
matchAttrs.put(new BasicAttribute("userpassword", "password"));
matchAttrs.put(new BasicAttribute("description", "defaultuser"));
matchAttrs.put(new BasicAttribute("cn", "defaultuser"));
matchAttrs.put(new BasicAttribute("sn", "defaultuser"));
matchAttrs.put(new BasicAttribute("objectclass", "top"));
matchAttrs.put(new BasicAttribute("objectclass", "person"));
matchAttrs.put(new BasicAttribute("objectclass", "organizationalPerson"));
matchAttrs.put(new BasicAttribute("objectclass","inetorgperson"));
matchAttrs.put(new BasicAttribute("objectclass", "wlsUser"));
String name="uid=defaultuser";
InitialDirContext iniDirContext = (InitialDirContext)dirContext;
iniDirContext.bind(name,dirContext,matchAttrs);
}
但有了这个,我得到一个例外.
Exception in thread "main" javax.naming.OperationNotSupportedException: [LDAP: error code 53 - Unwilling To Perform]; remaining name 'uid=defaultuser'
我肯定是在违反某些事情.有什么想法吗?
解决方法:
LDAP 53,不愿意执行,通常意味着它所说的.您尝试从LDAP服务器角度执行“非法”操作.
首先猜测,不太可能,你指的是eDirectory吗?如果是这样,添加sn很重要,因为eDirectory的架构中必须在创建时提供Surname值.在这种情况下,您可能会得到稍微不同的错误,更像是608或611错误.
第二个猜测,你是指向Active Directory,在这种情况下,fullName是一个强制属性.但在这种情况下,您通常会得到一个略微不同的结果代码.应该在错误中有更多. (虽然这可能是JNDI的回归,而不是我使用的工具).
第三个猜测,你指的是别人的LDAP服务器,你错过了架构中的强制属性.
实际上,也许它是一个对象类问题. wlsUser是辅助类还是真正的类?在你的目录中,inetorgperson是真实的(我正在为这类类的名称消隐,有aux,structural和其他东西)类吗?
我的基本猜测是你错过了一个强制属性并且违反了目标目录中的模式,我希望上面列出的缺少强制性的可能示例是有帮助的.
内容总结
以上是互联网集市为您收集整理的java – 使用JNDI添加LDAP条目全部内容,希望文章能够帮你解决java – 使用JNDI添加LDAP条目所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。