Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
The move and rename tasks use the same method, MoveHere, to complete their respective operations. Unlike the copy task, the move and rename tasks are relatively simple to complete with an ADSI script. The MoveHere method supports the following Active Directory move and rename operations:
You cannot use the MoveHere method to move an object to another forest.
There are some object-specific restrictions to making cross-domain moves. However, moving an object to other domains within the same forest is possible when the following general conditions are met:
(null): Inappropriate authentication
When you call the MoveHere method in a script, the first parameter of the method designates the ADsPath of the move or rename operation. The DN in the ADsPath designates where the object currently resides. The second argument designates the relative distinguished name of the object to be moved or the new name of the object to be renamed. If your intention is simply to move and not rename the object, the second parameter can be specified as vbNullString. Table 5.3 shows the arguments of the MoveHere method.
Table 5.3 MoveHere Arguments
Argument | Type | Required | Default | Description |
---|---|---|---|---|
ADsPath | string | Yes | None | The name of the provider and the DN of the source object to move or rename. |
RelativeDistinguishedName | string | Yes | None | The cn=name attribute of the user account object to be moved or the new name of the user account to be renamed. If you are not renaming the account, you can specify vbNullString instead. |
Regardless of the move or rename task you want to complete, both tasks involve two simple steps:
Like the Delete method, the MoveHere method acts immediately upon Active Directory. Therefore, there is no need to call the SetInfo method to complete a rename or move operation.
The goal of the three scripts in this section is to rename a published printer, move a group from one OU to another within the same domain, and move an OU from one domain to another. These three objects and tasks provide a good sampling of what can be done with the MoveHere method. For more information about how to complete object-specific move operations, see the ADSI task-based chapters in this book.
The script in Listing 5.25 renames the Printer1 printer to HRPrn1. After the rename operation, the printer remains in the HR OU of the na.fabrikam.com domain.
This binding operation designates the HR OU as the target container of the rename operation.
The first parameter of the MoveHere method specifies the ADsPath of the object to be renamed, the LDAP provider and the DN of Printer1. The second parameter specifies the new name for the printer.
Listing 5.25 Renaming a Published Printer
|
|
The script in Listing 5.26 moves the Atl-Users group from the HR OU to the Users container of the na.fabrikam.com domain. Note that the Atl-Users group is not modified in any way. All members of the group remain, and the group is not renamed.
This binding operation designates the Users container as the target container of the move operation.
The first parameter of the MoveHere method specifies the ADsPath of the object to be moved, the LDAP provider and the DN of the Atl-Users group. The second parameter specifies vbNullString because the group is not renamed during the move operation. Alternatively, you can specify the relative distinguished name (cn=Atl-Users) for the second parameter.
Listing 5.26 Moving a Group Within the Same Domain
|
|
Tip
The script in Listing 5.27 moves the Management OU from the fabrikam.com domain to the na.fabrikam.com domain.
This binding operation designates the na.fabrikam.com domain as the target container of the move operation.
Listing 5.27 Performing a Cross-Domain Move of an OU
|
|
While the script in Listing 5.27 might appear useful, it is of limited use in its current form. A cross-domain move works only for leaf objects. Therefore, the OU must be empty before it can be moved. However, if you have assigned a number of attributes to the OU, it might make sense to move all of the objects in the container to the other domain, then move the OU, and finally move all of the objects back into the OU. For information about moving specific types of objects, such as user accounts, see the corresponding ADSI task-based chapter.
Important observations about the scripts in this section are:
Send us your feedback | « Previous | Next » |