using SDK I just want to count number of session for a user.
Also how can I check that user is already logged In?
using SDK I just want to count number of session for a user.
Also how can I check that user is already logged In?
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.
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.
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
Awesome, thank you.
I have the name of the server in my config file, so the first example is just what I need.
Using ssir
As
ServerSessionInfoReader = LFS.EnumSessions is giving access denied error, pls. help