13 Replies Latest reply on Sep 21, 2016 11:53 AM by philmodjunk

    Check if user::account name = an active user

    ericjlindholm

      I have a table of users.  the only thing that currently connect the FM user account to those records is a matching name. It seems a little fragile.  I would like to create a way to warn someone editing the user record that the name does not match an active account name.  any ideas?  thanks!

        • 1. Re: Check if user::account name = an active user
          User26869

          Hi!

           

          The way I do it is by running an ExecuteSQL on start up that looks for the account name of the looted in user in the User table.

          Something like ExecuteSQL("SELECT id FROM User WHERE accountName=?" ; "" ; "" ; get(accountname) )

          I store the result of this variable in a global so that I can auto enter the id of the logged in user in a foreign key on new records for example.

          In your case, if the request is empty, you could show a dialog that informs the user that no match for her account name were found.

           

          Hope this helps!

           

          Chloe

          • 2. Re: Check if user::account name = an active user
            Johan Hedman

            Not sure what you are trying to accomplish, but first and most important, never let user into your solution without logging in with FileMaker Security. Each user should have a Account there. If you have many users you should think about using AD/OD to connect securely to your solution

            • 3. Re: Check if user::account name = an active user
              philmodjunk

              You could have one field that auto-enters the creation account name (It seems you have this one) and another field that auto-enters the modification account name.

               

              You can then set up a validation rule that displays an error if they do not match. OnCommitRecord could run a script that compares the two fields as well.

               

              Or you can set up access privileges that simply do not allow a user to edit a record if the creation account name field does not match their account name to avoid the need to show any warning message.

              • 4. Re: Check if user::account name = an active user
                ericjlindholm

                We have users that are part time in our user table that do not have FM accounts or any access.  Their managers email them their schedules.  When we make them full time, I create a FM account to give them access to their schedules in real time.  I have a button that creates an account that I would like to hide if the name already exists in the FM account list.

                • 5. Re: Check if user::account name = an active user
                  wimdecorte

                  philmodjunk wrote:

                   

                  You could have one field that auto-enters the creation account name (It seems you have this one) and another field that auto-enters the modification account name.

                   

                  You can then set up a validation rule that displays an error if they do not match.

                   

                  There is room for ambiguity here.  If EA is in use say with an AD then these 3 different types of input from Get(AccountName) are really all the same user but will not validate according to the above:

                   

                  user

                  DOMAIN\user

                  user@domain

                   

                  Something to keep in mind.

                  1 of 1 people found this helpful
                  • 6. Re: Check if user::account name = an active user
                    dtcgnet

                    I use a method similar to User26869's, BUT I discovered something recently which is very important to pay attention to: Account Name is saved as entered.

                     

                    Let's say that in the user table, my account name is dtcgnet. If I login with DTcgnet, then the ExecuteSQL statement as shown in Chloe's example will fail because the statement will not find DTcgnet, and dtcgnet is not the same as DTcgnet. Set a variable to Get ( AccountName ), and then login using different combinations of upper and lower case, and you'll see what's going on.

                     

                    The solution is to make sure you set Get ( AccountName ) AND the AccountName in your user table to all lower case or all upper.

                     

                    Set Variable $AcctName = Lower ( Get ( AccountName )

                    ExecuteSQL("SELECT id FROM User WHERE Lower ( accountName )=?" ; "" ; "" ; $AcctName )

                    1 of 1 people found this helpful
                    • 7. Re: Check if user::account name = an active user
                      dtcgnet

                      In the script that activates when you create an account, use Set Error Capture [ on ], then check to see if you get an error after your Create Account script step. If you get an error, decide how you want to handle it. If there is no error, your account is created fine and away you go.

                      • 8. Re: Check if user::account name = an active user
                        User26869

                        Yes this is actually really important and I forgot to mention it! I use Lower() as well, but Upper() or Proper() would work too.

                         

                        Thanks for pointing this out

                        • 9. Re: Check if user::account name = an active user
                          philmodjunk

                          We use external authorization (EA) here with Active Directory groups (AD). We don't see any of these complications. Get ( accountName) and an auto-entered account name only enter the users AD account name--a single unique value. I didn't set up AD on this system so maybe there are other configurations where this confusion is possible, but we don't see it in our system.

                          • 10. Re: Check if user::account name = an active user
                            wimdecorte

                            philmodjunk wrote:

                             

                            We use external authorization (EA) here with Active Directory groups (AD). We don't see any of these complications. Get ( accountName) and an auto-entered account name only enter the users AD account name--a single unique value. I didn't set up AD on this system so maybe there are other configurations where this confusion is possible, but we don't see it in our system.

                             

                            You're fortunate then with your user's habits.  The user can type in any of those 3 formats and FM and the AD will accept them.

                            The issue surfaces mostly when there are multiple trusted domains and the users must specify what domain their account belongs to, which forces them to use either the UNC or UPN syntax.  But it can happen with simple AD setups too, depending on how the user types it in.

                            • 11. Re: Check if user::account name = an active user
                              philmodjunk

                              We've got over 300 users logging in via EA/AD and have used that for years with no such trouble. I don't usually log in that way myself as I need full access as a developer, but I ran the following tests on my system using Citrix terminal server to gain access and use AD to log in with an AD group set up for testing purposes:

                               

                              Log In               |   Account Name shown

                              user                |  user

                              DOMAIN\user  | user

                              user@domain   | Log in error, can't use this method

                               

                              So this would explain my lack of concern here.

                               

                              We do have only one domain as far as I know.

                              1 of 1 people found this helpful
                              • 12. Re: Check if user::account name = an active user
                                dtcgnet

                                While you're at it...can you try with User instead of user? It would be nice to know how that gets handled.

                                • 13. Re: Check if user::account name = an active user
                                  philmodjunk

                                  I decline. I need to get back to work. For our uses, case does not matter as we either force a uniform case (in SQL) or use a straight FileMaker calc which is then case insensitive.