Platform SDK: Active Directory, ADSI, and Directory Services |
The property methods of the IADsSession interface get or set the properties described in the following table. For a general discussion of property methods, see Interface Property Methods.
Property | Description |
---|---|
Computer
[Visual Basic] [C++] |
Name of the client workstation. |
ComputerPath
[Visual Basic] [C++] |
ADsPath of the computer object for the client workstation. |
ConnectTime
[Visual Basic] [C++] |
Number of minutes that have elapsed since the session started. |
IdleTime
[Visual Basic] [C++] |
The idle time of the session, in minutes. |
User
[Visual Basic] [C++] |
The name of the user of the session. |
UserPath
[Visual Basic] [C++] |
The ADsPath of the user object for the user of this session. |
The following Visual Basic code snippet illustrates how to examine sessions for 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 sessions If (IsEmpty(fso) = False) Then For Each session In fso.sessions MsgBox "Session Computer: " & session.Computer MsgBox "Session User: " & session.User Next Session End If
The following C++ code snippet enumerates a collection of sessions.
IADsFileServiceOperations *pFso; IADsSession *pSes; HRESULT hr ; LPWSTR adsPath =L"WinNT://aMachine/LanmanServer"; hr = ADsGetObject(adsPath, IID_IADsFileServiceOperations, (void**)&pFso); if (FAILED(hr)) exit(hr); IADsCollection *pColl; hr = pFso->Sessions(&pColl); pFso->Release(); // Now to enumerate sessions. 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_IADsSession, (void**)&pSes); pSes->get_Computer(&bstr); printf("Session host: %S\n",bstr); SysFreeString(bstr); pSes->get_User(&bstr); printf("Session user: %S\n",bstr); SysFreeString(bstr); pRes->Release(); } VariantClear(&var); pDisp=NULL; hr = pEnum->Next(1, &var, &lFetch); }; hr = pEnum->Release();