Lazarus

Programming => Databases => Topic started by: RedOctober on March 05, 2018, 10:11:47 pm

Title: TIBDatabaseInfo.UserNames only shows one user... me
Post by: RedOctober on March 05, 2018, 10:11:47 pm
TIBDatabaseInfo.UserNames is not showing the currently logged in users.  It only shows one user, myself, as what ever user account I logged in as.

I checked this out with an old copy of FlameRobin.  It too has a "Current Users" list that fails the exact same way.  I can log in as two different users (concurrently) and I only ever see one user listed in the TIBDatabaseInfo.UserNames, or FlameRobin's "Connected Users" list, no matter how many users are actually logged in.

So I browse the contents of the MON$ATTACHMENTS system table, and sure enough, all connected users are listed there.  So my question is.. how do I get the correct list of connected users, using TIBDatabaseInfo?


Assuming:
...
fb_db: TIBDatabase;
memUsr: TMemo;
...

Code: Pascal  [Select][+][-]
  1. procedure TfrmCurUsr.LoadUsers(const sel_usr_nm: String);
  2. begin
  3.   // Load Users;
  4.   fb_info.Database := fb_db;
  5.   memUsr.Lines.AddStrings(fb_info.UserNames, True);
  6. end;                      
  7.  



Title: Re: TIBDatabaseInfo.UserNames only shows one user... me
Post by: rvk on March 05, 2018, 10:25:37 pm
Are you running Firebird as SuperServer and logged in as SYSDBA when you issue that command?

It appears this is not a problem with IBX but with Firebird.
See http://tracker.firebirdsql.org/browse/CORE-3471

So you need SS and logged in as SYSDBA to see all users.

Otherwise use the MON$ATTACHMENTS method.
Title: Re: TIBDatabaseInfo.UserNames only shows one user... me
Post by: rvk on March 05, 2018, 11:21:19 pm
And B.T.W. it's documented behavior for the Classic version.

Quote
How to find active connections via SQL?

If you want to find the number of active users, you can use the services API, or the relevant option in your favorite administration tool (Database -> Advanced -> Show Connected Users in Flamerobin). Please note that this only works on SuperServer, Classic would only return one user - yourself.

If you wish to do it from SQL, you need to use Firebird 2.1 at least, and it's monitoring tables. The relevant table is MON$ATTACHMENTS which provides a lot of useful information like user name, IP address, connection state, remote process name (so you can see which application user is using), etc.
http://www.firebirdfaq.org/faq10/
TinyPortal © 2005-2018