determine ASP.NET worker process user context programatically?

Discussion in 'ASP .Net' started by =?Utf-8?B?RGFubnkgTWlsbGVy?=, Sep 30, 2005.

  1. 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
     
    =?Utf-8?B?RGFubnkgTWlsbGVy?=, Sep 30, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?RGFubnkgTWlsbGVy?=

    Karl Seguin Guest

    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.GetCurrent().Name

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



    "Danny Miller" <> wrote in message
    news:...
    > 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
    >
     
    Karl Seguin, Sep 30, 2005
    #2
    1. Advertising

  3. 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.GetCurrent().Name
    >
    > Karl
    > --
    > MY ASP.Net tutorials
    > http://www.openmymind.net/
    > http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
    >
    >
    >
    > "Danny Miller" <> wrote in message
    > news:...
    > > 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
    > >

    >
    >
    >
     
    =?Utf-8?B?RGFubnkgTWlsbGVy?=, Oct 1, 2005
    #3
  4. =?Utf-8?B?RGFubnkgTWlsbGVy?=

    Karl Seguin Guest

    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/d...y/en-us/vsent7/html/vxconaspnetdelegation.asp

    Karl

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



    "Danny Miller" <> wrote in message
    news:...
    >
    > 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.GetCurrent().Name
    >>
    >> Karl
    >> --
    >> MY ASP.Net tutorials
    >> http://www.openmymind.net/
    >> http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
    >>
    >>
    >>
    >> "Danny Miller" <> wrote in message
    >> news:...
    >> > 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
    >> >

    >>
    >>
    >>
     
    Karl Seguin, Oct 3, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave Mehrtens
    Replies:
    4
    Views:
    580
    Rick Strahl [MVP]
    Aug 19, 2003
  2. alex
    Replies:
    1
    Views:
    659
    Lau Lei Cheong
    Feb 4, 2005
  3. Andrea Raimondi
    Replies:
    1
    Views:
    508
  4. nicerun
    Replies:
    1
    Views:
    516
    bruce barker
    Nov 18, 2008
  5. Navin Mishra

    How to get process id of hosting ASP.NET worker process ?

    Navin Mishra, Feb 7, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    440
    Navin Mishra
    Feb 7, 2006
Loading...

Share This Page