Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MS Access password

Posted on 2004-10-23
7
Medium Priority
?
196 Views
Last Modified: 2010-04-24
Hi,

I'm using MS Access as database with my app and I want to prevent users from opening the database mainly to prevent structural modifications.

However, I want my app to be able to use the database without limitations.

I put a password in the database and tried to import it in the Visual Studio's Servers Explorer and invariably got an error message saying that no workgroup information is available.

Actually I don't want to authorize anyone to open/use the database except through the app.

Can anyone explain to me what's the problem and how I can resolve the issue?

Any help shall be greatly appreciated.  
0
Comment
Question by:Ghanisen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 22

Expert Comment

by:CJ_S
ID: 12389268
If you have no problems with the removal of the password on the actual database, then you can use the IPrincipal interface.

IPrincipal allows you to set an identity to the current thread. Then you can call IsInRole(rolename) to check if the user can access the database.
All you have to do is create a class which implements the IPrincipal interface. Then set the System.Threading.Thread.CurrentPrincipal to an instance of your class. Since you've implemented a working check of IsInRole you can now check in your database open function whether the current user has access or not.

This approach does not protect the actual database when opened of course.
0
 

Author Comment

by:Ghanisen
ID: 12389343
Hi CJ S,

Look I don't want each user to have or not permission to use the database. It's not on a network. All I want to do is set a OleDb connecting string for my mdb database that includes the password I've set in the database.

This way I want the database to be opened only by my VB.NET application and not by users directely. They have to use it thru the application.

My connection string (sConDB) is currently :

        sConDB = "Provider=Microsoft.Jet.OLEDB.4.0;"
        sConDB &= "Password=;User ID=Admin;"
        sConDB &= "Data Source=" & DBPath & ";"

If my password (in the database) is MyPassword, how do I set the connection string to enable my application to open the database?

I hope you have an answer. Thanks a lot.

Note also that I don't know a thing about IPrincipal and how to use it.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 12389362
The problems appears in your connectionstring. You need to append an additional attribute called "Database Password=YourPassword;".

CJ.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Ghanisen
ID: 12389480
Hi CJ S,

I tried:

sConDB = "Provider=Microsoft.Jet.OLEDB.4.0;"
sConDB &= "Database Password=Mypassword;"
sConDB &= "Data Source=" & DBPath & ";"

This connection string doesn't work.

Can you give me the exact syntax the connection string should follow in this case? Thanks
0
 
LVL 22

Accepted Solution

by:
CJ_S earned 2000 total points
ID: 12389660
0
 

Author Comment

by:Ghanisen
ID: 12390088
Hi CJ S,

Thank you very much for indicating where to find the correct connection string. I post it here for others who may need it.

If you want to protect your MS Access database with a password and not use use workgroups then the syntax for the connection string is:

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:Database Password=MyDbPassword;"

However, if you use stored procedures in your MS Access database, you have to set the authorizations for the Administrator to edit/use stored procedures by selecting MSysObjects and MSysQueries under the security assistant within Access (To be opened in exclusive mode).

I discovered that when I tried to use my stored procedures after setting the password protection.

Thanks again CJ S. You sure deserve the 500 points.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 12390410
Thanks! Glad I could help.

CJ.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question