Home All Groups Group Topic Archive Search About

Howto obtain WindowsIdentity for client calling method on COM+ application?

Author
21 Mar 2005 3:12 PM
Dominick Baier [DevelopMentor]
You mean the name of the caller??

That's in  SecurityCallContext.CurrentCall.DirectCaller.AccountName

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

   nntp://news.microsoft.com/microsoft.public.dotnet.security/<#ttsf3hLFHA.1***@TK2MSFTNGP15.phx.gbl>

We have a COM+ application written in C# (a serviced component) thats get
accessed by remote hosts on the network. How do I obtain the WindowsIdentity
of the caller of my serviced-component?


Regards Morten



[microsoft.public.dotnet.security]

Author
21 Mar 2005 8:44 PM
Morten Overgaard
Actually I want to get hold of the WindowsIdentity because I have to
impersonate the caller????
So how do you impersonate the caller?

Regards Morten

Show quoteHide quote
"Dominick Baier [DevelopMentor]" <dbaier@pleasepleasenospamdevelop.com>
wrote in message news:uPSRshiLFHA.1176@TK2MSFTNGP12.phx.gbl...
> You mean the name of the caller??
>
> That's in  SecurityCallContext.CurrentCall.DirectCaller.AccountName
>
> ---
> Dominick Baier - DevelopMentor
> http://www.leastprivilege.com
>
>
> nntp://news.microsoft.com/microsoft.public.dotnet.security/<#ttsf3hLFHA.1***@TK2MSFTNGP15.phx.gbl>
>
> We have a COM+ application written in C# (a serviced component) thats get
> accessed by remote hosts on the network. How do I obtain the
> WindowsIdentity
> of the caller of my serviced-component?
>
>
> Regards Morten
>
>
>
> [microsoft.public.dotnet.security]
Author
22 Mar 2005 9:52 AM
Dominick Baier [DevelopMentor]
Hello Morten,

ok - this works differently under Enterprise Services - you cannot get a
WindowsIdentity object, as everything in COM+ is handled via the SecurityCallContext.

To impersonate you have to P/Invoke CoImpersonateClient and CoRevertToSelf
- this is straightforward...

void IServer.OpenFileInClientContext(string FileName)
{
  try {
    COMSec.CoImpersonateClient();?    // Do work on behalf of the client?
  }? 
finally {
    COMSec.CoRevertToSelf();?  }
}


class COMSec {
  [DllImport("OLE32.DLL", CharSet=CharSet.Auto)]
  public static extern uint CoImpersonateClient();
  [DllImport("OLE32.DLL", CharSet=CharSet.Auto)]
  public static extern uint CoRevertToSelf();
}


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

Show quoteHide quote
> Actually I want to get hold of the WindowsIdentity because I have to
> impersonate the caller????
> So how do you impersonate the caller?
> Regards Morten
>
> "Dominick Baier [DevelopMentor]"
> <dbaier@pleasepleasenospamdevelop.com> wrote in message
> news:uPSRshiLFHA.1176@TK2MSFTNGP12.phx.gbl...
>
>> You mean the name of the caller??
>>
>> That's in  SecurityCallContext.CurrentCall.DirectCaller.AccountName
>>
>> ---
>> Dominick Baier - DevelopMentor
>> http://www.leastprivilege.com
>> nntp://news.microsoft.com/microsoft.public.dotnet.security/<#ttsf3hLF
>> HA.1***@TK2MSFTNGP15.phx.gbl>
>>
>> We have a COM+ application written in C# (a serviced component) thats
>> get
>> accessed by remote hosts on the network. How do I obtain the
>> WindowsIdentity
>> of the caller of my serviced-component?
>> Regards Morten
>>
>> [microsoft.public.dotnet.security]
>>