Moving Directory Objects
To move objects to a new container, use the MoveTo method.
The following example shows how to use MoveTo to move a user object.
try { // Bind to the object to be moved. DirectoryEntry NewUser = new DirectoryEntry("LDAP://CN=User Name,OU=Sales,DC=fabrikam,DC=com"); // Use the MoveTo property to define the new container you want to move the object to. NewUser.MoveTo( new DirectoryEntry("LDAP://OU=HR,DC=fabrikam,DC=com")); } catch (InvalidOperationException InvOpEx) { // Handle InvalidOperationException. Console.WriteLine(InvOpEx.Message); } catch (COMException COMEx) { // Handle COMException. // For more information about handling COM exceptions, see Handling Errors. Console.WriteLine(COMEx.Message); }