10 Replies Latest reply on Jan 10, 2011 9:39 PM by RichardJohnson

    how to create a login window and allow enduser to create new database users from a runtime db

    RichardJohnson

      Title

      how to create a login window and allow enduser to create new database users from a runtime db

      Post

      Hello FM-pro community!

      I have a simple database called PersonaTracker, I would like to distribute the solution as a stand alone executable for windows platforms i have the adcanced verson of filemaker pro v10 for windows.  I need to know how to create a login dialog and allow enduser who dont have filemaker pro/advancedn to be able to add new users so that my endusers do not have to call/email me just to grand someone access to the system.

      please HELP!

      your help is much appreciated!

        • 1. Re: how to create a login window and allow enduser to create new database users from a runtime db
          RickWhitelaw

          You need to investigate Privilege Sets. Are you saying that ALL endusers should have the right to create new accounts? If so, this is not advisable IMHO. As far as creating a login dialog, I believe it's not necessary as FileMaker (or a runtime) will present a login dialog if set to do so.

          RW

          • 2. Re: how to create a login window and allow enduser to create new database users from a runtime db
            RichardJohnson

            what needs to happen is that there needs to be @ minimum two groups... poweruser or administrators, and restricted users.  to where admins can create new accounts and hr can add/delete staff members but not departmentsand regular users can just browseand all of this needs to happen on a runtime application as i am the only one @ my place of employeement with filemaker

            • 3. Re: how to create a login window and allow enduser to create new database users from a runtime db
              RichardJohnson

              also  how to configure a fmp database or runtime to require a login...   thanks for your help

              • 4. Re: how to create a login window and allow enduser to create new database users from a runtime db
                Sorbsbuster

                In File | File Options | Open/Close Tab untick the auto log in and force the user to enter an account name and password.

                You can create a script that adds a user.  In principle:

                - Check if the user belongs to the Privilege Set Admin, or Poweruser, or whoever you allow.  Otherwise show informing dialogue, halt the script.

                - Offer a dialogue box with 3 global fields: User Name, Password, and Access Level.  (For ease of entry I'd let them specify 1, 2, 3 etc, not 'Administrator', 'Poweruser', etc.

                - Check that all fields have been completed correctly and then use the script step 'Add Account'.  You can use the collected data to create the user name, password, and interpret the level they asked for to attach it to the right privilege set.

                - You could include an error trap for Get ( LastError ) = 12 in case someone tries to create a User who already exists (although FM will warn them anyway).

                **** I haven't checked if this facility is available in Runtime, but I don't remember in the 'excluded features' list ***

                • 5. Re: how to create a login window and allow enduser to create new database users from a runtime db
                  RichardJohnson

                  thanks to  all that have posted in reply so far.  now does anyone know of a free script to add users to the database as mentioned in the above comments.

                  • 6. Re: how to create a login window and allow enduser to create new database users from a runtime db
                    Sorbsbuster

                    Making the log-in dialogue appear doesn't need a script.

                    ----------------------------------------------------------------------------

                    Note that if you allow this facility then when you issue an upgrade to your file you will have to include a strat-up script which will re-create in the new file the customised User Accounts from the 'old' file, or else every time you upgrade the user will have to re-create all of the custom users they created previously.

                    To allow creation of additional user accounts, you could try this:

                    ACCOUNTNAMES is a table holding all of the custom-created user account names and passwords, and the level they were created at.  (Necessary for you to know what to re-create at upgrade.  Otherwise the global fields could simply exist in any table in your existing file.)  You will see some suggested integrity checks on the way through it.

                    gText is a global text field with 2 repetitions

                    gNumber is a global number field

                    Example Script

                    #Creates a new Account Name for logging on
                    Enter Browse Mode
                    #Check for mis-click
                    Show Custom Dialog [ Title: "Mis-click?"; Message: "Are you sure you want to create a NEW Account Name to allow a new person to log in to the system?"; Buttons: “Cancel”, “OK” ]
                    If [ Get ( LastMessageChoice ) = 1 ]
                    Halt Script
                    End If
                    #
                    #
                    #Clear global fields
                    Set Field [ ACCOUNTNAMES::gText; "" ]
                    Set Field [ ACCOUNTNAMES::gText[2]; "" ]
                    Set Field [ ACCOUNTNAMES::gNumber; "" ]
                    #
                    #Check that the user is 'Manager' or 'designer' or 'admin' or 'support' or they are Privilege Set UserLevel1
                    If [ Get (AccountName ) = "designer"
                    or
                    Get (AccountName ) = "admin"
                    or
                    Get ( AccountName ) = "support"
                    or
                    PatternCount ( Get ( AccountPrivilegeSetName ) ; "Level1") > 0 ]
                    Else
                    Show Custom Dialog [ Title: "Cannot create new User"; Message: "You access privileges do not allow you to create a new User.
                    Please ask an Administrator to do this."; Buttons: “OK” ]
                    Halt Script
                    End If
                    #
                    #Show Custom Dialogue to collect new Account Name and password
                    Show Custom Dialog [ Title: "Create Account Name"; Buttons: “OK”, “Cancel”; Input #1: ACCOUNTNAMES::gText, "Account Name"; Input #2: ACCOUNTNAMES::gText[2], Password, "Password"; Input #3: ACCOUNTNAMES::gNumber, "Access Level (0 or 1)" ]
                    #
                    #Check for cancellation
                    If [ Get ( LastMessageChoice ) = 2 ]
                    Set Field [ ACCOUNTNAMES::gText; "" ]
                    Set Field [ ACCOUNTNAMES::gText[2]; "" ]
                    Set Field [ ACCOUNTNAMES::gNumber; "" ]
                    Halt Script
                    End If
                    #
                    #Otherwise capture variables, clear data, and create account
                    Commit Records/Requests
                    [ Skip data entry validation; No dialog ]
                    Set Variable [ $AccountName; Value:GetRepetition ( ACCOUNTNAMES::gText ; 1 ) ]
                    Set Variable [ $Password; Value:GetRepetition ( ACCOUNTNAMES::gText ; 2 ) ]
                    Set Variable [ $UserLevel; Value:ACCOUNTNAMES::gNumber ]
                    #
                    Set Field [ ACCOUNTNAMES::gText; "" ]
                    Set Field [ ACCOUNTNAMES::gText[2]; "" ]
                    Set Field [ ACCOUNTNAMES::gNumber; "" ]
                    #
                    #Check that valid data has been completed
                    #
                    If [ $AccountName = ""
                    or
                    $Password = ""
                    or
                    Length ( $Password ) < 4
                    or
                    $UserLevel = ""
                    or
                    Filter ( $UserLevel ; "0123") = "" ]
                    Show Custom Dialog [ Title: "Invalid information"; Message: "You must specify an Account Name, a password of at least 4 characters,
                    and a User Level (0, 1, 2, or 3)"; Buttons: “OK” ]
                    Halt Script
                    End If
                    #
                    #Create account at correct UserLevel
                    #
                    #Check if Account Name already exists
                    Set Error Capture [ On ]
                    #
                    If [ $UserLevel = 0 ]
                    Add Account [ Account Name: $AccountName; Password: $Password; Privilege Set: “Level0” ]
                    Else If [ $UserLevel = 1 ]
                    Add Account [ Account Name: $AccountName; Password: $Password; Privilege Set: “Level1” ]
                    Else If [ $UserLevel = 2 ]
                    Add Account [ Account Name: $AccountName; Password: $Password; Privilege  Set: “Level2” ]
                    Else If [ $UserLevel = 3 ]
                    Add Account [ Account Name: $AccountName; Password: $Password; Privilege  Set: “Level3” ]
                    Else
                    End If
                    #
                    #Check if the Account Name already existed - Filemaker will return an error
                    #
                    #Filemaker will abort the Account Creation if the new username already exists
                    #
                    #(This is the Error Number for 'Name already exists')
                    If [ Get ( LastError ) = 12 ]
                    Show Custom Dialog [ Title: "Cannot create that Account"; Message: "The new user name: '" & $AccountName & "' already exists and
                    has NOT been added."; Buttons: “OK” ]
                    Halt Script
                    End If
                    #
                    #Create Record on Account Names Table
                    Go to Layout [ “Account Names” (ACCOUNTNAMES) ]
                    New Record/Request
                    Set Field [ ACCOUNTNAMES::AccountName; $AccountName ]
                    Set Field [ ACCOUNTNAMES::AccountPrivilegeSet; $UserLevel ]
                    Set Field [ ACCOUNTNAMES::AccountPassword; $Password ]
                    Commit Records/Requests
                    [ Skip data entry validation; No dialog ]
                    #
                    #Finish tidily
                    Show Custom Dialog [ Title: "Account created"; Message: "A Level " & $UserLevel & " Account has been created with the name: " &
                    $AccountName; Buttons: “OK” ]
                    #
                    #

                    • 7. Re: how to create a login window and allow enduser to create new database users from a runtime db
                      RichardJohnson

                      is there any way to  add this script to say the file menu of the runitme?  Also, can we have the script (or a seperate script) so that the admin's can add privilege sets and reset passwords?  and finally, I am new to filemaker so I was wondering could someone create these script(s) for me and I will be forever grateful as I have to get this done for work...  if need be i am willing to pay $12 for script(s) development.

                      Thanks again for the help!

                      • 8. Re: how to create a login window and allow enduser to create new database users from a runtime db
                        Sorbsbuster

                        Why not just make a button for it on a suitable layout?  What is the need for adding it to the File menu?

                        Why would you want admins to create Privilege sets?  Just create from the start whatever range of privilege sets you might ever need, even if you don't use some of them.

                        If you create the script line-by-line, and it will work.

                        • 9. Re: how to create a login window and allow enduser to create new database users from a runtime db
                          philmodjunk

                          You can certainly use Advanced to customize the file menu, but creating a privilege set isn't something you can do with anything but the full access password and Manage | Security. You can, however, set up a system whereby a "power user" can create new accounts and assign each account to an existing privilege set as sorbsbuster describes.

                          • 10. Re: how to create a login window and allow enduser to create new database users from a runtime db
                            RichardJohnson

                            Is there a way i can copy/paste the above script code and import it into FM?  if so, how? please provide a step-by-step procedure.  thanks again for all the help!