10 Replies Latest reply on Jul 16, 2015 3:45 AM by FrankvanderMost

    Identifying active users

    user12884

      1. I am trying to identify programatically what usernames are currently logged in so I can compare with account files.

       

      2. I know I can create and query a login log file, but that does not show me whether they have closed their session or not.

       

      3. I know I can limit the number of logins at the server. Is there a way to programatically query the server as to who is currently logged in?

       

      Any Ideas?

       

      Thanks

       

      Richard

        • 1. Re: Identifying active users
          wimdecorte

          You can't query live, but you could use a batch file and the fmsadmin command line in a server-side schedule to get a snapshot of the current users, say every 15 minutes or so.

          1 of 1 people found this helpful
          • 2. Re: Identifying active users
            user12884

            Sounds like it should work. Although its been 20 years since I wrote a batch file. Have you got a quick sample. Then I'll have to figure out how to call it - which I think will be fairly simple.

             

            Thanks

            Richard

            • 3. Re: Identifying active users
              kaostika

              You can run a script to to modify a field in a USER table to show when someone logs on and off.  Maybe set the field ACTIVE to one on opening and 0 on log off.  Wont help if someone computer crashed thou.

              • 4. Re: Identifying active users
                PedroPinto

                Hi all,

                 

                I have been dealing with the same problem myself and here is how I solved it step by step (for windows). I hope it works for you.

                 

                The following takes place in the server:

                 

                1. Open a notepad empty file;

                 

                2. Make sure there is no content in the file;

                 

                3. For a typical FM13 server install type:

                 

                fmsadmin list clients -stats -u UUU -p PPP > "C:\Program Files\FileMaker\FileMaker Server\Data\Documents\FileMakerActiveUsers.txt"

                 

                Note: replace the UUU by your own FMS console username and PPP by your own FMS console password. Note that one of the parameters is -stats, this gets the output to include the real account names and not the FileMaker  User Name (set in the FM preferences). I wich someone had told me this!!!!!. What you get with the -stats is the accounts set under security.

                 

                4. Save the notepad file (try ActiveUsers.txt) and change the extension (3 last characters) of the filename to cmd. This will make it a command file that can be run by windows;

                 

                5. Copy the ActiveUsers.cmd file to C:\Program Files\FileMaker\FileMaker Server\Data\Scripts;

                 

                Note this is where scheduled scripts that are run by the console have to be placed.

                 

                6. Try it by double clicking the ActiveUsers.cmd file you just created (make sure you are using a windows administrator account);

                 

                After running it you should see a file FileMakerActiveUsers.txt just created at C:\Program Files\FileMaker\FileMaker Server\Data\Documents\;

                 

                7. From here you just have to create a schedule in the console to run a system script at the desired interval so the file gets to be updated;

                 

                8. After you have the file automated you can create a script in Filemaker to import and parse the data from FileMakerActiveUsers.txt

                at C:\Program Files\FileMaker\FileMaker Server\Data\Documents\

                 

                Cheers

                 

                Pedro Pinto Faria

                Will be at the DevCon 2015 in Vegas

                • 5. Re: Identifying active users
                  wimdecorte

                  There's another way that does not require you to hard-code your admin console credentials into a batch file:

                  - set up FMS to use the access.log (it's off by default)

                  - create a batch file tat copies the access.log file into the FMS docs folder, save the script in the FMS scripts folder

                  - create a FM script that imports that access log

                  - create a script sequence schedule to run it all

                  • 6. Re: Identifying active users
                    wimdecorte

                    It has the benefit of giving you ALL the info as opposed to not capturing users that have logged on and off in-between calls to "list clients"

                    • 7. Re: Identifying active users
                      PedroPinto

                      Great WimDeCorte, next time I'll try that. I this case I absolutely needed to get just the active users.

                      • 8. Re: Identifying active users
                        FrankvanderMost

                        Since I am developing on a live database, I have a need for a simple active-user list. Since I don't have access to the server in the ways suggested I developed a solution within the database file. It works with a user-table/accounts-table (assuming that one user uses one account) that has a time-stamp field called last_notice_of_on_line_presence. The startup script installs an OnTimer script which runs every x minutes and updates the field with Get ( CurrentHostTimeStamp ).

                         

                        I implemented this by having every other table in the database related to the accounts table via a calculation field with Get (AccountName). I'm sure a find in the script will do the job too but then the script needs to leave the current layout/table which may have downsides.

                         

                        Clearly, there is a time-lag of x minutes, but for me that is good enough. The time lag will be bigger than x minutes when the user can run scripts that take more time than that.

                         

                        I am considering extending the system by also logging the current layout of the user.

                         

                        The way to know that the user is logged out is that x has expired more than y times. In my case y=2. Since they are accessing through webdirect they usually log out without triggering the OnLastWindowClose script. If I could force a controlled log-out, that script will empty the field and perhaps set the time stamp of log-out in a different field.

                         

                        A nice extra is that this solution also allows users to see who else is on-line and a possible extension would be a chat function but for 'my' database there is no real need for it.

                         

                        It's still in the testing-phase but so far so good.

                        • 9. Re: Identifying active users
                          wimdecorte

                          Frank van der Most wrote:

                           

                           

                          I implemented this by having every other table in the database related to the accounts table via a calculation field with Get (AccountName). I'm sure a find in the script will do the job too but then the script needs to leave the current layout/table which may have downsides.

                           

                          Use ExecuteSQL()

                          It has the benefit of not requiring the relationships, nor leaving your current context.

                          • 10. Re: Identifying active users
                            FrankvanderMost

                            Thanks for the suggestion, Wim! So far, I've only used the ExecuteSQL function to look up things, but of course it has a lot more to offer. Come to think of it, the function seems a kind of cuckoo's egg that makes script steps and relationships in the relationship scheme superfluous. As a function it's a bit odd too, since it can actively do things to stored data rather than present or calculate results. ... anyways, that's a different discussion.