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

Force user to set password 2

Status
Not open for further replies.

Autoeng

Technical User
Jul 16, 2002
57
0
0
US
Similar to this posting thread705-441707 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? You would need 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 change password form. If not null open "other" form.

I found this MS code...

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

Can anyone help me to modify this thinking to check for a null user password within the workgroup.mdw file?

Thanks,
Autoeng
 
When I add a new user to the database, I log in as that user (could do it programmatically) and change their password to something like: 4tI~59UUZooprw Then I either tell them what this password is or email it to them. Since it's a password they are not going to remember, they always change it as soon as they open the database.
 
Blah, I'm away from all my code right now, but I have this in place: if you have a blank password, pop up the Change Password form. My form is on the web at
but the "check if blank password" is not on that database. It will look something like the following:

Code:
Public Sub CheckBlankPassword()
On Error Resume Next
Dim ws as DAO.Workspace

Set ws = DBEngine.CreateWorkspace("",CurrentUser(),"")

If Err.Number = 0 Then 'they have a blank password
    DoCmd.OpenForm "frmChangePassword",WindowMode:=acDialog
Else 'password is fine, continue on
    MsgBox "Good on ya!" 'probably will want to remove this
End If

    DoCmd.OpenForm "frmYOUR_STARTUP_FORM_GOES_HERE_CHANGEME"
End Sub

All the above from memory. Yay! Basically it attempts to open a workspace with the currentuser and a blank password. If it actually works, then shame on those people! If it errors, then that's actually a good thing.
 
I was trying to figure out how to determine the names of the users via a query rather than using the workspace. Upon finding a way to do it, thought of this post. So here's the query that will return the names of users with null passwords.

SELECT MSysAccounts.Name, MSysAccounts.Password
FROM MSysAccounts IN '\\path\YourWorkgroupName.mdw'
WHERE (((MSysAccounts.Name) Not In ("Creator","Engine")) AND ((MSysAccounts.Password) Is Null) AND ((MSysAccounts.FGroup)=0))
ORDER BY MSysAccounts.Name;
 
Wow! That rocks. Thanks much for that.

In big applications, I make an interface to add users. The interface e-mails the user a shortcut to the database (well, to the batch file, but that's another story), his user name, and his password, which is always something wacky like you use. I also give the users a form to change their passwords, so that they don't ever see the security menu item.

Using a form to add users makes it easy enough to add a field to the users table to store the last password change date, and from there it's easy enough to prompt, and then force, the user to chnage his password.

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.
 
Hi
I need a ASP code to do the change the password. I wrote a code for it but it goes into infinite loop. can you look at it adn let me know what is the problem.

thank you


<%

Dim userName


' MapPath of virtual database file path to a physical path.
strDBPath = Server.MapPath("Secure_Metrics_Assets.mdb")
On Error Resume Next
' Create an ADO Connection to connect to the sample database.</FONT>
set conn = Server.CreateObject("ADODB.Connection")

userName = session("Userid")

'Use ODBC DSN to link to MS Access database
conn.open "DSN=Metrics;uid=" & session("Userid") & ";pwd=" & session("Password")
if err.number < 0 then 'Could not make connection. Return to main display
Response.Redirect "PasswordChange.asp"
end if

'Set session Userid and Password variables
session("OldPassword") = Request("OldPassword")
session("NewPassword") = Request("NewPassword")


'Create the command object

Set RST = Server.CreateObject("ADODB.recordset")

' strSQL= " UPDATE MSysAccounts SET MSysAccounts.Password=" & session("NewPassword") & " WHERE MSysAccounts.Name= ' " & userName & " '; "

strSQL= " SELECT MSysAccounts.Name, MSysAccounts.Password FROM MSysAccounts IN '\\kumar1\METRICS_ASSETS.mdw' WHERE MSysAccounts.Name= ' " & userName & " '; "

rst.open strSQL, conn
rst.MoveFirst

Do While NOT RST.EOF

Response.Write RST("MSysAccounts.Name")
Response.Write RST("MSysAccounts.Password")

RST.MoveNext
Loop
rst.close
set rst = nothing


%>
 
Replace this:
Do While NOT RST.EOF
By this:
If Err.Number Then Response.Redirect "PasswordChange.asp"
Do While Not Rst.EOF And Not rst.BOF

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top