Java Netscape LDAP 删除一个属性
我有 LDAP 架构,用户在哪里。我需要删除一个名为“notify”的属性,该属性的值是:电话号码或邮件,或者删除用户的属性。我找到了方法
LDAPConnection myCon = new LDAPConnection("localhost",389);
myCon.delete("uid=test1, ou=People, o=domain.com, o=isp");
,但这会删除整个用户,我只需要删除该用户的一个属性“notifyTo”。我需要删除整个属性,而不仅仅是其值。
感谢您的回复
I have LDAP schema where are users. I need remove one attribute named "notify" which have values: phone number or mail or remove attribute from user. I found method
LDAPConnection myCon = new LDAPConnection("localhost",389);
myCon.delete("uid=test1, ou=People, o=domain.com, o=isp");
but this remove whole user and i need remove only one attribute "notifyTo" of this user. I need remove whole attribute not only its value.
Thanks for reply
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要调用 修改 LDAPConnection 类的方法 :-)
从 javadocs:
javadocs 中的示例代码:
此示例用于删除条目属性之一的一个值。您需要删除所有值:-)
You need to call modify method on LDAPConnection class :-)
From the javadocs:
Example code from javadocs:
This sample is for removing one value of one of your entry's attributes. You need to delete all values :-)
没有 Netscape API 的解决方案:
Solution without Netscape API:
老问题但好问题,来自文档(Directory SDK for Java 4.0程序员指南)并补充 SourceRebels 的答案:
Old question but good question, from the docs (Directory SDK for Java 4.0 Programmer's Guide) and complementing SourceRebels' answer:
您可以在 LDAPModificationSet 中将该属性设置为 LDAPModification.DELETE
如果属性为“notifyTo”,
您可以添加、替换或删除用户的任意数量的属性。所有这些都可以在 LDAPModificationSet 中指定要执行的操作。
如果要替换用户的“email”属性,请将其添加到 LDAPModificationSet 中并最后调用modify() 方法。
删除属性时,只需确保该属性已存在于用户 LDAP 条目中,否则调用修改()方法时将抛出 NO_SUCH_ATTRIBUTE(错误代码 16)LDAPException。
You can set that attribute as LDAPModification.DELETE in the LDAPModificationSet
If the attribute is "notifyTo",
You can add, replace or delete any number of attributes from the user. All these can be specified in the LDAPModificationSet actions to be performed.
If you want to replace an attribute "email" for the user, add it to the LDAPModificationSet and call the modify() method in the end.
While deleting an attribute,just make sure that the attribute is already present in the user LDAP entry, otherwise a NO_SUCH_ATTRIBUTE(Error Code 16) LDAPException would be thrown when the modify() method is called.