Re: Howto obtain WindowsIdentity for client calling method on COM+ application?
From: Dominick Baier [DevelopMentor] (dbaier_at_pleasepleasenospamdevelop.com)
Date: 03/22/05
- Previous message: Ignus Fast: "Re: Error instantiating RSACryptoServiceProvider"
- In reply to: Morten Overgaard: "Re: Howto obtain WindowsIdentity for client calling method on COM+ application?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Tue, 22 Mar 2005 01:52:59 -0800
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
> 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.1884@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]
>>
- Previous message: Ignus Fast: "Re: Error instantiating RSACryptoServiceProvider"
- In reply to: Morten Overgaard: "Re: Howto obtain WindowsIdentity for client calling method on COM+ application?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|