I have defined DWord-Values for 32bit Flag-Options as followed:
GRP_GUESTS = $1
GRP_NORMAL_USERS = $2
GRP_POWER_USERS = $4
GRP_BACKUP_OPERATORS = $8
GRP_ADMINISTRATORS = $10
These constant symbols are used to store permission information on specific users.
Now, I want to write a method that checks these permissions and looks like this:
function hasPermission(NeedsGroups, hasGroups: DWord): Boolean;
but I am not sure, how it's supposed to look like. I got this so far:
if NeedsGroup = hasGroups then
Result := True;
now, can I avoid using many, many IFs with something like this to check if the current rights are less than the ones needed ?
if NeedsGroups > hasGroups then
Result := False ??
The second question is:
Before I call this method, i need to specify the rights required to complete it. Instead of setting the bits "manually" like
DummyVar := (DummyVar or GRP_ADMINISTRATOR)
can i define it in a CONST-Symbol ? Something like
GROUPS = (GRP_ADMINISTRATOR SHL ????????????) ????
.. and then pass this Const to the method's NeedGroups-Parameter ?