UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Advanced Custom Password    
 
   
dallr
post Jan 12 2007, 02:48 PM
Post #1

UtterAccess VIP
Posts: 3,071
From: The Land of the Access Ninja's



Hey Guys here is some custom security that i developed mid last year and now decided to share it with the bunch.

The security used here disables users from clicking on any control on any form you desire and also disables any reports you choose. You will have to assgin users to groups and set the permissions for the groups. You can gain great security flexibility by incorporating this into your apps.

You will also find a word document attached where you can get instructions on how to implement it in your application. To see the code in action extract the contents of the zip file to your C drive and open the Advanced Custom Password.mdb.
Log on information
All the passwords are the same 1234

Username: Steve
Username: Leslie
Username: Dane

Steve is an end user so his access is limited, Leslie is a poweruser and Dane is the administrator. Log on as Steve and Leslie and click the buttons on the main form and see how the access is restricted per user i.e (per group).

If you have any questions feel free to PM me with the details.

Dallr

EDIT 3/7/2007:

Hey guys i am just updating the .mda from this code. Someone sent me a PM and said that it was in 2003 file format and they wanted a copy in 2000 file format. As such I am including a security .mda in the 2000 file format.

So depending on what version of access you are using you will need to reference the relevant .mda.

I recommend using this code with Ricky's shift bypass utility found here ByPass Shift Key Utility So end users cannot use the shift key to gain access to your menus and objects

Dallr

The following is the code that is found in the .mda file:

CODE
[color="green"]'---------------------------------------------------------------------------------------

' Procedure : SecurityEnabled

' DateTime  : 2/20/2006 14:09

' Author    : Dane Miller

' Purpose   : To disable controls on forms and reports.

' Arguments : ObjectName is the Name of the form in question.

'             Object_type is the type of object "Form" or "Report"

' Returns   :

' Modification History:

' Who        When           WHY

'---------------------------------------------------------------------------------------[/color]



Public Function SecurityEnabled(TheUser As String, ObjectName As String, ByVal Object_Type As String)



Dim cnn As ADODB.Connection

Dim rst As ADODB.Recordset

Dim SQL As String, Arr_Index() As String

Dim RecCount As Integer, c As Integer

Dim frm As Object

Dim Frm_ctl As Object, Rpt_ctl As Object



'On Error GoTo handler

On Error Resume Next



Set cnn = CurrentProject.Connection

Set rst = New ADODB.Recordset



SQL = "SELECT tbl_ObjectControls.ControlName, tbl_UserAccess.UserName, tbl_ObjectControls.ObjectName " & _

"FROM (tbl_ObjectControls INNER JOIN (tbl_Groups INNER JOIN tbl_ControlsToDisable ON tbl_Groups.AccessTypeID = " & _

"tbl_ControlsToDisable.AccessTypeId) ON tbl_ObjectControls.ControlId = tbl_ControlsToDisable.ControlID) INNER JOIN " & _

"(tbl_UserAccess INNER JOIN tbl_AssignUsersToGroups ON tbl_UserAccess.MyID = tbl_AssignUsersToGroups.MyID) " & _

"ON tbl_Groups.AccessTypeID = tbl_AssignUsersToGroups.AccessTypeID " & _

"WHERE (((tbl_UserAccess.UserName)='" & TheUser & "') AND ((tbl_ObjectControls.ObjectName)='" & ObjectName & "'));"



rst.Open SQL, cnn, adOpenStatic

RecCount = rst.RecordCount



If RecCount > 0 Then

    ReDim Arr_Index(RecCount) As String ' get the maximum size of the array.

    ' pass the controls names in the table to the Array

    Select Case Object_Type

        Case "Form"

            Set Frm_ctl = Forms(ObjectName).Controls

            With rst

                For c = 1 To RecCount

                    Arr_Index(c) = rst.Fields("ControlName")

                    .MoveNext

                    Frm_ctl(Arr_Index(c)).Enabled = False

                Next

            End With

        Case "Report"

            MsgBox UCase(TheUser) & " you do not have permission to view this report."

            DoCmd.Close acReport, ObjectName

    End Select

End If



exit_handler:

    Exit Function



handler:

    Select Case Err.Number

        Case 2465 Or 438

            Resume Next

        Case 2450

            MsgBox Err.Description

            MsgBox "Please recheck the spelling of the object_type in the function SecurityEnabled on your form or report." & Chr(13) & _

                    "The form or report will open but no contols will be affected till the error is corrected."

        Case 2451

            MsgBox Err.Description & Chr(13) & "Please recheck the spelling of the name of your form or report in the function SecurityEnabled."

        Case Else

            MsgBox "Error Number  " & Err.Number & Chr(13) & "Error Description " & Err.Description

            Resume exit_handler

    End Select





'clean up



rst.Close

Set rst = Nothing

cnn.Close

Set cnn = Nothing



End Function

Attached File(s)
Attached File  Advanced Custom Password.zip ( 157.69K ) Number of downloads: 1112
 
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 24th May 2013 - 05:49 AM