Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have publish my website in IIS7. It is running in DefaultAppPool. The Identity of this app-pool is set to LocalSystem. The IIS is running and I can run the application from IIS without any problem.

Now I want to attach the database placed in inetpub's application folder:


I have added new logins in the SSMS which are: NT AUTHORITY\NETWORK SERVICE and IIS APPPOOL\DefaultAppPool.

But when I am trying to attach that database in the SSMS I am getting follwoing error:

TITLE: Microsoft SQL Server Management Studio

Failed to retrieve data for this request.

For help, click:

------------------------------ ADDITIONAL INFORMATION: 
An exception occurred while executing a Transact-SQL statement or batch. 

CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file 'C:\inetpub\wwwroot\EMSApplication\App_Data\ASPNETDB.MDF'. (Microsoft SQL Server, Error: 5123)

For help, click:
share|improve this question
up vote 1 down vote accepted

I struggle with this sometimes when moving .mdf/.ldf's between computers. Often I have to fiddle with the file permission/ownership on the database files themselves for it to work.

Try giving the user account for SQL Server full access permissions to the ASPNETDB.MDF and if you have it the ASPNETDB.LDF file.

Also, the SQL Server account might not have access to read the C:\inetpub\wwwroot\EMSApplication\App_Data\ directory. You may have to fiddle with permissions here too.

share|improve this answer
Thanks. Can you please tell me what is the name of the user account of SQL Server? – Tapas Bose Mar 24 '12 at 14:47
It's going to look something like SQLServerMSSQLUser$ComputerName$InstanceName – Matthew Ruston Mar 24 '12 at 14:52
Thanks, this works – Tapas Bose Mar 24 '12 at 15:33

I had this issue and none of the solutions online helped. Eventually I found the solution - run SSMS as Administrator.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .