Platform SDK: Active Directory, ADSI, and Directory Services |
The property methods of the IADsFileshare interface get or set the properties described in the following table. For more information, see Interface Property Methods.
Property | Description |
---|---|
CurrentUserCount
[Visual Basic] [C++] |
The number of users connected to the share. |
Description
[Visual Basic] [C++] |
The description of the file share. |
HostComputer
[Visual Basic] [C++] |
An ADsPath reference to the host computer. |
MaxUserCount
[Visual Basic] [C++] |
The maximum number of users allowed to access the share at one time. |
Path
[Visual Basic] [C++] |
The file system path to the shared directory. |
To access the properties of file shares on a computer, you must first bind to the "LanmanServer" on the machine. The following Visual Basic code snippet illustrates how to set up the description and the maximum number of allowed users for all the public file shares on the computer, named as "myMachine", in the default domain.
Dim fs As IADsFileService Dim fish As IADsFileShare Set fs = GetObject("WinNT://myMachine/LanmanServer") If (fs.class = "FileService") then For Each fish In fs fish.description = fish.name & " is my working folder." fish.MaxUserCount = 10 fish.SetInfo Next fish End if
The following code snippet shows how to make the existing C:\MyFolder directory a public file share.
Dim fs As IADsFileShare Dim cont As IADsContainer Set cont = GetObject("WinNT://yourDomain/yourMachineName/LanmanServer") Set fs = cont.Create("FileShare", "Public") Debug.Print fs.Class fs.Path = "C:\MyFolder" fs.SetInfo
Presently, you cannot set the permission on the share.
The following C++/C code snippet makes the existing C:\MyFolder directory a public file share.
IADsFileShare *pFish; IADsContainer *pCont; LPWSTR adsPath = L"WinNT://mimmo/lanmanServer"; HRESULT hr; hr = ADsGetObject(adsPath, IID_IADsContainer,(void**)&pCont); if(FAILED(hr)) exit( 0 ); hr = pCont->Create(L"FileShare",L"Public", (IDispatch**)&pFish); pCont->Release(); if(FAILED(hr)) exit(0); hr = pFish->put_Path(L"c:\\public"); if(FAILED(hr) ) { pFish->Release(); exit(0); } hr = pFish->SetInfo(); pFish->Release();