Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password protection 1

Status
Not open for further replies.

prutzler

Technical User
Aug 16, 2001
2
GB
I have just been dumped with this problem and would appreciate any help. In the company there is already a password login system setup, i say this but it actually doesn't work!!

We have a table created with all the employees listed and their passwords, also if they have 'edit' or 'read' access. A module has also been created, here is the coding:


Option Compare Database
Option Explicit
Dim db As Database
Dim rsPasswords As Recordset
Dim strCriteria As String
Public strUserName As String

Function Security(strPassword As String) As Boolean
Security = True
Set db = CurrentDb
Set rsPasswords = db.OpenRecordset("Passwords", dbOpenDynaset)

strCriteria = "Password Like '" & strPassword & "'"
rsPasswords.FindFirst strCriteria
If rsPasswords.NoMatch Then
Security = False
Exit Function
Else
strUserName = rsPasswords!UserName
'strBusinessUnit = rsPasswords!BusinessUnit
Select Case rsPasswords!Permission
Case "Database Administrator"
DoCmd.OpenForm "frmSwitchboardDBAdmin"
Security = True
'Case "Application Administrator"
'DoCmd.OpenForm "frmSwitchboardApplicationAdmin"
Case "Edit"
DoCmd.OpenForm "frmSwitchboard"
Security = True
Case "Read"
DoCmd.OpenForm "frmSwitchboard"
Security = True
End Select
End If
End Function

'************************************
' used for data ownership security

Function UserName()
UserName = strUserName
End Function



Not too sure where to start, maybe the coding needs to be changed in some way??? Any help would be excellent,

cheers

Paul
 
Hi, Paul!

In this case I would do little other:

Example for opening different forms by pushing commandbuton <cmdOpenForm> on start form.

Private Sub cmdOpenForm_Click()
Select Case [/b]Security(&quot;MyUserName&quot;, &quot;MyPassword&quot;)[/b]
Case &quot;Database Administrator&quot;
DoCmd.OpenForm &quot;frmSwitchboardDBAdmin&quot;
Case &quot;Edit&quot;
DoCmd.OpenForm &quot;frmSwitchboard&quot;
Case &quot;Read&quot;
DoCmd.OpenForm &quot;frmSwitchboard&quot;
Case Else 'Case &quot;&quot;
MsgBox &quot;You have not permissions for opening of any form!&quot;, vbCritical, &quot;Permission denied...&quot;
End Select
End Sub
'-------------------------------


Function Security(strUserName As String, strPassword As String) As String
'It would be good that this function confirm both needed parameters: UserName and Password
Dim rsPasswords As Recordset
Dim strCriteria As String

Set rsPasswords = CurrentDb.OpenRecordset(&quot;Select * From Passwords;&quot;, dbOpenDynaset)

strCriteria = &quot;UserName='&quot; & strUserName & &quot;' And Password = '&quot; & strPassword & &quot;'&quot;
rsPasswords.FindFirst strCriteria
If rsPasswords.NoMatch Then
Exit Function
Else
Security = rsPasswords!Permission
End If
End Function


Aivars

P.S. I don't understand yet why don't you want to craete User and Group Account file (.MDW) for users permissions administration. It's so simply!

In addition using of DB table for Users permission accounting don't ensure the security of these data: anybody application user (even every Jack which isn't app user if DB isn't secured by password) can open your table and take all information about your app users.

Here is site's address for learning more about MS Access Workgroup Administration:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top