
Configuring Permissions for an Access Database
An important aspect of working with an Access .mdb file is to correctly configure permissions. When a Web application uses an Access database, the application must have Read permission to the .mdb file so the application can access the data. Additionally, the application must have Write permission to the folder that contains the .mdb file. Write permission is required because Access creates an additional file that has the extension .ldb in which it maintains information about database locks for concurrent users. The .ldb file is created at run time.
By default, ASP.NET Web applications run in the context of a local machine account named ASPNET (for Windows 2000 and Windows XP) or in the context of the account NETWORK SERVICE (for Windows Server 2003). For example, for Windows 2000 or Windows XP Professional, if the Web server is named ABCServer, ASP.NET applications on the ABCServer computer run in the context of the local account ABCServer\ASPNET. Therefore, to use an Access database in an ASP.NET Web application, you must configure the folder that contains the Access database to have both Read and Write permissions for the local ASPNET user account.
When you create a Web site in Visual Web Developer, Visual Web Developer creates a folder named App_Data below the current root folder. The folder is designed to be a store for application data, including Access databases. The App_Data folder is also used by ASP.NET to store databases that the system maintains, such as the database for membership and roles. When Visual Web Developer creates the App_Data folder, it grants Read and Write permissions for the folder to the ASPNET or NETWORK SERVICE user account.
Note |
|---|
| As a security measure, files in the App_data folder are not served by the Web server. Do not store any Web pages in the App_Data folder, because users will see an error if they request a page from that folder. |
In this part of the walkthrough, you will examine the permissions of the App_Data folder to make sure that it will work correctly when the application runs.
To set permissions in the App_Data folder
-
In Windows Explorer, move to the root folder for the Web site.
The default location for your new Web site is c:\inetpub\wwwroot\AccessSample.
-
If the App_Data folder does not already exist, create one.
By default, Visual Web Developer creates the folder when you create a new Web site.
-
Right-click the App_Data folder, click Properties, and then click the Security tab.
-
Under Group or user names, look for either of these user accounts:
-
If the computer is running Windows XP Professional or Windows 2000, look for computer\ASPNET.
-
If the computer is running Windows Server 2003, look for NETWORK SERVICE.
-
Verify that the account has Read and Write permissions for the App_Data folder.