Question How to have a password Protected Folder to which MSAccess can acces (1 Viewer)

darbid

Registered User.
Local time
Today, 07:54
Joined
Jun 26, 2008
Messages
1,428
I would like to be able to have a secure area set up on a network drive where a DB loads and saves its files, but where people cannot come and change things.

At the moment I am thinking that I have a folder which is password protected and that I can code the entering of a password so that the DB can get access.

Is this the way to go?
If not what should I be trying for?
If yes how, what products exist that work with VBA?

Thanks guys.
 

Trevor G

Registered User.
Local time
Today, 06:54
Joined
Oct 1, 2009
Messages
2,341
What is your actual needs?

Wouldn't it be easier to have a folder with permissions so only those who need access to the folder can open it !

Will the database be in that folder?

You mention about data from the database going into the folder, what file types are they?

Just for interest sake what version of MS Office are you using?
 

darbid

Registered User.
Local time
Today, 07:54
Joined
Jun 26, 2008
Messages
1,428
What is your actual needs?
DB front end is hosted locally.
All users have full access to the network drive.
Users want me to build in the ability to "upload files" relating to a record.
I am thinking about where to save the files.

Thus I need a place to store these files, but am worried that people will go and play with the folder structure I set up or cut and copy files from it.

So I suppose what I am looking for is a network folder where a DB can have access to it but people going there with Explorer will not be able to get there. If I set up permissions then the locally hosted DB will not have permission as far as I understand.

Wouldn't it be easier to have a folder with permissions so only those who need access to the folder can open it !
We currently have that. But I cannot restrict access by permissions because then the DB would not be able to get access.

Will the database be in that folder?
No

You mention about data from the database going into the folder, what file types are they?
all different types from all office docs to pdf to images

Just for interest sake what version of MS Office are you using?
Office 2003
 

vbaInet

AWF VIP
Local time
Today, 06:54
Joined
Jan 22, 2010
Messages
26,374
What about just giving them WRITE permissions to that folder and subfolders?
 

darbid

Registered User.
Local time
Today, 07:54
Joined
Jun 26, 2008
Messages
1,428
What about just giving them WRITE permissions to that folder and subfolders?
That would be a good plan B.

But that would mean that the DB on their computer could also only write as well.

I think you understand that their permissions must be High cause they "own" their local copy of the DB, but the DB must have something that they don't, like a password or something.
 

DJkarl

Registered User.
Local time
Today, 00:54
Joined
Mar 16, 2007
Messages
1,028
I would like to be able to have a secure area set up on a network drive where a DB loads and saves its files, but where people cannot come and change things.

At the moment I am thinking that I have a folder which is password protected and that I can code the entering of a password so that the DB can get access.

Is this the way to go?
If not what should I be trying for?
If yes how, what products exist that work with VBA?

Thanks guys.

You could look into impersonating a user.
Found this code online so I'm not sure if it works, I have done similar things in .NET though so I know it's possible.

Code:
Option Explicit
 
 
Private Declare Function RevertToSelf Lib "advapi32.dll" () As Long
 
Private Declare Function LogonUser Lib "advapi32.dll" Alias "LogonUserA" (ByVal lpszUsername As String, ByVal lpszDomain As String, ByVal lpszPassword As String, ByVal dwLogonType As Long, ByVal dwLogonProvider As Long, phToken As Long) As Long
 
Private Declare Function ImpersonateLoggedOnUser Lib "advapi32.dll" (ByVal hToken As Long) As Long
 
Const LOGON32_LOGON_INTERACTIVE = 2
Const LOGON32_PROVIDER_DEFAULT = 0
 
 
Private Sub Command1_Click()
   Dim strLine As String
   Logon "username", "password", "domain"  'I used computer name if no domain.
   Open "C:\path\to\secure\file.txt" For Input As #1
   Line Input #1, strLine
   Close #1
   MsgBox strLine
   Logoff
 
End Sub
 
 
Public Sub Logon(ByVal strAdminUser As String, ByVal strAdminPassword As String, ByVal strAdminDomain As String)
 
  Dim lngTokenHandle, lngLogonType, lngLogonProvider As Long
 Dim blnResult As Boolean
 
  lngLogonType = LOGON32_LOGON_INTERACTIVE
 lngLogonProvider = LOGON32_PROVIDER_DEFAULT
 
  blnResult = RevertToSelf()
 
  blnResult = LogonUser(strAdminUser, strAdminDomain, strAdminPassword, lngLogonType, lngLogonProvider, lngTokenHandle)
 
 blnResult = ImpersonateLoggedOnUser(lngTokenHandle)
End Sub
 
Public Sub Logoff()
 Dim blnResult As Boolean
 
  blnResult = RevertToSelf()
End Sub
 

darbid

Registered User.
Local time
Today, 07:54
Joined
Jun 26, 2008
Messages
1,428
Hi DJkarl - now i never would have thought that such a thing exists. I will have to see if I can do that with the computer set up we have.
 

naganesan

New member
Local time
Today, 11:24
Joined
Jul 16, 2021
Messages
3
How can I know, if the login is successful or not
I want to get a error message " password incorrect " if I enter a wrong password.
and " login successful " if Logon is successful using the correct credentials
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:54
Joined
Sep 21, 2011
Messages
14,238
How can I know, if the login is successful or not
I want to get a error message " password incorrect " if I enter a wrong password.
and " login successful " if Logon is successful using the correct credentials
Almost an 11 year old thread?

Best to start your own thread for what you are trying to do?
 

Users who are viewing this thread

Top Bottom