using System; using System.Security.Principal; using System.Threading; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; using System.Runtime.Remoting.Messaging; public class Client { static public void Main() { GenericIdentity identity=new GenericIdentity("Alice"); GenericPrincipal principal=new GenericPrincipal(identity, new string[] {"Auditor"}); Thread.CurrentPrincipal=principal; ForeignPrincipal fp=new ForeignPrincipal(Thread.CurrentPrincipal); CallContext.SetData("ClientContext", fp); TcpChannel channel=new TcpChannel(); ChannelServices.RegisterChannel(channel); IServer server=(IServer) Activator.GetObject( typeof(IServer), "tcp://127.0.0.1:4000/TheServer"); server.DoSomething(); } }