[ Team LiB ] |
Recipe 4.19 Renaming an Object4.19.1 ProblemYou want to rename an object and keep it in its current container or OU. 4.19.2 Solution4.19.2.1 Using a graphical user interface
4.19.2.2 Using a command-line interface> dsmove "<ObjectDN>" -newname "<NewName>" 4.19.2.3 Using VBScript' This code renames an object and leaves it in the same location. ' ------ SCRIPT CONFIGURATION ------ strCurrentParentDN = "<CurrentParentDN>" strObjectOldName = "cn=<OldName>" strObjectNewName = "cn=<NewName>" ' ------ END CONFIGURATION --------- set objCont = GetObject("LDAP://" & strCurrentParentDN) objCont.MoveHere "LDAP://" & strObjectOldName & "," & _ strCurrentParentDN, strObjectNewName 4.19.3 DiscussionBefore you rename an object, ensure no applications reference it by name. You can make objects rename-safe by requiring all applications that must store a reference to objects to use the GUID of the object, not the name. The GUID (stored in the objectGUID attribute) is guaranteed to be unique and does not change when an object is renamed. 4.19.3.1 Using a graphical user interfaceIf the parent container of the object you want to rename has a lot of objects in it, you may want to add a new connection entry for the DN of the object you want to rename. This may save you time searching through the list of objects in the container. You can do this by right-clicking ADSI Edit and selecting Connect to. Under Connection Point, select Distinguished Name and enter the DN of the object you want to rename. 4.19.3.2 Using a command-line interfaceThe two parameters that are needed to rename an object are the original DN of the object and the new RDN (-newname). The -s option can also be used to specify a server name to work against. 4.19.3.3 Using VBScriptThe MoveHere method can be tricky to use, so an explanation of how to use it to rename objects is in order. First, you need to call GetObject on the parent container of the object you want to rename. Then call MoveHere on the parent container object and specify the ADsPath of the object to rename as the first parameter. The new RDN including prefix (e.g., cn=) of the object should be the second parameter. 4.19.4 See AlsoMSDN: IADsContainer::MoveHere |
[ Team LiB ] |