Adding Local Group to a Computer in Active Directory

Dim LGroupObj As IADsGroup
Dim CompuObj As IADsContainer

‘Path ”NTDSloc://Domain2/Diamond/LocalGroup01” identifies local group on computer “Diamond” in the Domain “Domain2"

‘Descriptor "server=DMSServer01" specifies that the DMS server is on computer named "DMSServer01"

‘Bind to local group object

Set LGroupObj = GetObject("NTDSloc://Domain2/Diamond/LocalGroup01/server=DMSServer01")

‘in the following four statements first parameter is name of property and second parameter is the value of the property.

'Note: You will have to put these properties for LRD in AD

LGroupObj.Put "DA_DRole_Server_Name", "DCDomain2"

'specify name of the DC for NT5 domain "Domain2"

LGroupObj.Put "DA_User_Name", "Domain1\Charlie"

'Name of the User connected to the AD tree

LGroupObj.Put "DA_Password", "pwd" 'Password of the User

LGroupObj.Put "DA_Use_Role_Type", 2

'Specifies the AD roles

'Add global group "GroupA" of domain "Domain1" identified by the path “NTDS://Domain1/GroupA"

LGroupObj.Add "NTDS://Domain1/GroupA"


'to commit the change to directory

Set LGroupObj = Nothing

‘release the object