Code for password change and delete user

P

Paul Doree

Hi,

I'm working on some changes to the security of an Access XP DB, and need
some code to allow a user to change their password via a simple form (users
are already created and assigned permissions).

I also need a sample of code for deleting a user from the collection of
users.

Can anyone help?

Paul
 
A

Arvin Meyer [MVP]

I haven't tested this, it's from a friend. It may work for you:

Public Function ChangePassword(OldPwd As Variant, NewPwd As Variant,
VerifyPwd As Variant)
On Error GoTo Err_ChangePassword

Dim wsp As Workspace, uuser As User
Set wsp = DBEngine.Workspaces(0)
Set uuser = wsp.Users(CurrentUser)

'If OldPwd <> uuser.Password Then
' MsgBox "Your old password is incorrect.", vbOKOnly + vbInformation
'End If

If NewPwd = VerifyPwd Then
uuser.NewPassword OldPwd, NewPwd
Forms!frmSplashPopUp![txtDatePasswordChange] = Date
passwordUpdate
Else
MsgBox "The Passwords do not match. Please try again", vbOKOnly +
vbInformation, "Data Conflict"
End If

Exit Function

Err_ChangePassword:
Select Case Err.Number
Case 3033 'Incorrect Password
Case Else
MsgBox Err.Number, Err.Description, "ChangePassword"
End Select
End Function
 
D

Douglas J. Steele

If you care about consistent case in the passwords, you may want to replace

If NewPwd = VerifyPwd Then

with

If StrComp(NewPwd, VerifyPwd, vbBinaryCompare) <> 0 Then

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Arvin Meyer said:
I haven't tested this, it's from a friend. It may work for you:

Public Function ChangePassword(OldPwd As Variant, NewPwd As Variant,
VerifyPwd As Variant)
On Error GoTo Err_ChangePassword

Dim wsp As Workspace, uuser As User
Set wsp = DBEngine.Workspaces(0)
Set uuser = wsp.Users(CurrentUser)

'If OldPwd <> uuser.Password Then
' MsgBox "Your old password is incorrect.", vbOKOnly + vbInformation
'End If

If NewPwd = VerifyPwd Then
uuser.NewPassword OldPwd, NewPwd
Forms!frmSplashPopUp![txtDatePasswordChange] = Date
passwordUpdate
Else
MsgBox "The Passwords do not match. Please try again", vbOKOnly +
vbInformation, "Data Conflict"
End If

Exit Function

Err_ChangePassword:
Select Case Err.Number
Case 3033 'Incorrect Password
Case Else
MsgBox Err.Number, Err.Description, "ChangePassword"
End Select
End Function
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Paul Doree said:
Hi,

I'm working on some changes to the security of an Access XP DB, and need
some code to allow a user to change their password via a simple form
(users
are already created and assigned permissions).

I also need a sample of code for deleting a user from the collection of
users.

Can anyone help?

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top