C
Codemonkey
Hi,
I was wondering if there is any way to total a group of records by using a
bitwise OR function to get a combination of values?
For example
-----------
I have a "Users" table and a "Groups" table joined by a "Users_Groups" table
so that Users can belong to many groups and a group can have many users.
Each group has a long integer field called "Permissions" which is a bitmask
of the following values:
-1 =All Permissions
0 =No Permissions
1 =Logon Permission
2 =View Permission
4 =Edit Permission
8 =Delete Permission
If the permissions field for a group "Group1" was "3" then any users
belonging to that group would have Logon and View permissions. If the
permissions field for a group "Group2" was "4" then any users belonging to
that group would have Edit permissions. Any users belonging to both "Group1"
and "Group2" would have a permission value of 7 (Logon, View and Edit
permissions).
I want to get the permissions for a user by using a bitwise OR on the values
of the Permissions field for each group that the user belongs to. Simply
adding them together won't work (SUM) as two groups could have the same
perission which would cause the total to be invalid.
I'd appreciate any help anyone can give.
Cheers,
Trev.
I was wondering if there is any way to total a group of records by using a
bitwise OR function to get a combination of values?
For example
-----------
I have a "Users" table and a "Groups" table joined by a "Users_Groups" table
so that Users can belong to many groups and a group can have many users.
Each group has a long integer field called "Permissions" which is a bitmask
of the following values:
-1 =All Permissions
0 =No Permissions
1 =Logon Permission
2 =View Permission
4 =Edit Permission
8 =Delete Permission
If the permissions field for a group "Group1" was "3" then any users
belonging to that group would have Logon and View permissions. If the
permissions field for a group "Group2" was "4" then any users belonging to
that group would have Edit permissions. Any users belonging to both "Group1"
and "Group2" would have a permission value of 7 (Logon, View and Edit
permissions).
I want to get the permissions for a user by using a bitwise OR on the values
of the Permissions field for each group that the user belongs to. Simply
adding them together won't work (SUM) as two groups could have the same
perission which would cause the total to be invalid.
I'd appreciate any help anyone can give.
Cheers,
Trev.