Getting the Last Login Info
Configuration Server provides last login information during the user authentication (handshake) procedure, and the Platform SDK Configuration Protocol provides it "as-is" in the form of a KeyValueCollection:
- ConfServerProtocol.getServerContext().getLastLoginInfo()
An example of the resulting KeyValueCollection could look like:
KVList: 'LAST_LOGIN_PERSON' [int] = 100 'LAST_LOGIN_TIME' [int] = 1259161588
Note that "last login" is configured on Configuration Server through the confserv.cfg file:
[confserv] ... last-login = true last-login-synchronization = true
Platform SDK obtains the information using the EventClientRegister message:
2012-08-21 10:05:49,306 [New I/O client worker #4-4] DEBUG ns.protocol.DuplexChannel null - Handling message: 'EventClientRegistered' (19) attributes: IATRCFG_SESSIONNUMBER [int] = 22 IATRCFG_CFGSERVERDBID [int] = 99 SATRCFG_PROTOCOL [str] = "CfgProtocol 5.1.3.54" IATRCFG_EXTERNALAUTH [int] = 0 SATRCFG_PARAMETERS [KvListString] = KVList: 'LAST_LOGIN_PERSON' [int] = 1227 'LAST_LOGIN_TIME' [int] = 1345532749 'LAST_LOGIN_APPLICATION' [str] = "PSDK_CFGSCI" IATRCFG_BACKUPCFGSERVERDBID [int] = 0 IATRCFG_UNSOLEVENTNUM [int] = 73770 IATRCFG_CRYPTPASSW [int] = 1 SATRCFG_SCHEMAVERSION [str] = "8.1.100.05" IATRCFG_REQUESTID [int] = 6 SATRCFG_PROTOCOLEX [str] = "CfgProtocol 5.1.3.77"
There are two methods available in Platform SDK for retrieving last login details:
- protocol.getServerContext().getLastLoginInfo()
- protocol.getServerContext().getCfgLastLogin() (deprecated, not recommended for use)
If these methods return null, then you need to check whether Configuration Server gave the required info by looking in the debug logs for either Platform SDK or Configuration Server.
Configuration Server provides last login information during the user authentication (handshake) procedure, and the Platform SDK Configuration Protocol provides it "as-is" in the form of a KeyValueCollection:
- protocol.Context.LastLoginInfo
An example of values from the KeyValueCollection could look like:
KVList: 'LAST_LOGIN_PERSON' [int] = 100 'LAST_LOGIN_TIME' [int] = 1259161588
Note that "last login" is configured on Configuration Server through the confserv.cfg file:
[confserv] ... last-login = true last-login-synchronization = true
Platform SDK obtains the information using the EventClientRegister message:
2012-08-21 10:05:49,306 [New I/O client worker #4-4] DEBUG ns.protocol.DuplexChannel null - Handling message: 'EventClientRegistered' (19) attributes: IATRCFG_SESSIONNUMBER [int] = 22 IATRCFG_CFGSERVERDBID [int] = 99 SATRCFG_PROTOCOL [str] = "CfgProtocol 5.1.3.54" IATRCFG_EXTERNALAUTH [int] = 0 SATRCFG_PARAMETERS [KvListString] = KVList: 'LAST_LOGIN_PERSON' [int] = 1227 'LAST_LOGIN_TIME' [int] = 1345532749 'LAST_LOGIN_APPLICATION' [str] = "PSDK_CFGSCI" IATRCFG_BACKUPCFGSERVERDBID [int] = 0 IATRCFG_UNSOLEVENTNUM [int] = 73770 IATRCFG_CRYPTPASSW [int] = 1 SATRCFG_SCHEMAVERSION [str] = "8.1.100.05" IATRCFG_REQUESTID [int] = 6 SATRCFG_PROTOCOLEX [str] = "CfgProtocol 5.1.3.77"
There are two properties available in Platform SDK for retrieving last login details, shown below with related code snippets:
- protocol.Context.LastLoginInfo
ConfServerProtocol protocol = new ConfServerProtocol(new Endpoint(_name, _host, _port)); protocol.ClientName = _clientName; protocol.ClientApplicationType = _clientType; protocol.UserName = _userName; protocol.UserPassword = _password; protocol.Open(); if (protocol.Context.LastLoginInfo!=null) { object lastLoginPerson = protocol.Context.LastLoginInfo["LAST_LOGIN_PERSON"]; object lastLoginTime = protocol.Context.LastLoginInfo["LAST_LOGIN_TIME"]; // TODO ... use obtained data ... }
- protocol.Context.CfgLastLogin (deprecated, not recommended for use)
protocol.ClientName = _clientName; protocol.ClientApplicationType = _clientType; protocol.UserName = _userName; protocol.UserPassword = _password; protocol.Open(); if (protocol.Context.CfgLastLogin != null) { // TODO parse XDocument to obtain data }
If these methods return null, then you need to check whether Configuration Server gave the required info by looking in the debug logs for either Platform SDK or Configuration Server.