all groups > dotnet security > june 2007 >
You're in the

dotnet security

group:

Implement "run as" for application within application....



Implement "run as" for application within application.... Dean Hinson
6/27/2007 4:52:01 AM
dotnet security: Hello,

I have been asked to implement a 'run as' methodology in a .net application.
I have read several threads regarding impersonation but have questions.

Here is what I think I need to do....

I have already a 'setting' that can be maintained off of the tool menu so
that the 'run as' creditentials can be maintained. I encode and decode the
password just in case. Now I want this 'impersonation' to override current
creditentials for the program while it is running.

Should this be done in the 'load' and 'close' of the main screen of the
application? Also, I read something about a powerful setting , something like
' as part of the operating system'. Is this neccessary for the original
application user or for the creditentials being used in the impersonation?

Basically, the staff wants the application to execute in a 'run as' mode.
Can you someone provide some assistance?

Thank you in advance.

Re: Implement "run as" for application within application.... Dean Hinson
6/27/2007 5:56:04 AM
Well, I don't know much about ProecessStartInformation but I'll look into it.
What I have done do far was to create an impersonate class and in the load
routine start the impersonation and in the close routine end impersonaton.
Will this work?

[quoted text, click to view]
Re: Implement "run as" for application within application.... Dominick Baier
6/27/2007 12:17:33 PM
Should this happen "inside" your app - like on the current thread - or do
you want to spawn a separate process?

for a)

- create a token from the credentials (use LogonUser for that)
- call WindowsIdentity.Impersonate on that token (put that into a using block)

for b)

- supply credentials in a ProcessStartInformation
- pass the PSI into Process.Start


-----
Dominick Baier (http://www.leastprivilege.com)

Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

[quoted text, click to view]

Re: Implement "run as" for application within application.... Dominick Baier
6/27/2007 3:25:57 PM
You shouldn't do that.

Impersonation should only be done a limited amount of time. Historically
impersonation only affects the main thread - .NET works around that behavior
for most cases. But you might experience anomalies when creating new threads
or doing other kinds of thread switches (e.g. when calling COM components).

If you want a process to run under a certain identity - start it like that.
Process.Start accomplishes that.


-----
Dominick Baier (http://www.leastprivilege.com)

Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

[quoted text, click to view]

AddThis Social Bookmark Button