Home All Groups Group Topic Archive Search About

How do I use windowsIdentity to start a process in .net?

Author
14 Nov 2006 2:42 PM
brett.mack
Hello, and thanks in advance.

I'm using the logonuser function within vb.net to obtain a
windowsIdentity. Now how do I start a process using it, within vb.net?
I need all functions after obtaining the windowsIdentity to use it.

Author
14 Nov 2006 6:39 PM
Claus Konrad [MCSD]
In .NET (C# and VB) you use the ImpersonationContext construct to obtain a
context in which you can launch a process.

In C#:
WindowsIdentity winID = new WindowsIdentity(token);
using(ImpersonationContext ctx = new ImpersonationContext(winID))
{
//launch process here..
}

//here no longer impersonated
--
rgds.
/Claus Konrad
MCSD.NET (C#)


Show quoteHide quote
"brett.m***@gmail.com" wrote:

> Hello, and thanks in advance.
>
> I'm using the logonuser function within vb.net to obtain a
> windowsIdentity. Now how do I start a process using it, within vb.net?
> I need all functions after obtaining the windowsIdentity to use it.
>
>
Author
15 Nov 2006 9:19 AM
Dominick Baier
this will not work - new processes will inherit the parent process token
- not the impersonation token...

The Process.Start takes a StartupInformation object - there you can specify
the credentials to use to start a new process - there is also a Win32 API
that uses a token to start new processes (name escapes me at the moment)

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

Show quoteHide quote
> In .NET (C# and VB) you use the ImpersonationContext construct to
> obtain a context in which you can launch a process.
>
> In C#:
> WindowsIdentity winID = new WindowsIdentity(token);
> using(ImpersonationContext ctx = new ImpersonationContext(winID))
> {
> //launch process here..
> }
> //here no longer impersonated
>
> "brett.m***@gmail.com" wrote:
>
>> Hello, and thanks in advance.
>>
>> I'm using the logonuser function within vb.net to obtain a
>> windowsIdentity. Now how do I start a process using it, within
>> vb.net? I need all functions after obtaining the windowsIdentity to
>> use it.
>>
Author
15 Nov 2006 2:00 PM
Claus Konrad [MCSD]
That behaviour has been corrected in .NET 2.0.

--
rgds.
/Claus Konrad
MCSD.NET (C#)


Show quoteHide quote
"Dominick Baier" wrote:

> this will not work - new processes will inherit the parent process token
> - not the impersonation token...
>
> The Process.Start takes a StartupInformation object - there you can specify
> the credentials to use to start a new process - there is also a Win32 API
> that uses a token to start new processes (name escapes me at the moment)
>
> ---
> Dominick Baier, DevelopMentor
> http://www.leastprivilege.com
>
> > In .NET (C# and VB) you use the ImpersonationContext construct to
> > obtain a context in which you can launch a process.
> >
> > In C#:
> > WindowsIdentity winID = new WindowsIdentity(token);
> > using(ImpersonationContext ctx = new ImpersonationContext(winID))
> > {
> > //launch process here..
> > }
> > //here no longer impersonated
> >
> > "brett.m***@gmail.com" wrote:
> >
> >> Hello, and thanks in advance.
> >>
> >> I'm using the logonuser function within vb.net to obtain a
> >> windowsIdentity. Now how do I start a process using it, within
> >> vb.net? I need all functions after obtaining the windowsIdentity to
> >> use it.
> >>
>
>
>
Author
15 Nov 2006 2:57 PM
Dominick Baier
no - thats not the case.

They changed a lot of the token propagation details for spawning new threads
while impersonating. This does _not_ apply to processes.

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

Show quoteHide quote
> That behaviour has been corrected in .NET 2.0.
>
> "Dominick Baier" wrote:
>
>> this will not work - new processes will inherit the parent process
>> token - not the impersonation token...
>>
>> The Process.Start takes a StartupInformation object - there you can
>> specify the credentials to use to start a new process - there is also
>> a Win32 API that uses a token to start new processes (name escapes me
>> at the moment)
>>
>> ---
>> Dominick Baier, DevelopMentor
>> http://www.leastprivilege.com
>>> In .NET (C# and VB) you use the ImpersonationContext construct to
>>> obtain a context in which you can launch a process.
>>>
>>> In C#:
>>> WindowsIdentity winID = new WindowsIdentity(token);
>>> using(ImpersonationContext ctx = new ImpersonationContext(winID))
>>> {
>>> //launch process here..
>>> }
>>> //here no longer impersonated
>>> "brett.m***@gmail.com" wrote:
>>>
>>>> Hello, and thanks in advance.
>>>>
>>>> I'm using the logonuser function within vb.net to obtain a
>>>> windowsIdentity. Now how do I start a process using it, within
>>>> vb.net? I need all functions after obtaining the windowsIdentity to
>>>> use it.
>>>>
Author
15 Nov 2006 3:13 PM
Claus Konrad [MCSD]
You are correct. It  is related to threads spawned.

Thx.

--
rgds.
/Claus Konrad
MCSD.NET (C#)


Show quoteHide quote
"Dominick Baier" wrote:

> no - thats not the case.
>
> They changed a lot of the token propagation details for spawning new threads
> while impersonating. This does _not_ apply to processes.
>
> ---
> Dominick Baier, DevelopMentor
> http://www.leastprivilege.com
>
> > That behaviour has been corrected in .NET 2.0.
> >
> > "Dominick Baier" wrote:
> >
> >> this will not work - new processes will inherit the parent process
> >> token - not the impersonation token...
> >>
> >> The Process.Start takes a StartupInformation object - there you can
> >> specify the credentials to use to start a new process - there is also
> >> a Win32 API that uses a token to start new processes (name escapes me
> >> at the moment)
> >>
> >> ---
> >> Dominick Baier, DevelopMentor
> >> http://www.leastprivilege.com
> >>> In .NET (C# and VB) you use the ImpersonationContext construct to
> >>> obtain a context in which you can launch a process.
> >>>
> >>> In C#:
> >>> WindowsIdentity winID = new WindowsIdentity(token);
> >>> using(ImpersonationContext ctx = new ImpersonationContext(winID))
> >>> {
> >>> //launch process here..
> >>> }
> >>> //here no longer impersonated
> >>> "brett.m***@gmail.com" wrote:
> >>>
> >>>> Hello, and thanks in advance.
> >>>>
> >>>> I'm using the logonuser function within vb.net to obtain a
> >>>> windowsIdentity. Now how do I start a process using it, within
> >>>> vb.net? I need all functions after obtaining the windowsIdentity to
> >>>> use it.
> >>>>
>
>
>