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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Passwords

Status
Not open for further replies.

MySki

Technical User
Feb 20, 2003
77
US
Good morning

I have a database in which I set up user-level security which users access via the desktop shortcut. Is there any way to set up the database so the user can change their login password (without going into the backend) or must this be done by the Administrator.

Thanks!!
 
There's no need to go into the back end. The security permission levels data is stored in the database, and the users, groups, and passwords data is stored in the mdw. So if a user changes his or her password in one database, that change will filter through to all databases (including the front end and back end) that use the same MDW file.

Just make sure the user has access to the security menu in the front end and you'll have no problems with users no being able to change their passwords.

I generally keep users out of that menu item, just because I don't want them even getting any ideas of what they could do with that, so I build a form to let them change their passwords.

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Access Databases for Non-Profit Organizations

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Excuse me if this is a stupid question...

When you build your form to have them change passwords, what table are you pulling the records from?? Where does Access store the secured IDs and passwords when you use the wizard.

I would rather not allow access to the security menu either

Sorry if I am missing the obvious...thanks
 
No, not a stupid question at all. It doesn't get the data from a table. There's code in the Security FAQ (copy of it on my website) that allows a user to change his or her password. Here's my version of that code:

Public Function ChangePassword(sOldPwd As String, sPwd1 As String, sPwd2 As String)
'(c)Copyright 2/6/01 Jeremy Wallace
On Error GoTo Error
Dim wsp As Workspace
Dim uUser As User

Set wsp = DBEngine.Workspaces(0)
Set uUser = wsp.Users(CurrentUser)
If sPwd1 = sPwd2 Then
uUser.NewPassword sOldPwd, sPwd1
DoCmd.Close
Forms!frmswitchboard.Visible = True
Else
Call MsgBox("The passwords did not match. Please try again.", vbOKOnly + vbInformation, _
"Data Conflict")
End If
Exit Function
Error:
Select Case Err.Number
Case 3033 'wrong current password
Call MsgBox("The current password you entered is not correct. Please try again, _
vbOKOnly + vbInformation, "Data Conflict")
Case Else
ErrorTrap Err.Number, Err.Description, "ChangePassword"
End Select
End Function

(The ErrorTrap function is something I use in my databases. You'll probably want to rewrite that bit. It's up on my website if you want to use it, though.)

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Access Databases for Non-Profit Organizations

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
So, I need to develop my change password form with the fields sPswd1 and sPswd2 (for example). Would I then put this code in the AfterUpdate event for sPswd2?

I'm assuming wsp.User would pull in the current User ID and show this as a field?

Am I on the right track?
 
You're very close. It doesn't really matter what the controls on the form are named. You'll call it in this format:
Call ChangePassword(me!ControlWithOldPassword, me!ControlWithNewPassword, me!ControlWithNewPasswordConfirmation)

wsp.users(CurrentUser) points Access to the current user in the workgroup. You're using it here to set a variable of type User. CurrentUser is a built-in function that returns the user's name. But in this case we need to change attributes of the user, so we need to actually point at the user object, not just know the name.

Jeremy

PS: PLEASE make backups before getting into this code. If you change your admin password to something random, you'll be kind of bummed!

==
Jeremy Wallace
AlphaBet City Dataworks
Access Databases for Non-Profit Organizations

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Be sure that on your "change password" form, that you disable Autocorrect on the textboxes. That way, it doesn't fix grammatical or spelling errors in the user's password. I think we can all see the value in that.


Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top