Alpha DevCon 2018
Results 1 to 10 of 10

Thread: Security Framework Teaser

  1. #1
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,775

    Default Security Framework Teaser

    Jerry helped me many months ago to add some ability to my application where I wanted to be able to delete a user from Security Framework through a normal Grid. I recently revisited this concept to be able to toggle the user's Security Group also from a normal Grid; so I thought I would show how.

    If you use the Security Framework, you know the normal online method to delete a user from Security or to change their Security Group is to use a Dialog and some Event code. But take a look at the image below. That's an absolutely normal Grid with no tricks at all. However, if the user checks the Delete box and presses Submit, it deletes the user from Security Framework. Similarly, if they check or uncheck the "Mgr?" checkbox, it will toggle the user in or out of a particular Security Group.

    So for fun, and because I'd like to see who is interested, I thought I would offer this up as a teaser - any guesses as to how I do this?
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  2. #2
    Member EricN's Avatar
    Real Name
    Eric
    Join Date
    May 2007
    Location
    Minnesota
    Posts
    553

    Default Re: Security Framework Teaser

    Hello Steve,
    Not sure yet how you did that. Thanks, now you are making me rethink my current method :) I'm interested but don't tell yet!

    I also created a grid to delete the user's account. If the user no longer wishes to be a member, he/she goes to this grid. User must be logged in. This grid not only deletes the user from security but at the same time deletes all the user's records in all of the tables associated with said user.

    My pic may not look pretty (I'm now in the aesthetic stage of my development) but it does do the trick.

    Among other things, I have this in my CanDeleteRecord under events.

    dim tbl as P
    dim qry as P
    tbl = table.open("[pathalias.adb_path]\sites")
    'Perform a query to find user records for deletion.
    query.filter = "Userid =" + quote(session.__protected__userid)
    query.order = "Recno()"
    qry = tbl.query_create()
    tbl.delete_range()
    tbl.close()

    a5ws_Delete_User(session.__protected__userid) <-- deletes user from security

    Sorry if I went on a tangent on your thread... :(
    Last edited by EricN; 05-14-2008 at 05:12 PM.
    Eric

    Alpha Five Websites
    longlivepuppies.com
    socialservicenetwork.com
    -------------------------------------------------
    socialservicenetwork.org

  3. #3
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,775

    Default Re: Security Framework Teaser

    Nice! This "teaser" format may be a great way to discuss abstract concepts towards finding common or better solutions. Your approach is one way, but not how I approached it. I don't have any code in the Events. I get nervous about running extensive code in the Grid Events because I'm not sure I can adequately respond to errors.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  4. #4
    Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,501

    Default Re: Security Framework Teaser

    Whenever you wish to share the secret, we're all ears (and eyes).

  5. #5
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,775

    Default Re: Security Framework Teaser

    I'll show how to delete the record, but I was looking for a discussion rather than just posting the how-to. I must be overestimating the interest.

    This code goes in the A5W page and was originally provided by Jerry and I used the concept for other effects, like toggling the user's Security Groups. It will both delete the user from Security and the table associated with the Grid. What is significant about this (along with other tricks) is it lets you manage your Users in bulk a normal Grid rather than individually in Dialogs.

    Toggling the Security Group (which I don't show below) takes about five more lines of code because you need to know the user's current security groups before you can write back the new set along with the one you are toggling.

    Code:
    dim chkrows as n
    with tmpl_comp_viewusers
    	componentName = "comp_viewusers"
    	chkrows = rows
    end with 
    
    '' DELETE CODE 
    dim deletelist as c
    for i = 1 to chkrows
     if eval_valid("V.R"+alltrim(str(i))+".CheckBox_Delete") = .T. 'delete checked
      deletelist = deletelist + eval("V.R"+alltrim(str(i))+".userid") + crlf()  ' assuming the field was named 'ulink'
     end if
    next
    
    for each foo in deletelist
    	a5ws_delete_user(foo.value,request)
    next
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  6. #6
    Moderator
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,510

    Default Re: Security Framework Teaser

    I think that's a real nice technique Steve - appreciate you sharing it. I can predict a lot of uses for that.

    I know you wanted more discussion and speculation but dunno exactly how to have achieved that. Kinda hard to match Jerry's inventiveness...
    -Steve


  7. #7
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,775

    Default Re: Security Framework Teaser

    The key to being inventive it to know how Alpha Five works, not just working with Alpha. That, plus motivation towards constant improvement.

    With this teaser, I was trying to find another way of sharing and building knowledge, without just freely offering up everything I've labored over.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  8. #8
    "Certified" Alphaholic
    Real Name
    Mike Christensen
    Join Date
    Nov 2005
    Location
    Michigan U.P.
    Posts
    5,907

    Default Re: Security Framework Teaser

    Steve,
    I must be overestimating the interest
    I don't think so. The interest is there (here?), but believe that the expertise is not amongst most who frequent the board. I am very interested but for future reference only so far, given the time restraints I have currently.

    I know that you and Steve Workings are two who give quite a bit of the support the rest of the users who are trying to develop web applications get and want you both to know it is very much appreciated by me and am sure all others who have benefited from the expertise.

    I can only hope that I and others will pick up enough information that has been presented here in order to contribute some also...instead of just a few who are currently taking the teaching/helping task almost entirely by themselves...I have noticed a couple of other users here lately who also have been answering questions--just need maybe 10 more now!!
    Mike
    __________________________________________
    It is only when we forget all our learning that we begin to know.
    It's not what you look at that matters, it's what you see.
    Henry David Thoreau
    __________________________________________




  9. #9
    Member EricN's Avatar
    Real Name
    Eric
    Join Date
    May 2007
    Location
    Minnesota
    Posts
    553

    Default Re: Security Framework Teaser

    Quote Originally Posted by MikeC View Post
    ...and want you both to know it is very much appreciated by me and am sure all others who have benefited from the expertise.
    I concur. If it weren't for you guys, I would probably have given up!
    Eric

    Alpha Five Websites
    longlivepuppies.com
    socialservicenetwork.com
    -------------------------------------------------
    socialservicenetwork.org

  10. #10
    "Certified" Alphaholic CharlesParker's Avatar
    Real Name
    Charles Parker
    Join Date
    Dec 2012
    Location
    New Orleans, LA
    Posts
    1,781

    Default Re: Security Framework Teaser

    ever get the feeling your looking at a polar bear in a snow storm? I am always interested in new ideas and methods to do anything alpha5 - I just dont always know what I am looking at, lol. Having never really worked with the security framework beyond the point and click wysiwyg I am just staring at a black cat in a dark room - but at least I know its there!

Similar Threads

  1. Security Framework
    By Esio Trot in forum Application Server Version 8
    Replies: 0
    Last Post: 11-13-2007, 08:41 AM
  2. Using LDAP within Security Framework
    By StephenP in forum Application Server Version 8
    Replies: 2
    Last Post: 07-26-2007, 02:16 PM
  3. Security Framework - notes about V7 to V8
    By Steve Wood in forum Application Server Version 8
    Replies: 1
    Last Post: 05-01-2007, 05:24 AM
  4. Security framework
    By Bill Griffin in forum Application Server Version 8
    Replies: 2
    Last Post: 02-26-2007, 10:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •