469,267 Members | 971 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,267 developers. It's quick & easy.

determine ASP.NET worker process user context programatically?

Hi there,

I've got a web app that uses impersonation and makes calls to a SQL Server
backend. I'd like to be able to automate the setting of database security for
the web app upon deployment. What I'd like to do during installation is the
following:

- run the database creation script
- determine the user context that the ASP.NET worker process is running under
- assign privileges for that user in the new database

Can anyone tell me if it is possible to programmatically determine the user
context that the ASP.NET worker process is running under and if so, how?

Under IIS5 this would be a case of interrogating the <ProcessModel> node in
Machine.config would it not? However, I'm not so sure if this is
deterministic and also, the same method won't work for machines running IIS6.

Thank you,

Danny

Nov 19 '05 #1
3 2274
Well, you can get a lot of information from System.Diagnostic.Process, but I
don't think you can get what you want...

I believe this will work for you though:
System.Security.Principal.WindowsIdentity.GetCurre nt().Name

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Danny Miller" <Da*********@discussions.microsoft.com> wrote in message
news:6E**********************************@microsof t.com...
Hi there,

I've got a web app that uses impersonation and makes calls to a SQL Server
backend. I'd like to be able to automate the setting of database security
for
the web app upon deployment. What I'd like to do during installation is
the
following:

- run the database creation script
- determine the user context that the ASP.NET worker process is running
under
- assign privileges for that user in the new database

Can anyone tell me if it is possible to programmatically determine the
user
context that the ASP.NET worker process is running under and if so, how?

Under IIS5 this would be a case of interrogating the <ProcessModel> node
in
Machine.config would it not? However, I'm not so sure if this is
deterministic and also, the same method won't work for machines running
IIS6.

Thank you,

Danny

Nov 19 '05 #2

I might have to elaborate a little more. I will be attempting to obtain the
ASP.NET worker process id from within an msi custom action, not from within a
web app. The call you provided would do what's required from within a web
app but would provide no information about the ASP.NET worker process from
within an msi custom action.

"Karl Seguin" wrote:
Well, you can get a lot of information from System.Diagnostic.Process, but I
don't think you can get what you want...

I believe this will work for you though:
System.Security.Principal.WindowsIdentity.GetCurre nt().Name

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Danny Miller" <Da*********@discussions.microsoft.com> wrote in message
news:6E**********************************@microsof t.com...
Hi there,

I've got a web app that uses impersonation and makes calls to a SQL Server
backend. I'd like to be able to automate the setting of database security
for
the web app upon deployment. What I'd like to do during installation is
the
following:

- run the database creation script
- determine the user context that the ASP.NET worker process is running
under
- assign privileges for that user in the new database

Can anyone tell me if it is possible to programmatically determine the
user
context that the ASP.NET worker process is running under and if so, how?

Under IIS5 this would be a case of interrogating the <ProcessModel> node
in
Machine.config would it not? However, I'm not so sure if this is
deterministic and also, the same method won't work for machines running
IIS6.

Thank you,

Danny


Nov 19 '05 #3
I honnestly don't know in that case. You could read the machine.config's
processModel section to read how asp.net is configured to run by default,
and go at it from there.

This link might, though probably not, be useful:
http://msdn.microsoft.com/library/de...delegation.asp

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Danny Miller" <Da*********@discussions.microsoft.com> wrote in message
news:A4**********************************@microsof t.com...

I might have to elaborate a little more. I will be attempting to obtain
the
ASP.NET worker process id from within an msi custom action, not from
within a
web app. The call you provided would do what's required from within a web
app but would provide no information about the ASP.NET worker process
from
within an msi custom action.

"Karl Seguin" wrote:
Well, you can get a lot of information from System.Diagnostic.Process,
but I
don't think you can get what you want...

I believe this will work for you though:
System.Security.Principal.WindowsIdentity.GetCurre nt().Name

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Danny Miller" <Da*********@discussions.microsoft.com> wrote in message
news:6E**********************************@microsof t.com...
> Hi there,
>
> I've got a web app that uses impersonation and makes calls to a SQL
> Server
> backend. I'd like to be able to automate the setting of database
> security
> for
> the web app upon deployment. What I'd like to do during installation is
> the
> following:
>
> - run the database creation script
> - determine the user context that the ASP.NET worker process is running
> under
> - assign privileges for that user in the new database
>
> Can anyone tell me if it is possible to programmatically determine the
> user
> context that the ASP.NET worker process is running under and if so,
> how?
>
> Under IIS5 this would be a case of interrogating the <ProcessModel>
> node
> in
> Machine.config would it not? However, I'm not so sure if this is
> deterministic and also, the same method won't work for machines running
> IIS6.
>
> Thank you,
>
> Danny
>


Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Studio P.M. | last post: by
7 posts views Thread by Dave Mehrtens | last post: by
2 posts views Thread by Chris Carter | last post: by
reply views Thread by Gregory Gadow | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.