Security issue

  • Thread starter Thread starter JPL
  • Start date Start date
J

JPL

Hello,
I would like to hide some buttons depending on machine's IP address or
name.Is there a way todo this? If so, how?
TIA
JPL

Access XP-> SQL 2k
 
Environ("ComputerName") will return the machine name; likewise,
Environ("UserName") will return the Windows logon name, so you could use
either. It can be argued that the environment variables are fairly easy
to change, but the average user hasn't got a clue what they are, let
alone how to do it... even more so if they don't know you are using them
to customize their forms at runtime. I use this technique widely (with
Win logon name).
Now, to do it, you will need some simple code behind the form's On Open
event, like:

If Environ("UserName") = "XYZ" Then
Me.control1.Enabled = True
Me.control2.Enabled = True
End If

which assumes the controls as Enabled = No in the form design. Instead
of hardcoding, you could use a table (tblUserRights) with a username
field (fldUser) and a yes/no field (fldAllow) for enabled, and modifythe
code above as follows:

vUser = Environ("UserName")
vStatus = DLookup("[fldAllow]","tblUserRights","[fldUser]='" & vUser & "'"
If Environ("UserName") = "XYZ" Then
Me.control1.Enabled = vStatus
Me.control2.Enabled = vStatus
End If

You could use more fields in the table for different controls, so each
user could have a different combination if required... just make sure
the users can't touch the table!

HTH,
Nikos
 
Back
Top