Obtaining Application Pool Identity in Inpersonation Mode

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Obtaining Application Pool Identity in Inpersonation Mode

    I have an ASP.Net application running on IIS 6.0 that is configured to
    impersonate the identity of the user who is accessing the page. I am
    wanting to have code that runs as the identity of the application pool for
    which this website runs as. is there a way to do this in code?


    Adam Roe Guest

  2. Similar Questions and Discussions

    1. Windows authentication breaks after configuring application pool identity
      Hi group I run IIS 6.0 on W2k3 being an Active Directory Controller in a test lab. Create a virtual directory 'test' with Windows authentication...
    2. Obtaining Client's IP when the application is remotelyconnected via Edge
      Hello, When I have only one FMS running and a client connecting to it, I can obtain the client IP during the application.onConnect function...
    3. SQL / IIS Application Pool Identity
      Hi, I've got an ASP.NET web application which uses Windows security with a SQL Server database. I want to use the application pool identity to...
    4. Impersonate IIS Application Pool Identity
      How do I get an IIS application pool identity, and create a Windows Impersonation Context from it? Troy
    5. Problems after changing Identity Application Pool Settings (sn-yycbk.dll)
      Applies to: W2K3 Server / IIS6 / Default Isolation Mode / ASP.NET 1.1 We wish to run our ASPNET worker process in a domain account so as to use...
  3. #2

    Default RE: Obtaining Application Pool Identity in Inpersonation Mode

    Adam,

    You would normally impersonate only when you want to run code under a
    different identity than the application pool. Is there a specific need to
    impersonate in your application?

    Jim Cheshire, MCSE, MCSD [MSFT]
    ASP.NET
    Developer Support
    [email]jamesche@online.microsoft.com[/email]

    This post is provided as-is with no warranties and confers no rights.

    --------------------
    >From: "Adam Roe" <roeadam@hotmail.com>
    >Subject: Obtaining Application Pool Identity in Inpersonation Mode
    >Date: Wed, 21 Jan 2004 23:31:20 -0500
    >Lines: 6
    >X-Priority: 3
    >X-MSMail-Priority: Normal
    >X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
    >Message-ID: <u7dWWCK4DHA.4084@TK2MSFTNGP11.phx.gbl>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet.security
    >NNTP-Posting-Host: adsl-67-39-0-49.dsl.dytnoh.ameritech.net 67.39.0.49
    >Path:
    cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTN GP08.phx.gbl!TK2MSFTNGP11.
    phx.gbl
    >Xref: cpmsftngxa07.phx.gbl
    microsoft.public.dotnet.framework.aspnet.security: 8320
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.security
    >
    >I have an ASP.Net application running on IIS 6.0 that is configured to
    >impersonate the identity of the user who is accessing the page. I am
    >wanting to have code that runs as the identity of the application pool for
    >which this website runs as. is there a way to do this in code?
    >
    >
    >
    Jim Cheshire [MSFT] Guest

  4. #3

    Default Re: Obtaining Application Pool Identity in Inpersonation Mode

    The Server control that I am building must run in windows sharepoint
    services which requires impersonation. I am wanting to connect to a SQL
    Server DB using SSPI and I was wanting to run the Application Pool as a
    domain user that has writes on the SQL Server Database. I am starting to
    think that my approach might be wrong could you recommend a better way of
    doing this. Should I build a COM+ component to make the data call or can I
    change the security context on just the Thread while I am making the call?
    I haven't done a hole lot with .net security so any advice would be great.

    Thanks
    Adam Roe

    "Jim Cheshire [MSFT]" <jamesche@online.microsoft.com> wrote in message
    news:hXLxvNQ4DHA.1992@cpmsftngxa07.phx.gbl...
    > Adam,
    >
    > You would normally impersonate only when you want to run code under a
    > different identity than the application pool. Is there a specific need to
    > impersonate in your application?
    >
    > Jim Cheshire, MCSE, MCSD [MSFT]
    > ASP.NET
    > Developer Support
    > [email]jamesche@online.microsoft.com[/email]
    >
    > This post is provided as-is with no warranties and confers no rights.
    >
    > --------------------
    > >From: "Adam Roe" <roeadam@hotmail.com>
    > >Subject: Obtaining Application Pool Identity in Inpersonation Mode
    > >Date: Wed, 21 Jan 2004 23:31:20 -0500
    > >Lines: 6
    > >X-Priority: 3
    > >X-MSMail-Priority: Normal
    > >X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
    > >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
    > >Message-ID: <u7dWWCK4DHA.4084@TK2MSFTNGP11.phx.gbl>
    > >Newsgroups: microsoft.public.dotnet.framework.aspnet.security
    > >NNTP-Posting-Host: adsl-67-39-0-49.dsl.dytnoh.ameritech.net 67.39.0.49
    > >Path:
    >
    cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTN GP08.phx.gbl!TK2MSFTNGP11.
    > phx.gbl
    > >Xref: cpmsftngxa07.phx.gbl
    > microsoft.public.dotnet.framework.aspnet.security: 8320
    > >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.security
    > >
    > >I have an ASP.Net application running on IIS 6.0 that is configured to
    > >impersonate the identity of the user who is accessing the page. I am
    > >wanting to have code that runs as the identity of the application pool
    for
    > >which this website runs as. is there a way to do this in code?
    > >
    > >
    > >
    >

    Adam Roe Guest

  5. #4

    Default Re: Obtaining Application Pool Identity in Inpersonation Mode

    That said, if you really need to be able to do this, you should be able to
    strip off the impersonating token by calling the Windows API RevertToSelf
    via P/Invoke. If you need to go back to impersonating, you should hold onto
    the WindowsIdentity so you can create a new impersonation context.

    I also don't understand why you are impersonating if you need to not
    impersonate in your app, but perhaps there is a legitimate reason for doing
    this.

    Joe K.

    "Jim Cheshire [MSFT]" <jamesche@online.microsoft.com> wrote in message
    news:hXLxvNQ4DHA.1992@cpmsftngxa07.phx.gbl...
    > Adam,
    >
    > You would normally impersonate only when you want to run code under a
    > different identity than the application pool. Is there a specific need to
    > impersonate in your application?
    >
    > Jim Cheshire, MCSE, MCSD [MSFT]
    > ASP.NET
    > Developer Support
    > [email]jamesche@online.microsoft.com[/email]
    >
    > This post is provided as-is with no warranties and confers no rights.
    >
    > --------------------
    > >From: "Adam Roe" <roeadam@hotmail.com>
    > >Subject: Obtaining Application Pool Identity in Inpersonation Mode
    > >Date: Wed, 21 Jan 2004 23:31:20 -0500
    > >Lines: 6
    > >X-Priority: 3
    > >X-MSMail-Priority: Normal
    > >X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
    > >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
    > >Message-ID: <u7dWWCK4DHA.4084@TK2MSFTNGP11.phx.gbl>
    > >Newsgroups: microsoft.public.dotnet.framework.aspnet.security
    > >NNTP-Posting-Host: adsl-67-39-0-49.dsl.dytnoh.ameritech.net 67.39.0.49
    > >Path:
    >
    cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTN GP08.phx.gbl!TK2MSFTNGP11.
    > phx.gbl
    > >Xref: cpmsftngxa07.phx.gbl
    > microsoft.public.dotnet.framework.aspnet.security: 8320
    > >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.security
    > >
    > >I have an ASP.Net application running on IIS 6.0 that is configured to
    > >impersonate the identity of the user who is accessing the page. I am
    > >wanting to have code that runs as the identity of the application pool
    for
    > >which this website runs as. is there a way to do this in code?
    > >
    > >
    > >
    >

    Joe Kaplan \(MVP - ADSI\) Guest

  6. #5

    Default Re: Obtaining Application Pool Identity in Inpersonation Mode

    COM+ is probably the "right" way to do what you want. That allows you more
    fine-grained control over the account that is used to access SQL and
    decouples it from the ASP.NET worker process.

    However, you could probably use the trick I suggested in my other post to
    call RevertToSelf and then start impersonation again when you are done.
    That would require that you have unmanaged code execution permissions and
    sounds a lot like a hack that would be difficult to support. Hence the COM+
    suggestion.

    Remoting or Web Services would also give you another way to get into a
    different process context, but they should all be slower and thus not as
    desirable unless you want that additional functionality.

    Joe K.

    "Adam Roe" <roeadam@hotmail.com> wrote in message
    news:ehZ6gXQ4DHA.632@TK2MSFTNGP12.phx.gbl...
    > The Server control that I am building must run in windows sharepoint
    > services which requires impersonation. I am wanting to connect to a SQL
    > Server DB using SSPI and I was wanting to run the Application Pool as a
    > domain user that has writes on the SQL Server Database. I am starting to
    > think that my approach might be wrong could you recommend a better way of
    > doing this. Should I build a COM+ component to make the data call or can
    I
    > change the security context on just the Thread while I am making the call?
    > I haven't done a hole lot with .net security so any advice would be great.
    >
    > Thanks
    > Adam Roe
    >
    > "Jim Cheshire [MSFT]" <jamesche@online.microsoft.com> wrote in message
    > news:hXLxvNQ4DHA.1992@cpmsftngxa07.phx.gbl...
    > > Adam,
    > >
    > > You would normally impersonate only when you want to run code under a
    > > different identity than the application pool. Is there a specific need
    to
    > > impersonate in your application?
    > >
    > > Jim Cheshire, MCSE, MCSD [MSFT]
    > > ASP.NET
    > > Developer Support
    > > [email]jamesche@online.microsoft.com[/email]
    > >
    > > This post is provided as-is with no warranties and confers no rights.
    > >
    > > --------------------
    > > >From: "Adam Roe" <roeadam@hotmail.com>
    > > >Subject: Obtaining Application Pool Identity in Inpersonation Mode
    > > >Date: Wed, 21 Jan 2004 23:31:20 -0500
    > > >Lines: 6
    > > >X-Priority: 3
    > > >X-MSMail-Priority: Normal
    > > >X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
    > > >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
    > > >Message-ID: <u7dWWCK4DHA.4084@TK2MSFTNGP11.phx.gbl>
    > > >Newsgroups: microsoft.public.dotnet.framework.aspnet.security
    > > >NNTP-Posting-Host: adsl-67-39-0-49.dsl.dytnoh.ameritech.net 67.39.0.49
    > > >Path:
    > >
    >
    cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTN GP08.phx.gbl!TK2MSFTNGP11.
    > > phx.gbl
    > > >Xref: cpmsftngxa07.phx.gbl
    > > microsoft.public.dotnet.framework.aspnet.security: 8320
    > > >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.security
    > > >
    > > >I have an ASP.Net application running on IIS 6.0 that is configured to
    > > >impersonate the identity of the user who is accessing the page. I am
    > > >wanting to have code that runs as the identity of the application pool
    > for
    > > >which this website runs as. is there a way to do this in code?
    > > >
    > > >
    > > >
    > >
    >
    >

    Joe Kaplan \(MVP - ADSI\) Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139