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

how to change MS Access mdw password using ASP code 2

Status
Not open for further replies.

axslearnr

Technical User
Apr 1, 2004
78
US
Hi
I have ASP page where I have a form to change the password of the user. The back end is Access database and I dont have any tables for password information. I have a workgroup information file for the users.

How to change the password of the access database using ASP form.

pls let me know
thank you.

 
Hi
Thanks for the help. 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.Command")

' 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


%>
 
I have that problem when I use:

Do while not rst.eof

I do not understand why it doesn't work and I always end up having to go with

Do until rs.eof = true

That is the only place where a loop could occur in your code that I can see.

Let me know if that works.

Cassidy

 
Hi
Thanks for the reply. It still goes into the loop like that. Do you see any errors in my code in the select statement. i am retrieving usernames and passwords from the access mdw file.

could you please let me know how to do that.

thank you

 
The only thing I see that is different than what I have when I opened the secured database is this:

Provider=Microsoft.Jet.OLEDB.4.0;Password=joe;User ID=jim;Data Source=C:\My.mdb;Persist Security Info=True;
Jet OLEDB:System database=C:\Program Files\Common Files\System\SYSTEM.MDW;Jet OLEDB:Database Password=14323

This information is in the following article


The other thing I found was that MSysAccounts wasn't amongst the table list in the schema. That could be because I am using Access 2003.

I will keep looking. Let me know if you get it.
 
Hi
I tried and got the usernames from the MSysAccounts table. But whenever i use WHERE MSysAccounts.Name =" & session("Userid") & " it goes it takes long time ans script timeout takes place. do u know wh yis it doing like this?
let me know . thanks




<html>
</body>
<%

Dim userName


' MapPath of virtual database file path to a physical path.

strDBPath = Server.MapPath("METRICS_ASSETS.mdw")

On Error Resume Next
' Create an ADO Connection to connect to the sample database

set conn = Server.CreateObject("ADODB.Connection")

userName = session("Userid")

Response.Write session("Userid")
'Response.Write userName


'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")

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

strSQL= " SELECT MSysAccounts.Name, MSysAccounts.Password FROM MSysAccounts WHERE (((MSysAccounts.Name) =" & session("Userid") & " ) AND ((MSysAccounts.FGroup)=0)) ORDER BY MSysAccounts.Name ; "


rst.open strSQL, conn
rst.MoveFirst

Do While NOT RST.EOF AND NOT RST.BOF

Response.Write rst("Name") & "<br>"

Response.Write rst("Password")

Response.Write "1"
rst.MoveNext
Loop
Response.Write "work - 2"

rst.close
set rst = nothing


%>
</body>
</html>
 
I normally use an OLEDB connection because DSN always has problems for me. try this

Code:
with cn
   .Provider = "Microsoft.Jet.OLEDB.4.0"
   .Connectionstring = "METRICS_ASSETS.mdw"
   .open
end with

For a secured database you might have to change the connectionstring for user name and password.

Let me know.

Cassidy
 
Hi
I tried that its slow and says the server sciprt time out.
what else could be the problem.
pls let me know
thank you

 
Take out your on error resume next statement and see if there if there are any errors. If there is an error then I would imagine it is in your loop. If the page still times out then try changing the do statement to this:

Do until rs.eof = true

I sometimes get into a loop using the other and have not figured out why that is.

Let me know if that helps at all. If not I will see if I can't simulate what you have.

Cassidy
 
you may want to look at this :

