De-impersonate to connect to SQL as Machine Account

O

Oleg Ogurok

Hi there,

My ASP.NET application has impersonation turned on in web.config as
follows:

<identity impersonate="true" />

However, now I need to connect to a SQL database. Rather than allowing
every single AD user access to the database, I'd like to connect to SQL
server as the computer account, e.g. MYWEBSERVER$. This should simplify
SQL security management, but most importantly, enable SQL connection
pooling.

If I turn impersonation off for the entire application (in web.config)
I get the desired result, i.e. the application runs as NETWORK SERVICE
user (IIS AppPool user), and I am able to connect to SQL -- good.
However this affects other parts of the application that require
impersonation to be turned on.

There doesn't seem to be a way to turn impersonation on or off per
page.

Is there a way to "temporarily" turn off impersonation? Or any other
way to connect to SQL and pass NETWORK SERVICE as the credentials?

Thanks,
-Oleg.
 
B

bruce barker \(sqlwork.com\)

see RevertToSelf in the windows api. because ado.net pooling is lazy about
connecting, you will have to surround all sql statements with RevertToSelf
and restore impersonation statements.


-- bruce (sqlwork.com)
 

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

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top