Passwording Various Levels of Switchboards

  • Thread starter Thread starter jdthomas_gmac
  • Start date Start date
J

jdthomas_gmac

I am building a switchboard in which I want main users have access only
to the main switchboard. How do I password my drill down button to
keep unwanted users from accessing lower switchboards? Thanks!
 
If you have implemented user-level security, then it won't matter. Users
will not be able to access any objects to which they do not have access.

I don't think you can build security for the built in switchboard. If you
are building your own menu system using a series of forms, then you would
just exclude access from the ones that you don't want people to open.

So, if you have a form called "MenuManagerReports" then only give access to
your managers. If they don't have access to the particular form (menu) then
they won't be able to open it.
 
I am building a switchboard in which I want main users have access only
to the main switchboard. How do I password my drill down button to
keep unwanted users from accessing lower switchboards? Thanks!

If you want to be more polite to the user and not temp them with buttons
that will return nasty messages telling them that they're not allowed to go
there, you could disable buttons based using code in the forms open event.

I just finished writing this simple function to check to see if a user is in
a specific group:

Public Function UserIsInGroup(strGroup As String) As Boolean

Dim wks As DAO.Workspace
Dim dbUser As DAO.User
Dim fRetVal As Boolean

On Error GoTo Err_UserIsInGroup

Set wks = DBEngine.Workspaces(0)

For Each dbUser In wks.Groups(strGroup).Users
If dbUser.Name = CurrentUser() Then
fRetVal = True
End If
Next

Exit_UserIsInGroup:
UserIsInGroup = fRetVal
Exit Function

Err_UserIsInGroup:
MsgBox "An unexpected error has ocurred when trying to determine if the
current " _
& "user '" & CurrentUser() & "' is in the group '" & strGroup &
"'.", vbInformation, "Unexpected Error"
fRetVal = False
Resume Exit_UserIsInGroup

End Function

In the open event of your main switchboard, you could call this function to
decide whether or not to enable a button.

cmdYourButton.Enabled = UserIsInGroup("Managers")

I think that should work but I haven't had much time to test it. Like I
said, I just wrote it. The timing of your question was amazing. I wrote this
function about 15 minutes ago to use at startup to determine which
switchboard form to open.

I hope this helps. I'm just learning some of this myself so if anyone finds
errors in my code or logic, please don't hesitate to point them out.
 
I forgot to add, you should still secure your other forms the way Rick B
suggests. My suggestion is just intended to make your application
friendlier, it's not enough to guarantee the security you want.
 
Ouch, lets cut that function down a bit!

Public Function UserIsInGroup(strGroup As String) As Boolean
dim s as string
on error resume next
s = dbengine(0).groups(strGroup).users(currentuser()).name
UserIsInGroup = (err.number = 0)
end function

TC :-)
 
Thanks TC, I guess I spend too much time reading documentation. I'm so used
to seeing everything done the hard way that it's rubbing off on me.
 
Tom said:
If you want to be more polite to the user and not temp them with
buttons that will return nasty messages telling them that they're not
allowed to go there, you could disable buttons based using code in
the forms open event.

I think a disabled button is just as unfriendly. I would suggest you set
the visibility of the button to false instead.
 
IMO it depends on whether you'd want to encourage or discourage the
user from applying to be upgraded so he can use that button.

If you want to /encourage/ him to ask to be upgraded, disabling the
button would be the way to go. Then he knows it's there, so perhaps he
could use it. But if you wanted to /discourage/ him from asking to be
upgraded, making it invisible would be better, because then he does not
even know it's there.

TC
 
Back
Top