Creating a File Share in Active Directory

Dim Container As IADsContainer
Dim FShare As IADsFileShare

''Create a fileshare named "FileShare" on Computer "ComputerA" in domain "Domain1"

'"NTDSloc://Domain1/ComputerA/file_services" is the DN of virtual container "file_services" on Computer "ComputerA" in domain "Domain1" which holds objects of type files/directories/Shares

'Descriptor "server = DMSserver01" in the path specifies that DMS server is on Computer "DMSserver01".

Set Container = GetObject("NTDSloc://Domain1/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 = Container.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", "DCDomain1"

'specify name of the DC for WIN2K domain Domain1

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 file share (mandatory property)


'To commit the changes

Set FShare = Nothing

'Release the Object