G
Guest
Hello all.
I'm currently in the middle of writing a web app and I've come to some
security aspects that I'd appreciate some help with.
I'd like to use some form of BitWise opration on the persons security. For
example, if the following permissions exist in the system:
0: None
1: Add Member
2: Edit Member
4: Delete Member
8: Add Company
16: Edit Company
32: Delete Company
and my user had permissions to Add and Edit a member, they would have the
number 3 (1 + 2) associated with them, another user may have permissions
number 12, to delete a member and add a company.
But how do i effectivky 'decode' this number. So if i pass 12 to some
method, how do I work out that it evaluates to Delete a member and Add a
company?
Any help, or indeed other ideas and example would be much appreciated.
Thanks all,
Jon
I'm currently in the middle of writing a web app and I've come to some
security aspects that I'd appreciate some help with.
I'd like to use some form of BitWise opration on the persons security. For
example, if the following permissions exist in the system:
0: None
1: Add Member
2: Edit Member
4: Delete Member
8: Add Company
16: Edit Company
32: Delete Company
and my user had permissions to Add and Edit a member, they would have the
number 3 (1 + 2) associated with them, another user may have permissions
number 12, to delete a member and add a company.
But how do i effectivky 'decode' this number. So if i pass 12 to some
method, how do I work out that it evaluates to Delete a member and Add a
company?
Any help, or indeed other ideas and example would be much appreciated.
Thanks all,
Jon