Directory Services

IADsResource Property Methods

The property methods of the IADsResource interface get or set the properties described in the following table. For a general discussion of property methods, see Interface Property Methods.

Properties

Property Description
LockCount

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

[C++]
HRESULT get_LockCount
([out] LONG* plLockCount);

Number of locks on the resource.
Path

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

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

The file system path of the opened resource.
User

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

[C++]
HRESULT get_User
([out] BSTR* pbstrUser);

The name of the user who opened the resource.
UserPath

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

[C++]
HRESULT get_UserPath
([out] BSTR* pbstrUserPath);

The ADsPath of the user object for the user who opened the resource.

Example Code [Visual Basic]

The following code example shows how to examine open resources of a file service.

Dim fso As IADsFileServiceOperations
' Bind to a file service operations object on "myComputer" in the local domain.
Set fso = GetObject("WinNT://myComputer/LanmanServer")

' Enumerate resources.
If (IsEmpty(fso) = False) Then
	For Each resource In fso.resources
		MsgBox "Resource name: " & resource.name
		MsgBox "Resource path: " & resource.path
	Next resource
End If

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

Example Code [C++]

The following code example enumerates a collection of resources.

IADsFileServiceOperations *pFso = NULL;
IADsResource *pRes = NULL;
IADsCollection *pColl = NULL;
IUnknown *pUnk = NULL;
IEnumVARIANT *pEnum = NULL;
BSTR bstr = NULL;
VARIANT var;
ULONG lFetch = 0;
IDispatch *pDisp = NULL;
HRESULT hr = S_OK;

LPWSTR adsPath =L"WinNT://aMachine/LanmanServer";
hr = ADsGetObject(adsPath, IID_IADsFileServiceOperations,(void**)&pFso);
if(FAILED(hr)) {goto Cleanup;}

hr = pFso->Resources(&pColl);
if(FAILED(hr)) {goto Cleanup;}


// Enumerate print jobs. Code omitted.
hr = pColl->get__NewEnum(&pUnk);
if(FAILED(hr)) {goto Cleanup;}

hr = pUnk->QueryInterface(IID_IEnumVARIANT,(void**)&pEnum);
if(FAILED(hr)) {goto Cleanup;}

// Enumerate.
VariantInit(&var);
hr = pEnum->Next(1, &var, &lFetch);
while(hr == S_OK)
{
	if (lFetch == 1)
	{
		pDisp = V_DISPATCH(&var);
		pDisp->QueryInterface(IID_IADsResource, (void**)&pRes);
		pRes->get_Name(&bstr);
		printf("Resource name: %S\n",bstr);
		SysFreeString(bstr);
		pRes->get_Path(&bstr);
		printf("Resource path: %S\n",bstr);
		SysFreeString(bstr);
		pRes->Release();
}
	pDisp->Release();
	VariantClear(&var);
	hr = pEnum->Next(1, &var, &lFetch);
};

Cleanup:
	if(pRes) pRes->Release();
	if(pDisp) pDisp->Release();
	if(pEnum) pEnum->Release();
	if(pUnk) pUnk->Release();
	if(pColl) pColl->Release();
	if(pFso) pFso->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

IADsResource, IADsFileServiceOperations::Resources