so the following code is supposed to move an object in active directory. I see what is going on here but i dont quite understand it. all i see is the old location and new location. I dont see how I actually grab the object. I have several objects in both locations, where does this code say what specific object is to be moved? I dont see where in the LDAP + objectLocation string that 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();
Maybe this example will make it clearer:
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);
The overload of MoveTo
with two parameters also specifies a new name for the object, and I think that in your example it's redundant.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With