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 Chriss Miller 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 password for user in workgroup file 1

Status
Not open for further replies.

AncientTiger

Programmer
Jul 5, 2001
238
US
Ok, I've searched the forum and faq and looked at the jet documentation, but I'm just not getting how to do this. I've got a secured access database (access2000), and I'm looking for a code example of how to change the password of a user in the secure workgroup. Don't want to changes any permission, just change the password...

Thanks

------------------------------------
[yinyang] Over 20 years of programming, and still learning every day! [yinyang]
 
This line in a module changes [blue]oldpassword[/blue]
to a [blue]newpassword[/blue] for a specific [blue]user[/blue]
Code:
currentproject.connection.execute "ALTER USER user PASSWORD 
newpassword oldpassword"
 
Ok, yep I saw that example. My question is the "currentproject" object. Let's say that I've got a secure database called "mydb.mdb" with a user called "tiger"

The way I tried to do it (and failed) was this

dim cnn as new adodb.connection
with cnn
.provider="Microsoft.Jet.OLEDB.4.0"
.connection=";Password=whatever;User ID=tiger;Data Source=C:\mydb.mdb;Persist Security Info=True;Jet OLEDB:System database=C:\seccon.mdw"
.open
.execute "alter user tiger password whatever whatever2"
.close
end with

It keeps giving me the error "You do not have the necessary permissions to use the '' object", but the user "tiger" is set to full permission as an administrator....

Any ideas?

------------------------------------
[yinyang] Over 20 years of programming, and still learning every day! [yinyang]
 
AncientTiger, looks like the cnn opened by this "tiger" User is not with administrator rights for this seccon.mdw on this C:\mydb.mdb database

The way I do it and works is
Code:
Dim Cnn as ADODB.Connection
Dim sConnection as String

sConnection = "Provider=Microsoft.Jet.OLEDB.4.0" & _
                ";Data Source=" & App_Folder & "\" & App_Dbase & _
                ";Jet OLEDB:System database=" & App_Folder & "\" & Sys_Dbase & _
                ";User Id=" & Pwr_User & _
                ";Password=" & Pwr_Pswrd & ";"
Set Cnn = New ADODB.Connection
With Cnn
    .ConnectionString = sConnection
    .CursorLocation = adUseServer
    .Mode = adModeShareDenyNone
    .Open
    .Execute "Alter User " & cmbUser.Text & " Password " & txtOldPswrd.Text & " " & txtNewPswrd.Text
    .Close
End With
Set Cnn=Nothing
[code]
which is almost the same!!!
 
Tried it... still getting the same error message...

------------------------------------
[yinyang] Over 20 years of programming, and still learning every day! [yinyang]
 
Well, can this "tiger" user change his password on C:\mydb.mdb database using the factionality of Access when joined to this seccon.mdw ??? Is he an administrator there or not ???? Has all needed prevelidges ????
 
Ok an ADO version
Code:
Dim cat As ADOX.Catalog
Dim Cnn as ADODB.Connection
Dim sConnection as String

sConnection = "Provider=Microsoft.Jet.OLEDB.4.0" & _
                ";Data Source=" & App_Folder & "\" & App_Dbase & _
                ";Jet OLEDB:System database=" & App_Folder & "\" & Sys_Dbase & _
                ";User Id=" & Pwr_User & _
                ";Password=" & Pwr_Pswrd & ";"
Set Cnn = New ADODB.Connection
With Cnn
    .ConnectionString = sConnection
    .CursorLocation = adUseServer
    .Mode = adModeShareDenyNone
    .Open
End With
Set cat = New ADOX.Catalog
cat.ActiveConnection = cnn
cat.Users("Tiger").ChangePassword NewPassword, OldPassword
Set cat = Nothing
cnn.Close
Set cnn = Nothing
In VBE Tools-->References, check your Microsoft ADO Ext. 2.x for DDL and Security version
If still no luck, maybe someone else could help ?

 
THAT one worked like a charm!!!!!!!

Thanks a ton Jerry!

------------------------------------
[yinyang] Over 20 years of programming, and still learning every day! [yinyang]
 
Ok, one last hangup...

Is there some reason why the statement to change the password would REQUIRE string contants, disallowing the use of variables??? I've tried it both ways, and it works like a charm with strings (ie: "tiger"), but throws up a multi-step OLE DB error if I try a variable (ie: UNAME).

Here's the lines of code that I've got...

Set CAT = New ADOX.Catalog
CAT.ActiveConnection = CNN
CAT.Users(UN).ChangePassword Opword, Npword
Set CAT = Nothing
CNN.Close

I've never seen anything like this!


------------------------------------
[yinyang] Over 20 years of programming, and still learning every day! [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top