Objects Security Permission

T

tsluu

Set dbs = CurrentDb
Set doc = dbs.Containers("Form").Documents("myForm")
doc.userName = "PowerUser"

doc.Permissions returned 196353

Based on the DAO Security Constants, I cant seem to find one that is equal
to 196353 or 393230. How can I get the different combinations to get 196353.
I understand it could be a combinations of dbSecReadDef or dbSecWriteDef...etc
 
T

Tom van Stiphout

On Mon, 11 May 2009 19:32:01 -0700, tsluu

Good question. It is very common in low-level programming that one
byte or one long (=4 bytes) is seen as a collection of bits. Let's use
an example. Say x = 23. Which bits are set?
23 can be written as 10111 (use Calculator and switch to
Scientific).
This value is read from right to left. The first bit is 1, so the
value so far is 1 (2^0). The second bit is 1, so we add 2^1 = 2, for a
total of 3. The third bit is 1, so we add 2^2 = 4 for a total of 7.
The 4th bit is 0 so we don't add anything. The 5th bit is 1 so we add
2^4 = 16 for a total of 23.
It also follows that all possible values of a byte are between 0
(00000000) and 255 (11111111) = 2^8-1

Now imagine that we have some constants:
READONLY = 1
SYSTEM = 2
HIDDEN = 4
ARCHIVE = 8
DIRECTORY = 16
etc.

If I wanted to use one byte to indicate a readonly directory that's
also a system directory and also hidden, I would write:
READONLY Or SYSTEM Or HIDDEN Or DIRECTORY
and that "Or's together" the values to add up to 23.

Now back to your question we need to do the reverse: given a value of
23, which bits are set? You can simply display in binary (10111) and
find out, or you can test using the bitwise And operator:
if (x And READONLY) then MsgBox("READONLY bit is set")
etc.
The result will be non-zero (not necessarily 1 or -1) if the bit is
set, and 0 if the bit is not set.

-Tom.
Microsoft Access MVP
 
T

tsluu

Hi Tom,

Im tryin to do an administration form for administrators to assign access
rights to certain forms, tables....etc for users and groups instead of doing
it direct from Tools->Securoty->User and Group Permissions.

I've managed to get all the DAO.PermissionEnum. Just that Im not really sure
which one to apply and when. For example to stop users from opening a form,
they must first hv access rights to access certain system tables like the
MSysUserList and then the permissions applied to stop them from opening the
form. Any help further would be greatly appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top