Recordset from secured database

mbentley

Registered User.
Local time
Today, 13:56
Joined
Feb 1, 2002
Messages
138
I'm trying to create and ADO recordset from an external database that is secured with user-level security. How do I modify the connection string to include the username and password of the current user?
 
mbentley said:
I'm trying to create and ADO recordset from an external database that is secured with user-level security. How do I modify the connection string to include the username and password of the current user?

If you need more info on processing strings check out the VBA Strings object in the object browser. There are lots of methods for string manipulation.

Fast and dirty solution might be to just append ";username='whatever';password='whateverelse'", since I believe ADO only uses the last value found in the string.

More likely though, you want to rebuild the string from scratch based on user input, something like...

strCon = "provider=microsoft.jet.oledb.4.0;datasource=c:\your.mdb;username=" & strUser & ";password=" & strPass

I think.
(Greetings from Van, BC)
 
Solved

Thanks Lagbolt, but that didn't quite work. I managed to figure it out though. My setup for creating my connection string seems to result in the User ID being a part of the string already, so all I have to do is concatenate the password. Capturing the password is another challenge I'm working on. Here's the code that worked:

With cnnFrontend
.Provider = CurrentProject.Connection.Provider
.ConnectionString = CurrentProject.Connection & ";Password=" & strPassword
.Open
End With
 
Pass user password to connection string

I'm guess I already know the answer, but is there anyway to pass the password of the current user to the connection string (see previous posts). I'm guessing that the password property is not readable for security reasons, but it doesn't hurt to check. I've only seen one other post on this, and it just degenerated into a flame war. ;)
 

Users who are viewing this thread

Back
Top Bottom