简体   繁体   English

如何将Bitwise用于安全组

[英]How to use Bitwise for security groups

I'm sure i've done this before, but I can't remember how to do it and I cannot find any help. 我确定我之前已经做过,但是我不记得该怎么做,也找不到任何帮助。

If I have the following security access: 如果我具有以下安全访问权限:

1: Read
2: Write
4: Delete
8: View

A user can have a combination of any of these, say Write and View, so their security number would be 10. 用户可以将所有这些内容结合使用,例如Write和View,因此他们的安全号码为10。

How can I check it against each security group to see if they have access? 如何针对每个安全组进行检查,以查看它们是否具有访问权限?

I thought it was 2 MOD 10 but this doesn't appear to work. 我以为是2 MOD 10,但这似乎行不通。

What is the simplest way to approach this issue? 解决此问题的最简单方法是什么? Am I missing a bitwise operation? 我是否缺少按位操作?

您将AND与适用的数字进行核对,然后检查它是否大于0,即10&2> 0,因此您具有写许可权。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM