Re: apply a Switchboard security

Tech-Archive recommends: Fix windows errors by optimizing your registry



hi Jeff,

thanks for your help it works great!
but actually i had included a user name to your previous code and it look
like this:

Private Sub cmdShowAdminArea_Click()
On Error GoTo ErrorPoint

If (Me.txtUser = "admin" And Me.txtPassword = "admin") Then
' Substitute with your own user and password between the quotes
Forms!Switchboard.Filter = "[ItemNumber] = 0 And [SwitchboardID] = 12"
Forms!Switchboard.Refresh
DoCmd.Close acForm, "frmPassword"
Else
If (Me.txtUser = "qiurong" And Me.txtPassword = "qiurong") Then
' Substitute with your own user and password between the quotes
Forms!Switchboard.Filter = "[ItemNumber] = 0 And [SwitchboardID] = 12"
Forms!Switchboard.Refresh
DoCmd.Close acForm, "frmPassword"
Else
MsgBox "Incorrect Password", vbExclamation, "Access Denied"
DoCmd.Close acForm, "frmPassword"
End If
End If

ExitPoint:
Exit Sub

ErrorPoint:
' Unexpected Error
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint

End Sub


now with your new code, i'm wondering how am i suppose to add in the user
name???
is there a way for it???

thanks in advance
Green

"Jeff Conrad" wrote:

