文档

Java™ 教程-Java Tutorials 中文版
重命名
Trail: Java Naming and Directory Interface
Lesson: Naming and Directory Operations

重命名

You can rename an object in a context by using Context.rename().

// Rename to Scott S
ctx.rename("cn=Scott Seligman", "cn=Scott S");
Renaming an object

This examplerenames the object that was bound to "cn=Scott Seligman" to "cn=Scott S". After verifying that the object got renamed, the program renames it to its original name ("cn=Scott Seligman"), as follows.

// Rename back to Scott Seligman
ctx.rename("cn=Scott S", "cn=Scott Seligman");

For more examples on renaming of LDAP entries check out the Advanced Topics for LDAP users lesson.


Previous page: Add, Replace or Remove a Binding
Next page: Create and Destroy Subcontexts