( it's at the bottom of the page )

found by means of google [ASP Access Database Password Change]

also i apologize if this isn't what you're looking for, from what i can tell you want to change the password of the database itself

<update> seems the page doesn't like to load on linking .. here's the code from in the page in case the link is grumpy :

Code:
Public Function ChangeDatabasePassword(DBPath As String, _
newPassword As String, oldPassWord As String) As Boolean
    
'Usage: Change DatabasePassword
'Parameters: sDBPath: Full Path to Access Database
'newPassword: the password
'oldPassword: the previous password
'returns true on success false otherwise

If Dir(DBPath) = "" Then Exit Function

Dim db As DAO.Database

On Error Resume Next
Set db = OpenDatabase(DBPath, True, False, ";pwd=" & oldPassWord)
If Err.Number <> 0 Then Exit Function
db.newPassword oldPassWord, newPassword
ChangeDatabasePassword = Err.Number = 0
db.Close

End Function


[thumbsup2]DreX
aKa - Robert
 
Hi
I tried removing the on Error Resume next statement but it still takes so muc time and get the same timout error.

The code u gave isnt that for changing the Database password? I need to change the users password. Can you modify the code according to that. Where do i call this function changedatabase password.

I am sorry i am new to ASP
i appreciate ur help

thank you
 
i guess i'm at a loss, typically you would have a "members" table with usernames/passes/misc info

the DB can be password protected and that's what the supplied code is trying to change.

as for user passwords, i dont know, i never attempted to have a db with built in authentication, that would only be useful as far as i can think of for direct networking to the DB for opening IN access, not through a web page.

perhaps you could give a synopsis of what you're building as a web page, how the DB is used (specifically) and... what you're trying to accomplish.

if anything use analogies... like :
Code:
i have a web store, with clients, i want the clients to be able to modify their user information/passwords from a page
the database is just used as a back end in this instance and there is no need for DB users or passwords, you'd just need one for theserver to access it.

vs

Code:
i have a access db that's used as a workgroup interface on our intranet for support calls, each of the CSR's have an account/password which is used for logging who takes what calls/modifies data etc. i want to be able to change this environment to be a web interface for out of office review/overview. but at the same time, i want the CSR's to change their account information locally or through the web interface.
this... is a little more involved ;)

[thumbsup2]DreX
aKa - Robert
 
I guess I need the second option.

Let me tell you I have a database and workgroup file file.
We have r building a ASP front end to access the database.
We have users and passwords secuirty and no database password. I would like to allow users to chanhe their passwords from the ASP form. The thing is employee table in the database has only username field but no password field.
So I have to access the workgroup file to change the password of each user from ASP form.

so let mw know what do u think i should do
thank you for ur help and i apreciate it

 
this is a little bit in the deep sheep department.
i guess for starters, how is the user/passwords actually handled, if youwere to change a user password for them at the moment, would it be :

done through NT as a workgroup useraccount

done in access as a security setting ( i dont rememebr there being one but i'm also not well versed in 20002003 access )


[thumbsup2]DreX
aKa - Robert
 
Hi
I have to change the MS Access password not the NT password. Users access the MS access till now with an user /password. We have added some tables in the db and made an ASP interface to access those tables. So they can login to the db through ASP pages now. I got to make the password change form from the ASP instead of opening MS Access directly and doing it.

I have been able to display the users in the MS Access workgroup file from the code above. When I put a WHERE conditon to display the user name it keeps on doing and script time out occurs.

So pls let me know
thank you
 
Here is something I found that worked when I tested it:

Code:
   Dim cat
   
   Set cat = Server.Createobject("ADOX.Catalog")

   ' Open the catalog, specifying the system database to use
   cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=.\NorthWind.mdb;Jet OLEDB:System database=" & _
      "C:\Program Files\Microsoft Office\Office\SYSTEM.MDW"

   ' Change the password for the user Admin
   cat.Users("Admin").ChangePassword "", "password"

It might take some tweaking but I know it works just as it is on my system.

Let me know

Cassidy
 
hi
what abt the userid and password to enter the database

in the line

cat.Users "Admin").ChangePassword "", "password"

what is this "" what to put in there?

and in "password"

let me know thank you

i appreciate ur help


 
Where it says ADMIN you would replace that with the username that you would like to change the password of. Where it says password you would place the new password there. I would use variables for the user name and password. Something like this:

Code:
sUser = Request.form("User") 
sPassword = Request.form("Password")

cat.Users(sUser).ChangePassword "",sPassword

Let me know how it goes.

Cassidy
 
Hi I tried it didnt get any eror messsage or nothing. didnt change the password. her is my code let me know what is the mistake?


<html>
</body>
<%

Dim userName


' MapPath of virtual database file path to a physical path.

strDBPath = Server.MapPath("METRICS_ASSETS.mdw")

On Error Resume Next

' Create an ADO Connection to connect to the sample database


userName = session("Userid")

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

Dim cat

Set cat = Server.Createobject("ADOX.Catalog")

' Open the catalog, specifying the system database to use
cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=.\Secure_Metrics_Assets.mdb;Jet OLEDB:System database=" & _
"C:\Inetpub\ ; UserID=" & session("Userid") & " ; Password=" & session("Password") & "; "

' Change the password for the user Admin
cat.Users("kumar").ChangePassword "", "ybnvdp"

%>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top