Check current password

Dave_cha

Registered User.
Local time
Today, 14:17
Joined
Nov 11, 2002
Messages
119
Does anyone have a script which will check the user's password and if blank will open a 'New Password entry form'?
I have enough info to build the password entry form but I'm stuck when it comes to checking their current password for a null entry.

Thanks Dave
 
Dave,

If you are implementing your own security, then you can bring
up a popup, modal form that asks for the username and password.

You can use the OnClick event of the OK command button to:

Code:
Dim CheckPass As Variant

If IsNull(Me.PassWord) then
   MsgBox("You must enter a password.")
   Me.PassWord.SetFocus
   Exit Sub
End If
'
' Check if password is valid for username.
'
Me.CheckPass = DLookUp("[PassWord]", "tblUsers", "[UserName] = '" & Me.Username & "'")
If IsNull(CheckPass) Then
   MsgBox("UserName or password incorrect.")
   Me.UserName.SetFocus
End If

Wayne
 
Sorry Wayne, I should have mentioned that I'm using a workgroup mdw file to authenticate users. I haven't needed users to have a password until now so I want to build in a check when they logon to force them to password protect their user id.

Thanks,

Dave
 
The users will not be able to log into your db if you have correctly set up your security for the workgroups and permissions.
 
Dave,

If you are using Access Security, how are they in without
filling out Access's dialog box. And you assign the passwords.

I generally don't deal with Access Security so I'll have to defer
to one of our other members.

I'll do some research ...

Wayne
 
All users are authenticating to a central mdw file at present, each using a unique user id. This allows me to connect the 'Current user' to an employee.
Until now, they have been able to enter with a blank password field. However, it's now becoming more important that users can't access using someone else's user id.
What I want to do is check when they login whether their password field is blank and, if it is, to prompt them to enter a new password. If I were just to provide them access to a password change form, half of them wouldn't bother changing.

Dave
 
Thanks Wayne.

That Autoeng link is actually a response to an original question I had on passwords sometime ago. He may also be able to answer this one.

Dave
 
Hmmm. Interesting conundrum. To reiterate if you haven't assigned a password for a user when you set them up how do you force them to go to the change password form and enter one the first time they enter the db? I have no idea how to access the data contained within the mdw file which is where the code would need to check to see if current user password is null. If null display the form and then some error checking to make sure they don't select OK without entering a new password. If not null open "other" form.

One thing to do is always give your user a password when you set them up but that's not what you want and I agree that we need to find a way of doing what you want.

I'm looking into it.
 
Found this on MSDN on how to programatically set users passwords. Perhaps it can be altered. I behind the 8 ball on a project right now so I can't really delve into this.

Code:
Sub ChangePasswords()

	Dim ws As Workspace, usr As User

	' Add passwords to the Admin, OrdersAdmin, and OrdersOwner
	' user accounts.
	Set ws = DBEngine.Workspaces(0)
	ws.Users("Admin").NewPassword "", "AdminPwd"
	ws.Users("OrdersAdmin").NewPassword "", "OrdAdminPwd"
	ws.Users("OrdersOwner").NewPassword "", "OrdOwnerPwd"

	' Create a user account, specifying a PID and a password with
	' the CreateUser method.
	Set usr = ws.CreateUser("Tim Smith", "ilmj2d", "MyPwd")
	ws.Users.Append usr

	' Create a user account, specifying a password with the
	' Password property.
	Set usr = ws.CreateUser("Robert King")
	usr.PID = "tdi3tcm"
	usr.Password = "NewUserPwd"
	ws.Users.Append usr
End Sub
 
Another idea is that some people display a one time screen then log user to a table so that the screen won't display again. You could work on that concept so that if user is not in table display change password form and do not allow closure until new password entered.
 
Thanks Autoeng.

I'll try option 2 in the morning.

Despite my best efforts I can't get option 1 to work.
I was heading in the right direction before your reply but I just kept getting a 'runtime error (3251) - object doesn't support this action' when I try to run "If Usr.Password = "" then" or "if is null (Usr.password) then".

Thanks again,

Dave
 
That still does not make sense. If the db is properly secured and the users are not using the updated MDW file with the correct user name and password then they should not be able to open the database. An outdated MDW file should not let the users into the db [If the db is properly secured] if they do not use the correct user name and password.
 
ghudson:

When you create a user in the Tools-Security-Users and Groups menu you can assign the user a password. If you do not all the user has to do to enter the db is enter their username into the login box and they are in. If you have a secured db you can test this by removing the password from a user. Access does not pre-test whether a user has a password but only if they are a user within the workgroup.
 
Missed your last question Autoeng.....I decided to pack it in for the day (I'm a few hours ahead of you).

I'm using Access '97 on W2K
 
Hi Dave:

Should work with 97. I really think option 1 would be better. Can you post your code you had?
 
Hi Autoeng,

This is what I had as of yesterday evening.

Private Sub Form_Open(Cancel As Integer)

Dim UsrLocal As Object
Dim Wk As Workspace
Dim Usr As String

Usr = CurrentUser

Set Wk = DBEngine.Workspaces(0)
Set UsrLocal = Wk.Users(Usr)

'If IsNull(UsrLocal.password) Then
If UsrLocal.Password = "" Then

MsgBox "No pw set"

Else
Exit Sub

End If

End Sub


Thanks,

Dave
 
Maybe this? I'm still learning VBA and when it comes to new objects I'm sometimes lost. Perhaps ghudson could tweak.
Code:
Private Sub Form_Open(Cancel As Integer) 

Dim UsrLocal As Object 
Dim Wk As Workspace 
Dim Usr As String 

Usr = CurrentUser 

Set Wk = DBEngine.Workspaces(0) 
Set UsrLocal = Wk.Users(Usr) 

'If IsNull(Usr.Password) Then 
If Usr.Password = "" Then 

MsgBox "No pw set" 

Else 

End If 

End Sub
 
I played with your code a bit without any luck. I just do not think that it is possible to extract out the users password that they logged in with.

Although...if there is a will, there is a way...

Something like that! :D
 

Users who are viewing this thread

Back
Top Bottom