[Mono-list] Authorization in .NET Remoting channel
Robert Jordan
robertj at gmx.net
Mon Jun 23 08:33:35 EDT 2008
paszczi wrote:
> Hi,
>
> I'm struggling to find a way of implementing authorization in .NET
> remoting. The issue is that I've developed custom sink and I'm able
> to pass some credentials which then can be authenticated by server.
> But what I want to do is to check whether remote user who has called
> shared object's method can in fact invoke it (using my custom
> security framework). I've tried to pass custom principal/identity to
> Thread.CrrentPrincipal - but somehow this is always empty
> GenericIdentity (I've tried this on windows and I've only managed to
> pass WindowsIdentity instead of empty one :(). Any suggestions - the
> basic issue is how to get those credentials from sink to the remoted
> object :)
>
You can inject the client identity in the current call context:
client:
// this is you sink's process message:
ProcessMessage(IMessage msg, ....)
{
MethodCall mc = msg as MethodCall;
if (mc != null) {
mc.LogicalCallContext.SetData ("UserName", WindowsIdentity.GetCurrent
().Name);
}
}
server:
class SomeRemoteClass : MarshalByRefObject
{
public void Method ()
{
Console.WriteLine (CallContext.GetData("UserName"));
}
}
There might be another ways to do this, though. I'm just writing this
down from weak memory ;-)
Robert
More information about the Mono-list
mailing list