[Mono-list] Authorization in .NET Remoting channel

Maciej Paszta paszczi at go2.pl
Tue Jun 24 01:05:25 EDT 2008


>
> 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

Thanks!

I played a bit and this does the trick as well
ProcessMessage()
{
	Thread.CurrentPrincipal = .....
	_next.ProcessMessage()
}

and then

public class SomeObject : MarshalByRefObject
{
	void Method()
	{
		IPrincipal = Thread.CurrentPrincipal
	}
}

Though I'm not sure which one is better. I fear that my way may  
interfere with some CAS stuff in .NET itself, although after  
processing message I assign to Thread.CurrentPrincipal the original  
value.

P.S Sorry for the mail on priv :)

Best regards,
Maciej Paszta


More information about the Mono-list mailing list