attaching SQL Server 2005 Express database in ASP.NET web application


Loane Sharp

Hi there

Please help! I'm at my wits' end...

I am using the System.Data.SQLClient namespace in an ASP.NET web application
to connect to a local instance of SQL Server 2005 Express.

Using "AttachDBFileName" in the connection string to attach to the database,
I can connect to the database if the ASPNET account is explicitly (a)
granted database access and (b) given "SELECT" permission, presumably
because the ASPNET account has limited permission by default.

I'm certain that I'm dealing with a permission issue: If I assign the ASPNET
account to the Administrators group, I can attach to and access the
database, but this is too scary for me (not to mention for my principals).
I've been told that I can let the ASPNET account impersonate the local user,
but the local user will not have been given explicit permission to access
the database (I'm using XCopy deployment with no knowledge of the ultimate
user's Windows domain\user details). Alternatively I've been told that I can
get the ASPNET process to run under the System account, but (i) this is
fairly risky too, (ii) I don't know how to do it, and (iii) I'm uncertain
whether it would work.

Am I missing something glaring?!!

Please help!

Best regards

Bruce Barker

attach databases requires admin permission. this is due to security, if any
user could attach/detach, they access any database on the hard drive.

your best bet if to suppy an admin page, that does the attach, then grats
access to the process.

-- bruce (

Loane Sharp

Hi Bruce, Thanks for clarifying that.
It sounds like a great idea but I'm not sure exactly what you mean by the
following ...
your best bet if to suppy an admin page, that does the attach, then grats
access to the process.

How would I do this? Do you have any pointers?
Best regards

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Latest member

Latest Threads