User login by organization

Questions and Answers on installation, deployment, management, locking, tranasactions of Servoy Application Server

User login by organization

Postby rmcneilly » Fri Jan 10, 2020 7:35 pm

Is there a query or admin page that can list the active user logins by organization? On the clients admin page, there is a list of all client logins but if difficult to determine the organizations that these users belong.
rmcneilly
 
Posts: 2
Joined: Fri Jan 10, 2020 7:32 pm

Re: User login by organization

Postby mboegem » Mon Jan 13, 2020 12:16 am

Hi rmcneilly,

If you want this, you can add client info to every client that connects.
Code: Select all
application.addClientInfo('organisation X')


Now you can do a count for all connected clients for 'organisation X' by using this function:
Code: Select all
application.getClientCountForInfo('organisation X')


Hope this helps.
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1573
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: User login by organization

Postby Bernd.N » Wed Jan 15, 2020 1:41 pm

We have users who all have different legal entities, branches, divisions and departments.
We all put this into our user table to specific fields. In fact, we do not use a separate user table but only one table called "persons", which includes also all contacts from customers and suppliers.
The users than just have a flag "ps_is_user" (INTEGER) in that table. The advantage is we spare a separate user table and it turned out to be quite useful.

When creating a current user list in an array with plugins.UserManager.getClients(), we then link that list to our own user table and can show everything we want.
I enclose our function which does that:
(_to_persons$initials_anykey is a relation that relates persons table to persons table (itself), and is defined by scopes.utils.anyKey=ps_initials, which in return we get from the getClients() )

Code: Select all
/**
* Returns current logged-in user data-set
*
* @return {JSDataSet} dsLoggedInUsers
*
* @private
*
* @properties={typeid:24,uuid:"0A6C79A9-BF61-434C-A9F7-3FF02B340066"}
*/
function getCurrentUserList() {
   
   var
      /*** @type {Array} */
      arrClients = plugins.UserManager.getClients(),
      /*** @type {JSDataSet} */
      dsLoggedInUsers = databaseManager.createEmptyDataSet(),
      sUserFullName    = "",
      sUserBranch    = "";
   
   dsLoggedInUsers.addColumn('client_id');
   dsLoggedInUsers.addColumn('application_type');
   dsLoggedInUsers.addColumn('host_address');
   dsLoggedInUsers.addColumn('host_identifier');
   dsLoggedInUsers.addColumn('host_name');
   dsLoggedInUsers.addColumn('user_name');
   
   dsLoggedInUsers.addColumn('user_fullName');
   dsLoggedInUsers.addColumn('user_branch');
   
   dsLoggedInUsers.addColumn('user_uid');
   dsLoggedInUsers.addColumn('login_time');
   dsLoggedInUsers.addColumn('idle_time');
   dsLoggedInUsers.addColumn('last_update_time');

   
   var   
      dLogin,
      dIdle,
      dLastUpdate,
      sDatePattern = scopes.person.currentDateFormat_dd_mm_yyyy,
      sTimePattern = "HH:mm";
   

   for (var i = 0; i < arrClients.length; i++) {
      
      scopes.utils.anyKey = arrClients[i].userName;
      
      if (utils.hasRecords(_to_persons$initials_anykey)) {
         
         if (utils.hasRecords(_to_persons$initials_anykey.persons_to_org_units))

                             sUserBranch = _to_persons$initials_anykey.persons_to_org_units.org_name ;
                sUserFullName = _to_persons$initials_anykey.clcs_ps_full_name ;
         
      } else {
         
         sUserBranch    = "Unknown";
         sUserFullName    = "Unknown";
      }
      
      dLogin      = utils.dateFormat(arrClients[i].login, sDatePattern) + " " + utils.dateFormat(arrClients[i].login, sTimePattern);
      dIdle       = utils.dateFormat(arrClients[i].idle, sDatePattern) + " " + utils.dateFormat(arrClients[i].idle, sTimePattern);
      dLastUpdate = utils.dateFormat(arrClients[i].lastUpdate, sDatePattern) + " " + utils.dateFormat(arrClients[i].lastUpdate, sTimePattern);
      
         
      dsLoggedInUsers.addRow([arrClients[i].clientId,
                        arrClients[i].applicationType,
                        arrClients[i].hostAddress,
                        arrClients[i].hostIdentifier,
                        arrClients[i].hostName,
                        arrClients[i].userName,
                        sUserFullName,
                        sUserBranch,
                        arrClients[i].userUid,
                        dLogin,
                        dIdle,
                        dLastUpdate]); 
   }
   
   return dsLoggedInUsers;
}
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 543
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany


Return to Servoy Server

Who is online

Users browsing this forum: No registered users and 4 guests