Platform SDK: Active Directory, ADSI, and 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 in Vtable Order

Property Description
LockCount

[Visual Basic]
Access: Read
Data Type: LONG

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

Number of locks on the resource.
Path

[Visual Basic]
Access: Read
Data Type: BSTR

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

The file system path of the opened resource.
User

[Visual Basic]
Access: Read
Data Type: BSTR

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

The name of the user who opened the resource.
UserPath

[Visual Basic]
Access: Read
Data Type: 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 Visual Basic code snippet illustrates 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")
' Enumerates 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

Example Code [C++]

The following C++ code snippet enumerates a collection of resources.

IADsFileServiceOperations *pFso;
IADsResource *pRes;
HRESULT hr ;
LPWSTR adsPath =L"WinNT://aMachine/LanmanServer";
hr = ADsGetObject(adsPath, 
IID_IADsFileServiceOperations, 
(void**)&pFso);
if (FAILED(hr)) exit(hr);
IADsCollection *pColl;
hr = pFso->Resources(&pColl);
pFso->Release();

// Now to enumerate the print jobs. Code omitted.
IUnknown *pUnk = NULL;
hr = pColl->get__NewEnum(&pUnk);
if (FAILED(hr) ) exit(hr);
pColl->Release();

IEnumVARIANT *pEnum;
hr = pUnk->QueryInterface(IID_IEnumVARIANT,(void**)&pEnum);
if (FAILED(hr)) exit(hr);
pUnk->Release();

// Now Enumerate
BSTR bstr;
VARIANT var;
ULONG lFetch;
IDispatch *pDisp;

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();
    }
VariantClear(&var);
pDisp=NULL;
hr = pEnum->Next(1, &var, &lFetch);
};

hr = pEnum->Release();

See Also

IADsResource, IADsFileServiceOperations::Resources