The following table represents the 32 bit positions available in a 32-bit byte. By using these positions you can assign up to 32 access control levels to the same user without depending on role lists (i.e. IsUserInRole() style). Storage and processing of a single 32-bit byte is demonstrated here in it's most basic form for easy digestion, however the use of single 32-bit byte is an optimal mathmatic calculation and storage method for tiered access controls.
| Bit Pos | Bin Val | Dec Val | Hex Val |
|---|---|---|---|
| 0 | [00000000000000000000000000000000] | 0 | 0 |
| 1 | [00000000000000000000000000000001] | 1 | 1 |
| 2 | [00000000000000000000000000000010] | 2 | 2 |
| 3 | [00000000000000000000000000000100] | 4 | 4 |
| 4 | [00000000000000000000000000001000] | 8 | 8 |
| 5 | [00000000000000000000000000010000] | 16 | 10 |
| 6 | [00000000000000000000000000100000] | 32 | 20 |
| 7 | [00000000000000000000000001000000] | 64 | 40 |
| 8 | [00000000000000000000000010000000] | 128 | 80 |
| 9 | [00000000000000000000000100000000] | 256 | 100 |
| 10 | [00000000000000000000001000000000] | 512 | 200 |
| 11 | [00000000000000000000010000000000] | 1024 | 400 |
| 12 | [00000000000000000000100000000000] | 2048 | 800 |
| 13 | [00000000000000000001000000000000] | 4096 | 1000 |
| 14 | [00000000000000000010000000000000] | 8192 | 2000 |
| 15 | [00000000000000000100000000000000] | 16384 | 4000 |
| 16 | [00000000000000001000000000000000] | 32768 | 8000 |
| 17 | [00000000000000010000000000000000] | 65536 | 10000 |
| 18 | [00000000000000100000000000000000] | 131072 | 20000 |
| 19 | [00000000000001000000000000000000] | 262144 | 40000 |
| 20 | [00000000000010000000000000000000] | 524288 | 80000 |
| 21 | [00000000000100000000000000000000] | 1048576 | 100000 |
| 22 | [00000000001000000000000000000000] | 2097152 | 200000 |
| 23 | [00000000010000000000000000000000] | 4194304 | 400000 |
| 24 | [00000000100000000000000000000000] | 8388608 | 800000 |
| 25 | [00000001000000000000000000000000] | 16777216 | 1000000 |
| 26 | [00000010000000000000000000000000] | 33554432 | 2000000 |
| 27 | [00000100000000000000000000000000] | 67108864 | 4000000 |
| 28 | [00001000000000000000000000000000] | 134217728 | 8000000 |
| 29 | [00010000000000000000000000000000] | 268435456 | 10000000 |
| 30 | [00100000000000000000000000000000] | 536870912 | 20000000 |
| 31 | [01000000000000000000000000000000] | 1073741824 | 40000000 |
| struct | |
|---|---|
| this0 | 00000000000000000000000000000000 |
| this1 | 00000000000000000000000000000001 |
| this10 | 00000000000000000000001000000000 |
| this11 | 00000000000000000000010000000000 |
| this12 | 00000000000000000000100000000000 |
| this13 | 00000000000000000001000000000000 |
| this14 | 00000000000000000010000000000000 |
| this15 | 00000000000000000100000000000000 |
| this16 | 00000000000000001000000000000000 |
| this17 | 00000000000000010000000000000000 |
| this18 | 00000000000000100000000000000000 |
| this19 | 00000000000001000000000000000000 |
| this2 | 00000000000000000000000000000010 |
| this20 | 00000000000010000000000000000000 |
| this21 | 00000000000100000000000000000000 |
| this22 | 00000000001000000000000000000000 |
| this23 | 00000000010000000000000000000000 |
| this24 | 00000000100000000000000000000000 |
| this25 | 00000001000000000000000000000000 |
| this26 | 00000010000000000000000000000000 |
| this27 | 00000100000000000000000000000000 |
| this28 | 00001000000000000000000000000000 |
| this29 | 00010000000000000000000000000000 |
| this3 | 00000000000000000000000000000100 |
| this30 | 00100000000000000000000000000000 |
| this31 | 01000000000000000000000000000000 |
| this4 | 00000000000000000000000000001000 |
| this5 | 00000000000000000000000000010000 |
| this6 | 00000000000000000000000000100000 |
| this7 | 00000000000000000000000001000000 |
| this8 | 00000000000000000000000010000000 |
| this9 | 00000000000000000000000100000000 |
In this test case we are going to add existing members of the structure (bytes) together. By adding these bytes together and then converting back to base 2 (binary) output you will see how multiple levels could be assigned to the same user.
| Test Case Binary | Test Case Decimal | Current Bit Binary | Current Bit Decimal | Result |
|---|---|---|---|---|
| [00000000000001001000010000000010] | 295938 | [00000000000000000000000000000000] | 0 | False |
| [00000000000001001000010000000010] | 295938 | [00000000000000000000000000000001] | 1 | False |
| [00000000000001001000010000000010] | 295938 | [00000000000000000000000000000010] | 2 | True |
| [00000000000001001000010000000010] | 295938 | [00000000000000000000000000000100] | 4 | False |
| [00000000000001001000010000000010] | 295938 | [00000000000000000000000000001000] | 8 | False |
| [00000000000001001000010000000010] | 295938 | [00000000000000000000000000010000] | 16 | False |
| [00000000000001001000010000000010] | 295938 | [00000000000000000000000000100000] | 32 | False |
| [00000000000001001000010000000010] | 295938 | [00000000000000000000000001000000] | 64 | False |
| [00000000000001001000010000000010] | 295938 | [00000000000000000000000010000000] | 128 | False |
| [00000000000001001000010000000010] | 295938 | [00000000000000000000000100000000] | 256 | False |
| [00000000000001001000010000000010] | 295938 | [00000000000000000000001000000000] | 512 | False |
| [00000000000001001000010000000010] | 295938 | [00000000000000000000010000000000] | 1024 | True |
| [00000000000001001000010000000010] | 295938 | [00000000000000000000100000000000] | 2048 | False |
| [00000000000001001000010000000010] | 295938 | [00000000000000000001000000000000] | 4096 | False |
| [00000000000001001000010000000010] | 295938 | [00000000000000000010000000000000] | 8192 | False |
| [00000000000001001000010000000010] | 295938 | [00000000000000000100000000000000] | 16384 | False |
| [00000000000001001000010000000010] | 295938 | [00000000000000001000000000000000] | 32768 | True |
| [00000000000001001000010000000010] | 295938 | [00000000000000010000000000000000] | 65536 | False |
| [00000000000001001000010000000010] | 295938 | [00000000000000100000000000000000] | 131072 | False |
| [00000000000001001000010000000010] | 295938 | [00000000000001000000000000000000] | 262144 | True |
| [00000000000001001000010000000010] | 295938 | [00000000000010000000000000000000] | 524288 | False |
| [00000000000001001000010000000010] | 295938 | [00000000000100000000000000000000] | 1048576 | False |
| [00000000000001001000010000000010] | 295938 | [00000000001000000000000000000000] | 2097152 | False |
| [00000000000001001000010000000010] | 295938 | [00000000010000000000000000000000] | 4194304 | False |
| [00000000000001001000010000000010] | 295938 | [00000000100000000000000000000000] | 8388608 | False |
| [00000000000001001000010000000010] | 295938 | [00000001000000000000000000000000] | 16777216 | False |
| [00000000000001001000010000000010] | 295938 | [00000010000000000000000000000000] | 33554432 | False |
| [00000000000001001000010000000010] | 295938 | [00000100000000000000000000000000] | 67108864 | False |
| [00000000000001001000010000000010] | 295938 | [00001000000000000000000000000000] | 134217728 | False |
| [00000000000001001000010000000010] | 295938 | [00010000000000000000000000000000] | 268435456 | False |
| [00000000000001001000010000000010] | 295938 | [00100000000000000000000000000000] | 536870912 | False |
| [00000000000001001000010000000010] | 295938 | [01000000000000000000000000000000] | 1073741824 | False |
Listed below are the binary roles detected by the BitAnd checking routine.
00000000000000000000000000000010,00000000000000000000010000000000,00000000000000001000000000000000,00000000000001000000000000000000