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

Property Description
CurrentUserCount

[Visual Basic]
Access: Read-only
DataType: Long

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

The number of users connected to the share.
Description

[Visual Basic]
Access: Read/Write
DataType: 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
DataType: 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-only
DataType: 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
DataType: 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 code example shows 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 share As IADsFileShare
On Error GoTo Cleanup

Set fs = GetObject("WinNT://myMachine/LanmanServer")
If (fs.class = "FileService") Then
	For Each share In fs
		share.description = share.name & " is my working folder."
		share.MaxUserCount =  10
		share.SetInfo
	Next share
End if

Cleanup:
	If (Err.Number<>0) Then
		MsgBox("An error has occurred. " & Err.Number)
	End If
	Set fs = Nothing
	Set share = Nothing

The following code example shows how to make the existing C:\MyFolder directory a public file share.

Dim fs As IADsFileShare
Dim cont As IADsContainer
On Error GoTo Cleanup
 
Set cont = GetObject("WinNT://yourDomain/yourMachineName/LanmanServer")
 
Set fs = cont.Create("FileShare", "Public")
Debug.Print fs.Class
fs.Path = "C:\MyFolder"
fs.SetInfo

Cleanup:
	If (Err.Number<>0) Then
		MsgBox("An error has occurred. " & Err.Number)
	End If
	Set cont = Nothing
	Set fs = Nothing

Example Code [C++]

The following code example makes the existing C:\MyFolder directory a public file share.

IADsFileShare *pShare = NULL;
IADsContainer *pCont = NULL;
LPWSTR adsPath = L"WinNT://yourMachineName/LanmanServer";
HRESULT hr = S_OK;

hr = ADsGetObject(adsPath, IID_IADsContainer,(void**)&pCont);
if(FAILED(hr)) {goto Cleanup;}

hr = pCont->Create(CComBSTR("FileShare"), CComBSTR("Public"), (IDispatch**)&pShare);

if(FAILED(hr)) {goto Cleanup;}

hr = pShare->put_Path(CComBSTR("c:\\public"));

if(FAILED(hr)) {goto Cleanup;}

hr = pShare->SetInfo();

Cleanup:
	if(pCont) pCont->Release();
	if(pShare) pShare->Release();

Requirements

Client: Included in Windows XP and Windows 2000 Professional.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension on Windows NT 4.0 SP6a and Windows 95/98/Me.
Header: Declared in Iads.h.

See Also

IADsService, IADsFileShare, Interface Property Methods