Adding File Shares to a Computer in Active Directory

Dim FShare As IADsFileShare
'‘Create a fileshare named "FileShare" on Computer "ComputerA" in domain "Domain2"

'"NTDSloc://Domain2/ComputerA/file_services" is the DN of virtual Container "file_services" on Computer "ComputerA" in domain "Domain2" which holds objects of type files/directories/Shares
‘Descriptor "server = DMSserver01" in the path specifies that DMS server is on Computer "DMSserver01".

Set Cont = GetObject("NTDSloc://Domain2/ComputerA/file_services/server=DMSserver01") 

'Create file share in this virtual Container
' "Share" is the class name which specifies that we want to create a object of type File Share and name of the object is “FileShare”.

Set FShare = Cont.Create("Share", "FileShare")

' 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 WIN2K

FShare.Put "DA_DRole_Server_Name", "DCDomain2"

'specify name of the DC for WIN2K domain Domain2

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

'Name of the User connected to the AD tree

FShare.Put "DA_Password", "pwd"

'Password of the User

FShare.Put "DA_Use_Role_Type", 2

'Specifies the AD roles 

FShare.Path ="c:\"
'Path of the directory associated with the file share (mandatory property)

'To commit the changes

Set FShare = Nothing
'Release the Object

Set Cont = Nothing
'Release the Object


See Also