Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Button Security with groups and users

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Re: Button Security with groups and users

    Originally posted by Stan Mathews View Post
    My thinking was that the same security group process as used for the rest of the application would suffice for button access. They would set up groups (can_del, can_edit, and can_save) and assign users to those groups.

    Then as suggested earlier

    You could create a global variable in the autoexec which used A5_GET_USER_ASSIGNMENTS() to populate it with the groups to which user_name() is assigned.

    dim global whch_bttns as C
    whch_bttns = A5_GET_USER_ASSIGNMENTS("themasterpassword,user_name())

    Then each button (delete, edit, or save) would be coded to check whether the current user was part of the can_del, can_edit, or can_save groups - either by xbasic or dymanic property.
    Hi Stan,
    I tried this and get error message user Administrator does not exist.
    I tried Ronalds code and that worked, but it is using usernames, maybe I can create something owner creates what users get access, but groups is better way in my mind.
    Any thoughts to error message that user administrator does not exist when it does?

    Thank you,
    Paul

    Comment


      #17
      Re: Button Security with groups and users

      The "Administrator" user name is special and is, by definition, a member of all groups. Notice that it doesn't appear in the add users and groups dialog. The usual practice would be to have each user log in with their own name and password and one or more be part of the Administrators group.
      There can be only one.

      Comment


        #18
        Re: Button Security with groups and users

        I used user_name() as it returns the name of the current user.
        In my case the current user is the name of a group.

        login_shot.PNG

        I don't know how your application is handling the log in process. When someone logs in, are they
        logging in as an individual or as a group member.

        Alpha has a whole host of functions that handle security.
        It's just a matter of setting a global variable to whatever you need from the log in process.
        Then using that variable to manipulate the buttons on your forms.

        This is a portion of my code on the main menu OnActivate event.
        Depending in the result of the function user_name(), I grey out the appropriate buttons.

        Code:
        '--list of who has access to which buttons
        'button1 - utilities			        :admin, billing
        'button3 - maintenance invoice	:admin, billing, office
        'button4 - inventory			:admin, billing, office, mechanic, parts
        'button5 - mechanics			:admin, billing
        'button6 - po's				:admin, billing, office, parts
        'buttoncustomers				:admin, billing, office
        'buttondefaults				:admin, billing
        'buttonvendors				:admin, billing, parts
        'exitbutton
        
        ''Exclude parts button list
        if inlist2(var->vcUser, "Parts") = .t. then
        	eList = <<%a%
        button1
        button3
        button5
        buttoncustomers
        buttondefaults
        %a%
        	
        	for each foo in eList
        		eval("topparent:"+foo+".Border.Color")  = "Gray-25"
        		eval("topparent:"+foo+".Font.Color")  = "Gray-25"
        		eval("topparent:"+foo+".disable()")
        	next
        	goto moveOn
        end if
        
        ''Exclude office button list
        if inlist2(var->vcUser, "Office") = .t. then
        	eList = <<%a%
        button1
        button5
        buttondefaults
        buttonvendors
        %a%
        	
        	for each foo in eList
        		eval("topparent:"+foo+".Border.Color") =  "Gray-25"
        		eval("topparent:"+foo+".Font.Color")  = "Gray-25"
        		eval("topparent:"+foo+".disable()")
        	next
        	goto moveOn
        end if
        Alpha 5 Version 11
        AA Build 2999, Build 4269, Current Build
        DBF's and MySql
        Desktop, Web on the Desktop and WEB

        Ron Anusiewicz

        Comment


          #19
          Re: Button Security with groups and users

          Hi Stan,
          I see now as I would be the only one to ever see the message.

          So I did what you said and if I use statement ? a5_get_user_assignments("mpassword", "user_name") the user shows can_delete as a group.

          Now I put for form events on activate the xbasic code below and it doesn't seem to work

          '-Hide Delete button for users who are not in group can_delete
          if var->whch_bttns <> "can_delete" then
          control_button8.hide()
          end if

          Can you help wit what I am screwing up here?

          Thank you,
          Paul

          Comment


            #20
            Re: Button Security with groups and users

            I never suggested

            a5_get_user_assignments("mpassword", "user_name")

            my suggestion was

            A5_GET_USER_ASSIGNMENTS("themasterpassword,user_name()). This returns a list of groups to which the currently logged in user is assigned.

            '-Hide Delete button for the current user if they are not in group can_delete
            if "can_delete" !$ var->whch_bttns then
            control_button8.hide()
            end if
            There can be only one.

            Comment


              #21
              Re: Button Security with groups and users

              Originally posted by Ronald Anusiewicz View Post
              I used user_name() as it returns the name of the current user.
              In my case the current user is the name of a group.

              [ATTACH=CONFIG]45122[/ATTACH]

              I don't know how your application is handling the log in process. When someone logs in, are they
              logging in as an individual or as a group member.

              Alpha has a whole host of functions that handle security.
              It's just a matter of setting a global variable to whatever you need from the log in process.
              Then using that variable to manipulate the buttons on your forms.

              This is a portion of my code on the main menu OnActivate event.
              Depending in the result of the function user_name(), I grey out the appropriate buttons.

              Code:
              '--list of who has access to which buttons
              'button1 - utilities			        :admin, billing
              'button3 - maintenance invoice	:admin, billing, office
              'button4 - inventory			:admin, billing, office, mechanic, parts
              'button5 - mechanics			:admin, billing
              'button6 - po's				:admin, billing, office, parts
              'buttoncustomers				:admin, billing, office
              'buttondefaults				:admin, billing
              'buttonvendors				:admin, billing, parts
              'exitbutton
              
              ''Exclude parts button list
              if inlist2(var->vcUser, "Parts") = .t. then
              	eList = <<%a%
              button1
              button3
              button5
              buttoncustomers
              buttondefaults
              %a%
              	
              	for each foo in eList
              		eval("topparent:"+foo+".Border.Color")  = "Gray-25"
              		eval("topparent:"+foo+".Font.Color")  = "Gray-25"
              		eval("topparent:"+foo+".disable()")
              	next
              	goto moveOn
              end if
              
              ''Exclude office button list
              if inlist2(var->vcUser, "Office") = .t. then
              	eList = <<%a%
              button1
              button5
              buttondefaults
              buttonvendors
              %a%
              	
              	for each foo in eList
              		eval("topparent:"+foo+".Border.Color") =  "Gray-25"
              		eval("topparent:"+foo+".Font.Color")  = "Gray-25"
              		eval("topparent:"+foo+".disable()")
              	next
              	goto moveOn
              end if
              Hi Ronald,
              I have owner as an administrator and they handle creating user groups and user names themselves and the assign initial password.
              Once user logs in, they can change their password
              So the owner creates a group called managers, employees, etc. and then creates users and associates each one to a group.
              Now as owner I add a user named paul and assign him to managers group
              So paul is a manager now in alpha.
              So using Alphas login, I select from dropdown paul and enter pauls initial assigned password.
              In Stans case it is groups can delete, can edit, and can save with users being assigned whatever level of privileges they want

              If I understand what you are saying is you have users called parts, billing, admin, office, mechanic. The users are really departments (could be 3 individuals) with a common shared password for each individual department.
              I might be able to adopt your code, but use groups in place of users, but I get a true or false logging in as different users, but I have not gotten it to work right as I really don't have much knowledge to this.

              I assigned this little code to form and it doesn't seem to work right.
              For autoexec script I put:
              dim global whch_bttns as C
              whch_bttns = A5_GET_USER_ASSIGNMENTS("themasterpassword,user_name())

              on form I have on activate:
              '-Hide Delete button for users who are not in group can_delete
              if var->whch_bttns <> "can_delete" then
              control_button8.hide()
              end if

              If you have any thoughts on this, it would be helpful and after I eat, I plan to looks yours over and maybe I will see what I am doing wrong.
              I tried the other code you gave and that worked and I can hide the button I want.

              Thank you for your assistance in this!

              Paul

              Comment


                #22
                Re: Button Security with groups and users

                Originally posted by Stan Mathews View Post
                I never suggested

                a5_get_user_assignments("mpassword", "user_name")

                my suggestion was

                A5_GET_USER_ASSIGNMENTS("themasterpassword,user_name()). This returns a list of groups to which the currently logged in user is assigned.

                '-Hide Delete button for the current user if they are not in group can_delete
                if "can_delete" !$ var->whch_bttns then
                control_button8.hide()
                end if

                Hi Stan,

                I used what you said for global variable, autoexec script
                dim global whch_bttns as C
                whch_bttns = A5_GET_USER_ASSIGNMENTS("themasterpassword,user_name())

                I am simply saying after this if I log in as a user that is assigned can_delete and use the
                a5_get_user_assignments("mpassword", "user_name") in the interactive window it shows I have can_delete group assignment and I used the code on form

                '-Hide Delete button for users who are not in group can_delete
                if var->whch_bttns <> "can_delete" then
                control_button8.hide()
                end if

                and it does not seem to work when placed under form events onactivate

                Thank you,
                Paul

                Comment


                  #23
                  Re: Button Security with groups and users

                  Give this a try. Just run the autoexec.

                  If this doesn't get you over the hump, maybe you will need to put together a working example for us to look at.
                  Attached Files
                  Alpha 5 Version 11
                  AA Build 2999, Build 4269, Current Build
                  DBF's and MySql
                  Desktop, Web on the Desktop and WEB

                  Ron Anusiewicz

                  Comment


                    #24
                    Re: Button Security with groups and users

                    Originally posted by Stan Mathews View Post
                    I never suggested

                    a5_get_user_assignments("mpassword", "user_name")

                    my suggestion was

                    A5_GET_USER_ASSIGNMENTS("themasterpassword,user_name()). This returns a list of groups to which the currently logged in user is assigned.

                    '-Hide Delete button for the current user if they are not in group can_delete
                    if "can_delete" !$ var->whch_bttns then
                    control_button8.hide()
                    end if
                    Hi Stan,
                    As usual you had the answer to this.

                    Thank you so much. Now I can name the buttons for what they are and expand on your code and it should all work.

                    Thank you once again!

                    Paul

                    Comment


                      #25
                      Re: Button Security with groups and users

                      Originally posted by Ronald Anusiewicz View Post
                      Give this a try. Just run the autoexec.

                      If this doesn't get you over the hump, maybe you will need to put together a working example for us to look at.
                      Thanks Ron!

                      I missed Stans little line of code and that did the trick. My line didn't work for multiple user groups just one.
                      I will look at what you did as I really need to learn this stuff, but I am at retirement and this is something I decided to learn and keep me busy for some time.
                      Its something I always wanted to learn, but never did.

                      I appreciate all of yours and Stans patience with me along with all the others that help me slowly learn, just hope short term memory doesn't take over!

                      Thanks everyone, I really appreciate all your help!!!!!!!!!

                      Paul

                      Comment

                      Working...
                      X