Re: .NET 2.0 Remoting Bug?
- From: Itay Sandbank <ItaySandbank@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 3 Apr 2006 00:51:02 -0700
Apparently it does not. It is set to a GenericPrincipal. I found another
post from about a month ago reporting the same problem. There was no real
solution. Thread.CurrentPrincipal.Identity IS set to a WindowsIdentity
(containing the correct user).
I ended up creating a PrincipalSink that does
Thread.CurrentPrincipal = new
WindowsPrincipal(Thread.CurrentPrincipal.Identity);
and now PrincipalPermission works OK. I reset Thread.CurrentPrincipal to
the GenericPrincipal after I finish handling the call.
I am not entirely aware of all the remoting interals and threading issues,
I hope I haven't opened the door to a world of race conditions and pain. For
instance, I'm not 100% sure that it will work with asynchronous calls (I
might reset the CurrentPrincipal of a DIFFERENT thread, because
AsyncProcessResponse and ProcessResponse may be called in two different
threads. Or not).
"Dominick Baier [DevelopMentor]" wrote:
Hi,.
i never experienced this - Thread.CurrentPrincipal should be set to a WindowsPrincipal
- for Windows groups you have to use the domain\group syntax for principalpermission
is Thread.CurrentPrincipal.Identity.Name set to the name of the client?
---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com
Hi.
I'm trying to apply role-based security to a .NET remoting server.
I'm using a secure TcpServerChannel with security turned on
(identification only, I don't want to impersonate the client), and I
want to limit access to a remoted method, like so:
class RemotedObject
{
[PrincipalPermission(SecurityAction.Demand, Role="Important")]
void MeaningfulStuff() { ... }
}
This fails miserably - no matter who the user running the client is.
Apparently Thread.CurrentPrincipal is set to a GenericEntity type
which never belongs to any roles. When I change the channel setting to
Impersonate, it works well.
Since I don't want to impersonate the client, I have no chance but
to create my own new
WindowsPrincipal(Thread.CurrentPrincipal.Identity) and ask it if it
IsInRole("Important") . Note that I need to to this trick even if the
client and server are running under exactly the same user.
Is there any reasonable fix for this .NET bug?
Itay.
- Follow-Ups:
- Re: .NET 2.0 Remoting Bug?
- From: Dominick Baier [DevelopMentor]
- Re: .NET 2.0 Remoting Bug?
- References:
- Re: .NET 2.0 Remoting Bug?
- From: Dominick Baier [DevelopMentor]
- Re: .NET 2.0 Remoting Bug?
- Prev by Date: Re: LDAP, Security Groups
- Next by Date: Re: Strange problem with X509Certificate2 on Windows 2003
- Previous by thread: Re: .NET 2.0 Remoting Bug?
- Next by thread: Re: .NET 2.0 Remoting Bug?
- Index(es):
Relevant Pages
|