Psst! Did you know DevelopmentNow is a mobile web site design agency?

Contact us for help mobilizing your site, or to sign up for our beta Mobile Web SDK!
all groups > dotnet security > may 2005 >

dotnet security : Impersonation through HttpModule


otto
5/26/2005 1:16:04 AM
Hi, all:
I have a question about security in ASP.NET applications. We´ve to develop
several applications. All of them with Windows integrated security in IIS.
Each application must run under one domain account (each application has its
own account), so we´ve to use impersonation. How can I do this with
HttpModule´s?

Dominick Baier [DevelopMentor]
5/26/2005 2:00:36 AM
Hello otto,

on which platform (IIS5 or 6)

---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com

[quoted text, click to view]


otto
5/26/2005 6:26:21 AM
Hi, Dominick:

both of them. What´s the difference? I have few experience with IIS 6.0



[quoted text, click to view]
Joe Kaplan (MVP - ADSI)
5/26/2005 9:42:43 AM
Programmatic impersonation on IIS5 is painful because normal accounts can't
call the LogonUser API on Win2K. This restriction is removed in XP and 2K3.

On IIS6, I would recommend you do this without using impersonation,
especially programmatic. It is much easier to set up a single AppPool for
each application that runs under the specified domain account (and disable
impersonation in web.config). The other option would be to use explicit
impersonation in web.config, supplying a username and password there.

On IIS 5 this is harder. There are no AppPools, so there is no good way to
have a process account for each app as there is only one process. You can't
use programmatic impersonation (or explicit impersonation of a specific user
via web.config) with the default settings because you won't have rights to
call LogonUser.

The first thing you will need to do is figure out how you will get the
necessary permissions to call LogonUser in the first place. One way might
be to give the ASPNET account the "Act as part of the operating system"
privilege in local security policy, but that also seriously compromises the
security of the web server (although possible not as much as simplying
running it as SYSTEM).

Joe K.
[quoted text, click to view]

Dominick Baier [DevelopMentor]
5/26/2005 9:56:58 AM
Hello Joe,

yes!

i recommend to move away from IIS5 and use app pools. Use impersonation only
if you have to.

---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com

[quoted text, click to view]


otto
5/26/2005 11:55:02 PM
Hi, Joe:
Is there another way to make impersonation instead using LogonUser? Using
IPrincipal objects or Thread objects, HttpContext...
Thanks for your help.

[quoted text, click to view]
Dominick Baier [DevelopMentor]
5/27/2005 4:09:12 AM
Hello otto,

you can use the

<identity impersonate="true" /> element in web.config.

as i said - when you are impersonating you are in a wacky state...try to
keep it to a minimum.

---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com

[quoted text, click to view]


Joe Kaplan (MVP - ADSI)
5/27/2005 9:56:47 AM
You might also consider using SSPI directly to create a token for a user,
but that is more complex and might not do what you want. Another
alternative for Win2K would be to place all of your code that needs a
special identity in a separate component that you set up under COM+ to run
as a special identity.

Joe K.

[quoted text, click to view]

AddThis Social Bookmark Button