3.6 Moving an Entry

This section contains information about how to move an entry (changing the parent DN) inside a directory from one container to another using classes provided by Novell.Directory.Ldap namespace. To move an entry, use the Rename function of LdapConnection class, do the following:

  1. Select the new container DN (parentDN) where the entry has to be moved.

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

The C# code fragments below shows how to move 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);

//Moves the entry to new container named parentDN. 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, oldDN,parentDN, true);