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

change password in workgroup

Status
Not open for further replies.

gransbpa

Programmer
Jun 5, 2001
98
NL
Hi there,

I want to create a new user in a workgroup file, and then change his password from default/blank to something else. However, when I am logged on as myself (I belong to the Admin group), I can't change the new user's password: you can only reset it. But the user himself does not have Admin rights, so he does not have access to the user and group account option. Is there any way to change this user's password without giving him the Admin rights?

Thanks
 
This works real well.....with this you can change any of your user's password while logged in as yourself.

Create a form with 4 fields and 2 buttons

Form Fields
1. cboUsers [Row Source Type] = glrcboUsersFill
2. txtOldPwd [Input Mask] = Password
3. txtNewPwd [Input Mask] = Password
4. txtConfirmNewPwd [Input Mask] = Password

Command Buttons
1. cmdPwd [On Click] = [Event Procedure]
2. cmdClose [On Click] = [Event Procedure]

Then add this code...

Function glrcboUsersFill(ctl As Control, _
varID As Variant, varRow As Variant, varCol As Variant, _
varCode As Variant) As Variant

Static swrk As Workspace
Static sastrUsr() As String
Static sintUsrCnt As Integer
Dim usr As User
Dim varReturn As Variant
Dim strName As String

Set swrk = DBEngine.Workspaces(0)
Select Case varCode
Case acLBInitialize
sintUsrCnt = 0
swrk.Users.Refresh
ReDim sastrUsr(1 To swrk.Users.Count)
For Each usr In swrk.Users
strName = usr.Name
If strName <> "Engine" And strName <> "Creator" Then
sintUsrCnt = sintUsrCnt + 1
sastrUsr(sintUsrCnt) = strName
End If
Next usr
ReDim Preserve sastrUsr(1 To sintUsrCnt)
varReturn = True
Case acLBOpen
varReturn = Timer
Case acLBGetRowCount
varReturn = sintUsrCnt
Case acLBGetValue
varReturn = sastrUsr(varRow + 1)
End Select

glrcboUsersFill = varReturn

End Function

Private Sub cboUsers_AfterUpdate()

' Disable txtOldPwd if an Admins
' member is changing the password of
' another user since it's unneeded.
If cboUsers = CurrentUser() Then
Me!txtOldPwd.Enabled = True
Else
Me!txtOldPwd.Enabled = False
End If

End Sub

Private Sub cmdClose_Click()
DoCmd.Close
End Sub

Private Sub cmdPwd_Click()

Dim fOK As Boolean
Dim ctlOldPwd As TextBox
Dim ctlNewPwd As TextBox
Dim ctlConfirmNewPwd As TextBox
Dim strMsg As String

Set ctlOldPwd = Me!txtOldPwd
Set ctlNewPwd = Me!txtNewPwd
Set ctlConfirmNewPwd = Me!txtConfirmNewPwd

If Nz(ctlNewPwd) = Nz(ctlConfirmNewPwd) Then
fOK = glrSetPwd(strUser:=cboUsers, _
strOldPwd:=Nz(ctlOldPwd), _
strNewPwd:=Nz(ctlNewPwd))
If fOK Then
strMsg = "Password changed!"
ctlOldPwd = ""
ctlNewPwd = ""
ctlConfirmNewPwd = ""
Else
strMsg = "Password change failed!"
End If
Else
strMsg = "New password entry does not match " & _
"confirming password entry!"
End If

MsgBox strMsg, vbOKOnly + vbInformation, _
"Change Password"

End Sub

Private Sub Form_Load()

' If not a member of Admins lock
' and disable the user combo box.

If Not glrIsGroupMember("Admins") Then
With Me!cboUsers
.Locked = True
.Enabled = False
End With
End If

End Sub
 
Thanks Yarcadian!

We tried it and it works great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top