Moving an object in Active Directory using C #

therefore, the following code should move the object in the active directory. I see what is happening here, but I do not understand this. all i see is the old location and the new location. I do not see how I actually capture an object. I have several objects in both places where this code says which particular object should be moved? I do not see where in the LDAP + objectLocation line there is an object.

DirectoryEntry eLocation = new DirectoryEntry("LDAP://" + objectLocation); DirectoryEntry nLocation = new DirectoryEntry("LDAP://" + newLocation); string newName = eLocation.Name; eLocation.MoveTo(nLocation, newName); nLocation.Close(); eLocation.Close(); 
+4
source share
1 answer

Perhaps this example will be more clear:

 DirectoryEntry theObjectToMove = new DirectoryEntry("LDAP://CN=jdoe,CN=Users,DC=acme,DC=com"); DirectoryEntry theNewParent = new DirectoryEntry("LDAP://OU=Something,DC=acme,DC=com"); theObjectToMove.MoveTo(theNewParent); 

An overload of MoveTo with two parameters also indicates a new name for the object, and I think this is redundant in your example.

+12
source

All Articles