473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 2479
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mark | last post by:
Hi... We're looking at moving an ASP app from IIS 5 to IIS 6. In general things seem to be working okay, but there are some oddities around the edges. One of those unanticipated changes has to...
2
by: Studio P.M. | last post by:
Does anyone know a valid and compete reference paper about what the “Worker Process” precisely is and does? So far I couldn’t find any. Reason is that during last weeks I had to go deep...
7
by: Dave Mehrtens | last post by:
I am trying to configure my ASP.NET application and have come across something unexpected. First, I understand that all ASP.NET applications running on a single server will utilize a single...
2
by: Chris Carter | last post by:
We have a site, for reference I'll call this MainSite, that has certain pages actually hosted on another site, I'll call this ChildSite. In MainSite when you click on a certain link, it loads a...
9
by: Abhishek Srivastava | last post by:
Hello All, In IIS 6.0 We have a concept of worker processes and application pools. As I understand it, we can have multiple worker process per appliction pool. Each worker process is dedicated...
3
by: Christopher | last post by:
One of our ASP.NET Pages is starting a new Process using the Process object. When the process starts, it is started under the ASPNET User. We tried editing the web.config file and the...
1
by: justin | last post by:
I have the problem that I need to programatically add new url mappings to the web.config file in an asp 2.0 app. e.g. my code is Dim urlMappings As UrlMappingCollection =...
0
by: Gregory Gadow | last post by:
Still working on this project. What I have working: I have a service that uses FileSystemWatcher on an "in box" folder. When a text file appears in the in-box, it copies the file to a work...
1
by: nicerun | last post by:
I'm using the Application_Start event at Global.asax.cs to invoke thread that do some job. I know that Application_Start event occurs when the very first request to Web Application received. -...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.