| Platform SDK: Active Directory, ADSI, and Directory Services |
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.
| Property | Description |
|---|---|
| LockCount
[Visual Basic] [C++] |
Number of locks on the resource. |
| Path
[Visual Basic] [C++] |
The file system path of the opened resource. |
| User
[Visual Basic] [C++] |
The name of the user who opened the resource. |
| UserPath
[Visual Basic] [C++] |
The ADsPath of the user object for the user who opened the resource. |
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
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();