Platform SDK: Active Directory, ADSI, and Directory Services

IADsFileShare Property Methods

The property methods of the IADsFileshare interface get or set the properties described in the following table. For more information, see Interface Property Methods.

Properties in Vtable Order

Property Description
CurrentUserCount

[Visual Basic]
Access: Read
Data Type: LONG

[C++]
HRESULT get_CurrentUserCount
([out] LONG *plCurrentUserCount);

The number of users connected to the share.
Description

[Visual Basic]
Access: Read/Write
Data Type: BSTR

[C++]
HRESULT get_Description
([out] BSTR *pbstrDescription);


HRESULT put_Description
([in] BSTR bstrDescription);

The description of the file share.
HostComputer

[Visual Basic]
Access: Read/Write
Data Type: BSTR

[C++]
HRESULT get_HostComputer
([out] BSTR *pbstrHostComputer);


HRESULT put_HostComputer
([in] BSTR bstrHostComputer);

An ADsPath reference to the host computer.
MaxUserCount

[Visual Basic]
Access: Read
Data Type: LONG

[C++]
HRESULT get_MaxUserCount
([out] LONG *plMaxUserCount);

The maximum number of users allowed to access the share at one time.
Path

[Visual Basic]
Access: Read/Write
Data Type: BSTR

[C++]
HRESULT get_Path
([out] BSTR *pbstrPath);

HRESULT put_Path
([in] BSTR bstrPath);

The file system path to the shared directory.

Example Code [Visual Basic]

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.

Example Code [C++]

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();

See Also

IADsService, IADsFileShare, Interface Property Methods