IADsContainer Method: CopyHere

SourceObject As String,
NewName As String
) As IADs;


[in] String SourceObject
ADsPath of a Group or User, or Local group or Local User object, depending on the object in which you are copying.

[in] String NewName
The New name of the copied user or group. If it is an empty string, the same name is retained after copying.

Creates a new object in a container identical to a specified object and returns a pointer to the new object. Copying objects across namespaces is not permitted.

The CopyHere property for IADsContainer supports copying of the following objects:


User and Group


User, Group and PrintQueue


Directories and Files


Registry Keys and Registry Values

Return Values
Newly copied ADS object.

On the File container specifying a File Share as the source copies it as a directory to the destination.


This example demonstrates the use of the CopyHere Method to copy a User.

Dim UserContainer As IADsContainer
Dim User As IADsUser
Set UserContainer = GetObject("NTDS://<YourDomainName>") 
Set User = UserContainer.CopyHere("NTDS://<SrcDomainName>/<UserName>", "<NewName>")

'The next example demonstrates the use of the CopyHere Method for copying a directory.
Dim FileContainer As IADsContainer
Dim Directory As Ifile
Set FileContainer = GetObject("NTDS://<YourDomainName>/<MachineName>/file_services/c-drive\documents")
'The next statement will copy the directory documents as a subdirectory of Dos. It will be copied with the new name NewDirectory.
Set Directory = FileContainer.CopyHere("NTDS://<YourDomainName>/<MachineName>/file_services/c-drive/Dos", "NewDirectory")


See Also