15.13. Renaming an Object

Problem

You want to rename an object and keep it in its current container or OU.

Solution

Using a graphical user interface

  1. Open ADSI Edit.

  2. If an entry for the naming context you want to browse is not already displayed, do the following:

    1. Right-click on ADSI Edit in the right pane and click Connect to....

    2. Fill in the information for the naming context, container, or OU that contains the object you want to rename. Click on the Advanced button if you need to enter alternate credentials.

  3. In the left pane, browse to container or OU where the object you want to modify is. Once you've found the object, right-click on it and select Rename.

  4. Enter the new name and click OK.

Using a command-line interface

> dsmove "<ObjectDN>" -newname "<NewName>"

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

Discussion

Before you rename an object, ensure no applications reference it by name. You can make objects rename-safe by requiring all applications storing a reference to objects 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 ...

Get Windows Server Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.