Board index » Visual Studio » Advanced function for rights management

Advanced function for rights management

Visual Studio2
Hi



Sometimes VB uses numbers (2^n) in arguments (eg. MsgBox). One all has to provide a single number to identify the correct combination



I would also like to implement this kind of functionality for rights management. Let's say I have n forms that would be identified by numbers 1 (2^1), 2 (2^1), 4 (2^2), 8 (2^3), ..., 2^n.

Each user would be assigned a single number that would tell which forms he has access to - the number would be the sum of the numbers of the forms. So if his rights' number would be 6, he would have acces to form 2 and form 4



What I would like to do is to have a function, thah would automatically tell if the user has right to access a certain form - based on form number and rights' number



Does anybody knows what would that function be



Thanks

Bostjan


-
 

Re:Advanced function for rights management

The AND function is designed for this. When applied to longs it does a

bit-wise ANDing of the two arguments.



The form would have a defined value, like Const FormID as long = 32



You test whether the user has access to the form using



If (UserValue AND FormID)>0 then ....







"Bostjan" <anonymous@discussions.microsoft.com>wrote in message

Quote
Hi!



Sometimes VB uses numbers (2^n) in arguments (eg. MsgBox). One all has to

provide a single number to identify the correct combination.



I would also like to implement this kind of functionality for rights

management. Let's say I have n forms that would be identified by numbers 1

(2^1), 2 (2^1), 4 (2^2), 8 (2^3), ..., 2^n.

Quote
Each user would be assigned a single number that would tell which forms he

has access to - the number would be the sum of the numbers of the forms. So

if his rights' number would be 6, he would have acces to form 2 and form 4.

Quote


What I would like to do is to have a function, thah would automatically

tell if the user has right to access a certain form - based on form number

and rights' number.

Quote


Does anybody knows what would that function be?



Thanks,

Bostjan





-

Re:Advanced function for rights management

On Wed, 2 Jun 2004 00:56:02 -0700, "=?Utf-8?B?Qm9zdGphbg==?="

<anonymous@discussions.microsoft.com>wrote:



Quote
Hi!



Sometimes VB uses numbers (2^n) in arguments (eg. MsgBox). One all has to provide a single number to identify the correct combination.



I would also like to implement this kind of functionality for rights management. Let's say I have n forms that would be identified by numbers 1 (2^1), 2 (2^1), 4 (2^2), 8 (2^3), ..., 2^n.

Each user would be assigned a single number that would tell which forms he has access to - the number would be the sum of the numbers of the forms. So if his rights' number would be 6, he would have acces to form 2 and form 4.



What I would like to do is to have a function, thah would automatically tell if the user has right to access a certain form - based on form number and rights' number.



Does anybody knows what would that function be?



If (N And 4) = 4 Then

-

Re:Advanced function for rights management

"Jezebel" <dwarves@heaven.com.kr>wrote in message

Quote
The AND function is designed for this. When applied to longs it does a

bit-wise ANDing of the two arguments.



just to clarify... when applied to ANY data type it does a bitwise AND of

the two arguments (it's just that behind the scenes it's doing any necessary

conversion to get the two values)



www.mvps.org/vb/tips/truth.htm">www.mvps.org/vb/tips/truth.htm



--

Reply to the group so all can participate

VB.Net... just say "No"



-

Re:Advanced function for rights management



"Bostjan" <anonymous@discussions.microsoft.com>wrote in message



Quote
Sometimes VB uses numbers (2^n) in arguments (eg. MsgBox). One all

has to provide a single number to identify the correct combination.



For reference, these are called "flags," and to examine them you use a

technique called "masking." You'll also hear terms like "bitmask" and "bit

field."





-