|
|
|
date: Thu, 15 May 2008 01:01:05 -0700 (PDT),
group: microsoft.public.dotnet.security
back
Re: WindowsIdentity.GetCurrent
On May 15, 8:04 pm, despird wrote:
> On May 15, 5:40 pm, Dominick Baier
>
>
>
>
>
> wrote:
> > first, WindowsIdentity.GetCurrent has an overload that you can use to determine
> > if you are currently impersonating.
>
> > then you can undo impersonation temporarily to get to the process account
>
> > do this
>
> > using (WindowsIdentity.Impersonate(IntPtr.Zero))
> > {
> > string process = WindowsIdentity.GetCurrent();
>
> > }
>
> > from the docs:
> > "Calling the Impersonate(IntPtr) method with a userToken value of Zero is
> > equivalent to calling the Win32 RevertToSelf function. If another user is
> > currently being impersonated, control reverts to the original user."
>
> > -----
> > Dominick Baier (http://www.leastprivilege.com)
>
> > Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)
>
> > > System.Security.Principal.WindowsIdentity.GetCurrent() can give me the> > > current logged-on user, but I found if I'm using impersonation in the
> > > context, it can only give me the user identity who's being
> > > impersonated rather than the real logged user on the Windows, what if
> > > I want the latter?- Hide quoted text -
>
> > - Show quoted text -
>
> that seems to be a very plausible solution, i'll try it again tomorrow
> thanks a lot.- Hide quoted text -
>
> - Show quoted text -
that does work, thanks a lot Dominick
date: Thu, 15 May 2008 17:41:10 -0700 (PDT)
author: despird
|
|