> "'green'" wrote in message:
> news:69B31F50-04CB-4269-89D4-95E506E366F5@xxxxxxxxxxxxxxxx
>
> > Hi Jeff,
> >
> > i had did what you have listed and it work great!!!
> > but is there any way to make it case-sensitive??? like my password: "admin",
> > irregardless whether it is caps lock or not, i will still be able to open the
> > switchboard... which i don't really like about it...
> > perhaps i'm asking a rather stupid question... but i really new to codes...
>
> Hi Green,
>
> My apologies for not noticing this message earlier!
>
> Generally Access is not case sensitive, but your goal is certainly achievable.
> I'm assuming you followed all of my previous instructions to the letter.
>
> 1. Make a backup of your database
>
> 2. Copy and paste this code *over* your existing code behind the command
> button called cmdShowAdminArea:
>
> '*************** Code Start**********************
> Private Sub cmdShowAdminArea_Click()
> On Error GoTo ErrorPoint
>
> Dim strPassword As String
> Dim strEnteredPassword As String
> Dim intI As Integer
> Dim blnOk As Boolean
>
> strPassword = "password"
> ' Set our Boolean Variable to True as default
> blnOk = True
>
> If Len(Nz(Me!txtPassword, "")) = 0 Then
> ' Password field blank
> MsgBox "Please enter the administrative password " _
> & "before continuing.", vbExclamation, "Missing Password"
> ' Set the focus to the text box as a visual reminder
> Me.txtPassword.SetFocus
> Else
> ' Password entered so remember it
> strEnteredPassword = Me.txtPassword
>
> ' Check to see if the lengths are the same
> If Len(strPassword) <> Len(strEnteredPassword) Then
> ' Supplied password is not the same length
> MsgBox "The password you supplied is incorrect." _
> & vbNewLine & "Please see the Database Administrator " _
> & "for access to these functions.", vbExclamation _
> , "Access Denied"
> ' Close the form
> DoCmd.Close acForm, "frmPassword"
> Else
> ' Now do a case-sensitive comparison
> For intI = 1 To Len(strPassword)
> If Asc(Mid$(strPassword, intI, 1)) <> _
> Asc(Mid$(strEnteredPassword, intI, 1)) Then
> ' The two passwords are not the same case-wise
> MsgBox "The password you supplied is incorrect." _
> & vbNewLine & "Please see the Database Administrator " _
> & "for access to these functions.", vbExclamation _
> , "Access Denied"
> ' Set the boolean to false now
> blnOk = False
> ' Close the form
> DoCmd.Close acForm, "frmPassword"
> Exit For
> End If
> Next
> ' Now to test our boolean to see if it is still Ok to proceed
> If blnOk = True Then
> ' All set, close this form and open the Admin menu
> Forms!Switchboard.Filter = "[ItemNumber] = 0 And " _
> & "[SwitchboardID] = 2"
> Forms!Switchboard.Refresh
> DoCmd.Close acForm, "frmPassword"
> End If
> End If
> End If
>
> ExitPoint:
> Exit Sub
>
> ErrorPoint:
> ' Unexpected Error
> MsgBox "The following error has occurred:" _
> & vbNewLine & "Error Number: " & Err.Number _
> & vbNewLine & "Error Description: " & Err.Description _
> , vbExclamation, "Unexpected Error"
> Resume ExitPoint
>
> End Sub
> '*************** Code End**********************
>
> 3. Make sure you enter whatever password you want to use in the
> appropriate place (where it says strPassword = "password")
>
> 4. This assumes that the Admin Switchboard area you want to
> protect is number "2" in the Switchboard Items TABLE. Make
> sure to change that number to whatever matches your table
> value. This also assumes that the NAME of your switchboard
> form is actually just "Switchboard." Change the code if
> you have changed the name. Dress up the message box with
> whatever formatting and/or messages you desire.
>
> 5. Compile the code, save and close the form.
>
> Everything should be OK.
>
> Hope that helps,
> --
> Jeff Conrad
> Access Junkie
> Bend, Oregon
>
>
> > "Jeff Conrad" wrote:
> >
> > > Hi Ron,
> > >
> > > Sounds like the instructions I gave should work just fine in your
> > > case. When you are ready to move up to Access User Level
> > > Security I would recommend ALL of the following reading material.
> > > ULS is a difficult concept to grasp the first couple of times so
> > > it best to practice on dummy databases first.
> > >
> > > Access User-Level Security:
> > >
> > > Security FAQ (the Security Bible):
> > > http://support.microsoft.com/?kbid=207793
> > >
> > > Jack Macdonald's Security Document:
> > > http://www.geocities.com/jacksonmacd/AJMAccessSecurity.pdf
> > >
> > > Lynn Trapp's Ten Security Steps:
> > > http://www.ltcomputerdesigns.com/Security.htm
> > >
> > > Joan Wild's Tips:
> > > http://www.jmwild.com/security02.htm
> > >
> > > The Security Whitepaper is also worth reading:
> > > http://support.microsoft.com/?id=148555
> > >
> > > Keith Wilby's Instructions (See step-by-step link)
> > > http://www.keithwilby.com/
> > >
> > > Other Good Information:
> > > http://www.access-experts.com/default.aspx?selection=TutorialSecurity&sm=18
> > >
> > > Other Microsoft KB articles of interest:
> > >
> > > Description of how to help protect a Access 2000 database:
> > > http://support.microsoft.com/?id=254372
> > >
> > > Description of the role of workgroup information files in Access security:
> > > ACC97: http://support.microsoft.com/?id=303941
> > > ACC2000: http://support.microsoft.com/?id=305541
> > > ACC2002/2003: http://support.microsoft.com/?id=305542
> > >
> > > --
> > > Jeff Conrad
> > > Access Junkie
> > > Bend, Oregon
> > >
> > > "Ron P" <atcwi@xxxxxxxxxxx> wrote in message
> > > news:B41163FA-1B15-4AD1-A501-56B44F2E2B07@xxxxxxxxxxxxxxxx
> > >
> > > > Hi Jeff,
> > > > The users of this Access database are generally low tech users. They
> > > > have very little to no knowledge of Access. The one otyher person that does
> > > > is leaving my office for a job transfer, but if that falls through he is the
> > > > designated back-up person for Access repair or changes to databases. This
> > > > therefore does not appear to be an issue. If you want to post those links
> > > > that would help me read up on things more. I will give your solution a try,
> > > > it looks like it will work fine for what we need. Thanks
> > > >
> > > > "Jeff Conrad" wrote:
> > > >
> > > > > "Ron P" <atcwi@xxxxxxxxxxx> wrote in message
> > > > > news:F348A6FD-1246-4A17-9786-AD86DBBF67DD@xxxxxxxxxxxxxxxx
> > > > >
> > > > > > I have a Switchboard that was created by Access Switchboard utility.
> > > > > > Everything works great. What I have been told now is that one of the buttons
> > > > > > I created needs to have a security measure placed on it so only management
> > > > > > can click on the button and move on to the next Switchboard. How can I do
> > > > > > this or is there a way to apply security to one button on a Switchboard.
> > > > > > This user and pass can be hard coded
> > > > >
> > > > > Hi Ron,
> > > > >
> > > > > Any kind of "Developer-implemented" security/password
> > > > > schemes are really not all that secure. Implementing full-
> > > > > blown Access User Level Security is really the *best* way
> > > > > to go if you want to have some security built into your
> > > > > application. It is a difficult and challenging task to implement
> > > > > the first couple of times, so it is best to thoroughly read up
> > > > > on the subject before beginning and practice on "dummy"
> > > > > databases. If you would like some links on the subject, post
> > > > > back and I'll provide a few for you.
> > > > >
> > > > > OK, having said the above, I also believe that there are times
> > > > > and places when ULS is way too much overkill. If the data
> > > > > is not ultra-sensitive and/or you have really low-tech users, a
> > > > > *simple* security system can be more than sufficient. I have
> > > > > done this before many times in the past.
> > > > >
> > > > > So what you are looking for is to integrate something with the
> > > > > built-in Switchboard Manager, correct? Here is a past post of
> > > > > mine on this subject (modified just a bit) which should do exactly
> > > > > what you are looking for. As long as you the developer fully
> > > > > understand the limitations of this setup, then you may proceed.
> > > > >
> > > > > >>>>
> > > > > Make a backup of your database BEFORE beginning!
> > > > >
> > > > > 1. Create a new small password form with the following properties:
> > > > >
> > > > > -Scroll Bars No
> > > > > -Record Selectors No
> > > > > -Navigation Buttons No
> > > > > -Dividing Lines No
> > > > > -Auto Center Yes
> > > > > -Pop Up Yes
> > > > > -Modal Yes
> > > > > -Border Style Thin
> > > > > -Control Box No
> > > > > -Min Max Buttons None
> > > > > -Close Button No
> > > > > -Shortcut Menu No
> > > > >
> > > > > Name the form frmPassword.
> > > > >
> > > > > Add a text box on this form called txtPassword with an Input Mask
> > > > > of "Password" (without the quotations).
> > > > >
> > > > > Add a label called lblPassword and have the caption say
> > > > > something like "Please Enter Administrator Password."
> > > > > Position just above the text box.
> > > > >
> > > > > Add a command button called cmdCloseForm that simply
> > > > > closes the form; nothing else in that code. Like so:
> > > > >
> > > > > 'Code Start
> > > > > Private Sub cmdCloseForm_Click()
> > > > > On Error GoTo ErrorPoint
> > > > >
> > > > > DoCmd.Close acForm, "frmPassword"
> > > > >
> > > > > ExitPoint:
> > > > > Exit Sub
> > > > >
> > > > > ErrorPoint:
> > > > > ' Unexpected Error
> > > > > MsgBox "The following error has occurred:" _
> > > > > & vbNewLine & "Error Number: " & Err.Number _
> > > > > & vbNewLine & "Error Description: " & Err.Description _
> > > > > , vbExclamation, "Unexpected Error"
> > > > > Resume ExitPoint
> > > > >
> > > > > End Sub
> > > > > ' Code End
> > > > >
> > > > > Add another command button called cmdShowAdminArea with
> > > > > a caption of "OK" or something similar and enter the following code
> > > > > into the Click event for this button:
> > > > >
> > > > > 'Code Start
> > > > > Private Sub cmdShowAdminArea_Click()
> > > > > On Error GoTo ErrorPoint
> > > > >
> > > > > If Me.txtPassword <> "password" Then
> > > > > ' Substitute with your own password between the quotes
> > > > > MsgBox "Incorrect Password", vbExclamation, "Access Denied"
> > > > > DoCmd.Close acForm, "frmPassword"
> > > > > Else
> > > > > Forms!Switchboard.Filter = "[ItemNumber] = 0 And [SwitchboardID] = 2"
> > > > > Forms!Switchboard.Refresh
> > > > > DoCmd.Close acForm, "frmPassword"
> > > > > End If
> > > > >
> > > > > ExitPoint:
> > > > > Exit Sub
> > > > >
> > > > > ErrorPoint:
> > > > > ' Unexpected Error
> > > > > MsgBox "The following error has occurred:" _
> > > > > & vbNewLine & "Error Number: " & Err.Number _
> > > > > & vbNewLine & "Error Description: " & Err.Description _
> > > > > , vbExclamation, "Unexpected Error"
> > > > > Resume ExitPoint
> > > > >
> > > > > End Sub
> > > > > ' Code End
> > > > >
> > > > > This assumes that the Admin Switchboard area you want to
> > > > > protect is number "2" in the Switchboard Items TABLE. Make
> > > > > sure to change that number to whatever matches your table
.


Quantcast