IADsSession Property Methods

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

Properties

Computer

Name of the client workstation.

Access type: Read-only

Scripting data type: BSTR

// C++ method syntax
HRESULT get_Computer(
  [out] BSTR* pbstrComputer
);

ComputerPath

ADsPath of the computer object for the client workstation.

Access type: Read-only

Scripting data type: BSTR

// C++ method syntax
HRESULT get_ComputerPath(
  [out] BSTR* pbstrComputerPath
);

ConnectTime

Elapsed time, in seconds, since the session started.

Access type: Read-only

Scripting data type: LONG

// C++ method syntax
HRESULT get_ConnectTime(
  [out] LONG* plConnectTime
);

IdleTime

Idle time, in seconds, of the session.

Access type: Read-only

Scripting data type: LONG

// C++ method syntax
HRESULT get_IdleTime(
  [out] LONG* plIdleTime
);

User

The name of the user of the session.

Access type: Read-only

Scripting data type: BSTR

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

UserPath

The ADsPath of the user object for the user of this session.

Access type: Read-only

Scripting data type: BSTR

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

Examples

The following code example shows how to examine sessions for a file service.

Dim fso As IADsFileServiceOperations
On Error GoTo Cleanup

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

' Enumerate 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

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

The following code example enumerates a collection of sessions.

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

VariantInit(&amp;var);

LPWSTR adsPath = L"WinNT://aMachine/LanmanServer";

hr = ADsGetObject(adsPath,IID_IADsFileServiceOperations,
                  (void**)&amp;pFso);

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

hr = pFso->Sessions(&amp;pColl);

// Enumerate sessions. 
hr = pColl->get__NewEnum(&amp;pUnk);
if(FAILED(hr)) {goto Cleanup;}

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

// Enumerate.
hr = pEnum->Next(1, &amp;var, &amp;lFetch);
while(hr == S_OK)
{
    if (lFetch == 1)    
    {
        pDisp = V_DISPATCH(&amp;var);
        pDisp->QueryInterface(IID_IADsSession, (void**)&amp;pSes);
        pSes->get_Computer(&amp;bstr);
        printf("Session host: %S\n",bstr);
        SysFreeString(bstr);

        pSes->get_User(&amp;bstr);
        printf("Session user: %S\n",bstr);
        SysFreeString(bstr);

        pRes->Release();
    }

    VariantClear(&amp;var);
    pDisp=NULL;
    hr = pEnum->Next(1, &amp;var, &amp;lFetch);
};

Cleanup:
    if(pFso) pFso->Release();
    if(pColl) pColl->Release();
    if(pUnk) pUnk->Release();
    if(pEnum) pEnum->Release();

Requirements

Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Header
Iads.h
DLL
Activeds.dll
IID
IID_IADsSession is defined as 398B7DA0-4AAB-11CF-AE2C-00AA006EBFB9

See also

IADsFileServiceOperations::Sessions

IADsSession