IADsContainer Method: CopyHere

CopyHere
(
SourceObject As String,
NewName As String
) As IADs;

Parameters

[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.

Description
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:

Domain

User and Group

Computer

User, Group and PrintQueue

File

Directories and Files

Registry

Registry Keys and Registry Values

Return Values
Newly copied ADS object.

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

Example

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