3.5 Renaming an Entry

This section contains information about how to rename (or change the RDN) an entry inside a directory using classes provided by Novell.Directory.Ldap namespace. To rename an entry use the Rename function of LdapConnection class.

Renaming an entry involves two steps:

  1. Select the new RDN of the entry.

  2. Specify whether you want to keep the old name as an attribute value or not.

The C# code fragments below shows how to rename an entry using Novell.Directory.Ldap namespace:

Example

// C# Library namespace
using Novell.Directory.Ldap;

// Creating an LdapConnection instance LdapConnection 
ldapConn= new LdapConnection();

//Connect function will create a socket connection to the server
ldapConn.Connect(ldapHost,ldapPort);

//Bind function will bind the user object Credentials to the server
ldapConn.Bind(userDN,userPasswd);

//Renames the entry to newRDN. If third parameter is true it means, the
old name is not retained as an attribute value. If false, the old name is retained as an attribute value.

ldapConn.Rename(oldDN, newRDN, true);