Setting Permissions to

Allow ASP.net to read Access Files

Dennis Galletta

Updated Oct. 8, 2003

Phone: 648-1699; e-mail: galletta@katz.pitt.edu

 

Background:

Using ASP.net we found the following error after clicking the RUN icon (►)

 

 

The Microsoft Jet database engine cannot open the file

'C:\Inetpub\wwwroot\test\custsys.mdb'. It is already opened exclusively by

another user, or you need permission to view its data.

Description: An unhandled exception occurred during the execution of the

current web request. Please review the stack trace for more information

about the error and where it originated in the code.

 

Exception Details: System.Data.OleDb.OleDbException: The Microsoft Jet

database engine cannot open the file 'C:\Inetpub\wwwroot\test\custsys.mdb'.

It is already opened exclusively by another user, or you need permission to

view its data.

 

After uploading the ASP.net application to a web server, the code worked. It would not work locally.

Source of Problem

The problem is because, strangely enough, the local user-administrator (me) didn't have access to this Access file (the one I myself created!).  It was created pre-XP, so it must have made an assumption of no permission when it was carried along with my old data in upgrading through 95, 98, 2000, then XP.  There need to be permissions in several places.

Solution

  1. First make sure you have CLASSIC access to permissions. Go to control panel-administrative tools-local security policy--then cruise down to Network Access: sharing and security model for local accounts. Double click and move from the cursed GUEST ONLY to CLASSIC!
  2. Go to control panel-system-advanced-environment-local security setting and write down which folders TEMP and TMP are pointing to in both User Variables and System Variables. There should be 2 different folders. That is, User variables will probably point to a folder in your DOCUMENTS AND SETTINGS folder and System Variables will probably point to a TEMP folder in your WINDOWS or WINNT folder.
  3. Grant permissions as follows:
    1. In Windows Explorer, give permission to the main local user to access the Access database. 
    2. Also, grant permission to the ASP.NET Machine Account for the Access database.
    3. Finally, if that isn’t enough, grant permission to Internet Guest Account (IUSR-your name) (note: I’ll refer to this as IUSR from here on) in the application folder as well as the TEMP and TMP folders, (the locations you wrote down in step 2 above).

To do this for the files, you might have to go through the following (IUSR is used as an example):

      1. Right click the folder for which you want to provide extra permissions and select PROPERTIES.
      2. Click the SECURITY tab.
      3. If IUSR is there, then make sure it has adequate permissions.
      4. If IUSR is not, then ADD –ADVANCED – FIND NOW
      5. Select IUSR and then click OK then OK again.
      6. Give it full permissions and then OK.

4.  Some have said to reboot. You only have to do those steps once for each application & database you create.  Once you set the TMP and TEMP folders, you are set until you move to a different server.

For more information

The brief information on this page is not available at any single resource.