There are multiple permission levels in the permission assignment, and different users have multiple different permissions.
Forum's permissions:
View, post, poll, search
User's permissions:
User A: View, post
User B: viewing
User c: View, post, poll, search
Analysis:
There are four different permission levels, a total of 2^4 types of permissions to assign.
Like this, permission level partitioning and the rights assignment of different levels of users is the best choice by using the binary method of permission assignment authentication. That is, each operation permission is represented by a binary number (1, 10, 100, 1000). The total permission type is 2^n, and N is the permission category. In C #, a long type has 64 bits, so there are 64 categories of permissions, 2^64 how to assign permissions. The allocation, deletion, and viewing of permissions are implemented by binary arithmetic.
Long userrolevalue;//user's permission to operate
Long oprolevalue;//permissions for an action
1. Allocation of permissions (or operations)
Userrolevalue = Userrolevalue | Oprolevalue
(00001110) 2 = (00000010) 2| (00000100) 2| (00001000) # 2