Permissions - getting a meaningful output

S

Stapes

Hi

I have a bit of code that is meant to display the permissions
assigned
to different users. This is it:


Dim db As Database
Dim ctrLoop As Container
Set db = CurrentDb
Dim GrpUsrInfo As String
GrpUsrInfo = ""
For Each ctrLoop In db.Containers
With ctrLoop
GrpUsrInfo = GrpUsrInfo & "Container: " & .Name & vbCrLf
GrpUsrInfo = GrpUsrInfo & "User: " & .UserName & vbCrLf
GrpUsrInfo = GrpUsrInfo & " Permissions: " & .Permissions &
vbCrLf
GrpUsrInfo = GrpUsrInfo & " AllPermissions: " & _
.AllPermissions & vbCrLf
End With
Next ctrLoop
Me!GroupUserInfo = GrpUsrInfo


The resultant output displays a load of meaningless numbers. How can
I
get it to display the information in English?


Stapes
 
D

Douglas J. Steele

As the Help file explains it, the Permissions property is a Long Integer
that represents the concatenation of various constants that indicate
specific permissions.

You can write a function that Ands those various constants to the specific
permission and builds up the details:

Function PermDesc(PermValue As Long) As String
Dim strDesc As String

If PermValue = dbSecNoAccess Then
strDesc = "No Access"
Else
If (PermValue And dbSecFullAccess) <> 0 Then
strDesc = strDesc & "Full Access, "
End If
If (PermValue And dbSecDelete) <> 0 Then
strDesc = strDesc & "Delete Access, "
End If
If (PermValue And dbSecReadSec) <> 0 Then
strDesc = strDesc & "Read Security, "
End If

' You'll have to add in all of the other constants yoursef...

If Len(strDesc) > 0 Then
strDesc = Left$(strDesc, Len(strDesc) - 2)
End If
End If

PermDesc = strDesc

End Function
 
S

Stapes

As the Help file explains it, thePermissionsproperty is a Long Integer
that represents the concatenation of various constants that indicate
specificpermissions.

You can write a function that Ands those various constants to the specific
permission and builds up the details:

Function PermDesc(PermValue As Long) As String
Dim strDesc As String

If PermValue = dbSecNoAccess Then
strDesc = "No Access"
Else
If (PermValue And dbSecFullAccess) <> 0 Then
strDesc = strDesc & "Full Access, "
End If
If (PermValue And dbSecDelete) <> 0 Then
strDesc = strDesc & "Delete Access, "
End If
If (PermValue And dbSecReadSec) <> 0 Then
strDesc = strDesc & "Read Security, "
End If

' You'll have to add in all of the other constants yoursef...

If Len(strDesc) > 0 Then
strDesc = Left$(strDesc, Len(strDesc) - 2)
End If
End If

PermDesc = strDesc

End Function

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no private e-mails, please)










- Show quoted text -

Thank you - that makes more sense. This bit of code shows me all the
permissions set for the current user, but how do I show those related
to all the other users. Also, how do I show the permissions set for
all the specific forms, tables etc.

Stapes
 
S

Stapes

No - I want to code it, not use a package. I want to control what
information is being displayed, and present it in a user friendly
fashion.- Hide quoted text -

- Show quoted text -

Having said that I have downloaded and installed the CSD tools & it
looks good, if not a little verbose. My first test of the permissions
report ran to 66 pages.
 

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