Well, you're not limited to 5 levels, but rather 31; if you feel confident
that will be enough then you're set.

Your second approach works IF you can always assume that all the security
levels are either lesser or greater than the new one you want to add, never
"equal".  But if you need to have two security levels, one with rights to
read pages about accounting projects (but not construction projects) and the
other with rights to read pages about construction projects (but not
accounting projects), which gets the higher number?

-----Original Message-----
From: Paul Smith [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 10, 2001 12:13 PM
To: CF-Talk
Subject: RE: Bit Masks


Thanks for the list tip!

I'm just now developing an application using CF's BitAnd() function.

In my application, I currently have the following permission levels:

Level      User        Description
            Permission
            DB value for
            BitAnd

1          1           Public - future permission level
                        READ selected pages
2          3           Basic Project Read User
                        Read all pages
4          7           Basic Project Content User
                        Read all, Add/Update selected data
8          15          Project Manager User
                        Read all, Add/Update all
16         31          me ;-)

Since a User with a larger permission value must also have the access all 
Users with lesser permission values do, CF's BitAnd enables only 5 
permission levels.  I'm concerned the client might come up with additional 
permission levels/groups in the future, thereby defeating my use of BitAnd, 
and forcing me to modify code/user database/client database to use a list 
instead of BitAnd.

Or have I missed a clever way to use BitAnd?

best,  paul


PS> It sure helps to ask for help;-)  Now that I've done so, I think the 
simple solution to my problem is not to use BitAnd, but just adopt a 
sequence of increasing numbers, for example: 5, 10, 15, 20, 25, etc (go by 
5's to allow future insertion of new intermediate permission levels), and 
verify a User's permission is greater than a target.  That way, I still 
only need to store a single number in the database as with BitAnd, and 
don't need to go to using a list.  Any comments?


At 10:48 AM 5/10/01 -0400, you wrote:
>Bit masks are cool, but remember that there is a limit to how much info you
>can pack in a bitmask because CF doesn't let you use the bit functions on
>anything of more than 32 bits.  I have taken to using lists for this sort
of
>thing because there's no practical limit to how many items it can contain
>and there are lots of useful list functions in CF.
>
>
>-----Original Message-----
>From: Ken Monroe [mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, May 09, 2001 4:54 PM
>To: CF-Talk
>Subject: Bit Masks
>
>
>Hello!
>
>I believe that someone once gave a presentation at one of the CFUGs about
>using bit masks, also know as Right Bit AND, to set up security access
>levels.  This wasn't the same as the presentation at the Fig Leaf site
>that's slight more oriented towards hierarchy uses.  I've looked at all the
>CFUG sites linked to from the Allaire site but I can't find the
>presentation.  Does anyone recall where the presentation was made and/or
how
>to get the presentation file?
>
>Thx
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to