You are viewing limited content. For full access, please sign in.

Question

Question

Can we count the no of session for any user using SDK?

SDK
asked on December 16, 2014

using SDK I just want to count number of session for a user.

Also how can I check that user is already logged In?

1 0

Answer

SELECTED ANSWER
replied on December 17, 2014

The EnumSessions method on the Server class will return all of the sessions.  You can use the RepositoryName and UserName properties to determine if it's the one you're interested in.

2 0

Replies

replied on January 16, 2015

I can't seem to get the Server linked to the Session.
What am I missing?
Thank you.

    Dim sString As String = String.Empty
    Dim oSession As Laserfiche.RepositoryAccess.Session = Nothing

    Dim oRepository As New Laserfiche.RepositoryAccess.RepositoryRegistration(sLfServerName, sLfRepository)
    oSession = New Laserfiche.RepositoryAccess.Session()
    oSession.LogIn(sLfUserName, sLfPassword, oRepository)
    oRAServer = New Laserfiche.RepositoryAccess.Server

    For Each xyz In oRAServer.EnumSessions
        sString = xyz.UserName
        sString = xyz.SessionId
        sString = xyz.RepositoryName
        sString = xyz.LastActivity
        sString = xyz.LastActivityUtc
        sString = xyz.LogInTime
    Next

The For Each statement gets the error -
Name 'EnumSessions' is not declared.

1 0
replied on January 16, 2015 Show version history

try this and make sure that you are referencing the RepositoryAccess DLL

 

        Dim LFS As New Server(sLfServerName)
        Using ssir As ServerSessionInfoReader = LFS.EnumSessions
            For Each si As SessionInfo In ssir
                Dim sUserName As String = si.UserName
                Dim iSessionID As Integer = si.SessionId
                Dim sRepositoryName As String = si.RepositoryName
                Dim dLastAct As Date = si.LastActivity
                Dim dLastActUTC As Date = si.LastActivityUtc
                Dim dLoginTime As Date = si.LogInTime
            Next
        End Using
    End Sub

As long as you are part of the LF Server Managers, you do not need to log into the repository to view the active sessions.

 

If you really want to get the server from your session (your code looks like that was what you were trying to do), then you must fill your server object with a valid server.  Your code defines a server object, but then never fills it, so it is an empty server object.

 

            'Get server from session
            Using LFS As Server = oSession.Repository.GetServer
                'Get list of Sessions from server
                Using ssir As ServerSessionInfoReader = LFS.EnumSessions
                    For Each si As SessionInfo In ssir
                        Dim sUserName As String = si.UserName
                        Dim sOSUserName As String = si.OSUserName
                        Dim sApplication As String = si.ApplicationName
                        Dim sClientName As String = si.ClientHostName
                        Dim iSessionID As Integer = si.SessionId
                        Dim sRepositoryName As String = si.RepositoryName
                        Dim dLastAct As Date = si.LastActivity
                        Dim dLastActUTC As Date = si.LastActivityUtc
                        Dim dLoginTime As Date = si.LogInTime
                        MsgBox("User Name: " & sUserName & Environment.NewLine & _
                               "OS User Name: " & sOSUserName & Environment.NewLine & _
                               "Application Name: " & sApplication & Environment.NewLine & _
                               "Host Name: " & sClientName & Environment.NewLine & _
                               "Repisitory Name: " & sRepositoryName & Environment.NewLine & _
                               "Session ID: " & iSessionID.ToString)
                    Next
                End Using
            End Using
            ' Don't forget to log out

 

1 0
replied on January 20, 2015

Awesome, thank you.

I have the name of the server in my config file, so the first example is just what I need.

 

0 0
replied on July 27, 2015

    Using ssir As ServerSessionInfoReader = LFS.EnumSessions is giving access denied error, pls. help

0 0
replied on July 28, 2015

Then the windows user that is running the code is not part of the LF Server Managers Group.  From the LF Server, open the LF Admin console and select the Server Managers node in the left pane.  Then in the right pane, add the windows user as a LF Server manager.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.