public void TestUnregisterListener() { Guid iid = Guid.NewGuid(); using (RpcServerApi server = new RpcServerApi(iid)) { server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5); server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT); server.StartListening(); RpcServerApi.RpcExecuteHandler handler = delegate(IRpcClientInfo client, byte[] arg) { return arg; }; using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest")) { client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT); server.OnExecute += handler; client.Execute(new byte[0]); server.OnExecute -= handler; try { client.Execute(new byte[0]); Assert.Fail(); } catch (RpcException) { } } } }
public void TestClientAbandon() { var iid = Guid.NewGuid(); using (RpcServerApi server = new RpcServerApi(iid)) { server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5); server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT); server.StartListening(); server.OnExecute += delegate(IRpcClientInfo client, byte[] arg) { return(arg); }; { RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest"); client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT); client.Execute(new byte[0]); client = null; } GC.Collect(0, GCCollectionMode.Forced); GC.WaitForPendingFinalizers(); server.StopListening(); } }
public void TestUnregisterListener() { Guid iid = Guid.NewGuid(); using (RpcServerApi server = new RpcServerApi(iid)) { server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5); server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT); server.StartListening(); RpcServerApi.RpcExecuteHandler handler = delegate(IRpcClientInfo client, byte[] arg) { return(arg); }; using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest")) { client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT); server.OnExecute += handler; client.Execute(new byte[0]); server.OnExecute -= handler; try { client.Execute(new byte[0]); Assert.Fail(); } catch (RpcException) { } } } }
public void TestClientOnLocalRpc() { Guid iid = Guid.NewGuid(); using (RpcServerApi server = new RpcServerApi(iid)) { server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5); server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT); server.StartListening(); server.OnExecute += delegate(IRpcClientInfo client, byte[] arg) { Assert.AreEqual(0, arg.Length); Assert.AreEqual(RpcAuthentication.RPC_C_AUTHN_WINNT, client.AuthenticationLevel); Assert.AreEqual(RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, client.ProtectionLevel); Assert.AreEqual(RpcProtoseqType.LRPC, client.ProtocolType); Assert.AreEqual(new byte[0], client.ClientAddress); Assert.AreEqual(System.Diagnostics.Process.GetCurrentProcess().Id, client.ClientPid.ToInt32()); Assert.AreEqual(System.Security.Principal.WindowsIdentity.GetCurrent().Name, client.ClientPrincipalName); Assert.AreEqual(System.Security.Principal.WindowsIdentity.GetCurrent().Name, client.ClientUser.Name); Assert.AreEqual(true, client.IsClientLocal); Assert.AreEqual(true, client.IsAuthenticated); Assert.AreEqual(false, client.IsImpersonating); using(client.Impersonate()) Assert.AreEqual(true, client.IsImpersonating); Assert.AreEqual(false, client.IsImpersonating); return arg; }; using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest")) { client.AuthenticateAs(RpcClientApi.Self); client.Execute(new byte[0]); } } }
public void TestPerformanceOnLocalRpc() { Guid iid = Guid.NewGuid(); using (RpcServerApi server = new RpcServerApi(iid)) { server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5); server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT); server.StartListening(); server.OnExecute += delegate(IRpcClientInfo client, byte[] arg) { return arg; }; using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest")) { client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT); client.Execute(new byte[0]); byte[] bytes = new byte[512]; new Random().NextBytes(bytes); Stopwatch timer = new Stopwatch(); timer.Start(); for (int i = 0; i < 10000; i++) client.Execute(bytes); timer.Stop(); Trace.WriteLine(timer.ElapsedMilliseconds.ToString(), "ncalrpc-timming"); } } }
public void TestClientAbandon() { Guid iid = Guid.NewGuid(); using (RpcServerApi server = new RpcServerApi(iid)) { server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5); server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT); server.StartListening(); server.OnExecute += delegate(IRpcClientInfo client, byte[] arg) { return arg; }; { RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest"); client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT); client.Execute(new byte[0]); client = null; } GC.Collect(0, GCCollectionMode.Forced); GC.WaitForPendingFinalizers(); server.StopListening(); } }
public void TestNestedClientImpersonate() { Guid iid = Guid.NewGuid(); using (RpcServerApi server = new RpcServerApi(iid)) { server.AddProtocol(RpcProtseq.ncacn_np, @"\pipe\testpipename", 5); server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT); server.StartListening(); server.OnExecute += delegate(IRpcClientInfo client, byte[] arg) { Assert.AreEqual(false, client.IsImpersonating); using (client.Impersonate()) { Assert.AreEqual(true, client.IsImpersonating); using (client.Impersonate()) Assert.AreEqual(true, client.IsImpersonating); //does not dispose, we are still impersonating Assert.AreEqual(true, client.IsImpersonating); } Assert.AreEqual(false, client.IsImpersonating); return(arg); }; using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncacn_np, null, @"\pipe\testpipename")) { client.AuthenticateAs(RpcClientApi.Self); client.Execute(new byte[0]); } } }
public void TestPerformanceOnLocalRpc() { Guid iid = Guid.NewGuid(); using (RpcServerApi server = new RpcServerApi(iid)) { server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5); server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT); server.StartListening(); server.OnExecute += delegate(IRpcClientInfo client, byte[] arg) { return(arg); }; using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest")) { client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT); client.Execute(new byte[0]); byte[] bytes = new byte[512]; new Random().NextBytes(bytes); Stopwatch timer = new Stopwatch(); timer.Start(); for (int i = 0; i < 10000; i++) { client.Execute(bytes); } timer.Stop(); Trace.WriteLine(timer.ElapsedMilliseconds.ToString(), "ncalrpc-timming"); } } }
protected override void AuthenticateClient(RpcAuthenticationType type, NetworkCredential credentials) { switch (type) { case RpcAuthenticationType.User: _client.AuthenticateAs(ServerPrincipalName, credentials); break; case RpcAuthenticationType.Self: _client.AuthenticateAs(ServerPrincipalName, RpcClientApi.Self); break; default: _client.AuthenticateAs(ServerPrincipalName, RpcClientApi.Anonymous); break; } }
static void Main(string[] args) { RpcLibrary.Log.VerboseEnabled = true; // The client and server must agree on the interface id to use: var iid = new Guid("{f4db45dc-0dcb-4003-b680-56c40f6cb6a8}"); bool attempt = true; while (attempt) { attempt = false; // Open the connection based on the endpoint information and interface IID using (var client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "1234")) //using (var client = new RpcClientApi(iid, RpcProtseq.ncacn_ip_tcp, null, @"18081")) { // Provide authentication information (not nessessary for LRPC) client.AuthenticateAs(RpcClientApi.Self); // Send the request and get a response try { var response = client.Execute(Encoding.UTF8.GetBytes(args.Length == 0 ? "Greetings" : args[0])); Console.WriteLine("Server response: {0}", Encoding.UTF8.GetString(response)); var task = client.ExecuteAsync(Encoding.UTF8.GetBytes(args.Length == 0 ? "Greetines" : args[0])). ContinueWith <String>(r => { return(Encoding.UTF8.GetString(r.Result.response)); }); task.Wait(); Console.WriteLine("Server response by async way: {0}", task.Result); } catch (RpcException rx) { if (rx.RpcError == RpcError.RPC_S_SERVER_UNAVAILABLE || rx.RpcError == RpcError.RPC_S_SERVER_TOO_BUSY) { //Use a wait handle if your on the same box... Console.Error.WriteLine("Waiting for server..."); System.Threading.Thread.Sleep(1000); attempt = true; } else { Console.Error.WriteLine(rx); } } catch (Exception ex) { Console.Error.WriteLine(ex); } } } // done... Console.WriteLine("Press [Enter] to exit..."); Console.ReadLine(); }
static void Main(string[] args) { RpcLibrary.Log.VerboseEnabled = true; // The client and server must agree on the interface id to use: var iid = new Guid("{0092F74D-0EA7-4667-A89F-A04C64244031}"); bool attempt = true; while (attempt) { attempt = false; // Open the connection based on the endpoint information and interface IID using (var client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "5678")) { //using (var client = new RpcClientApi(iid, RpcProtseq.ncacn_ip_tcp, null, @"18081")) client.AuthenticateAs(RpcClientApi.Self); // Send the request and get a response try { GetCustomers(client); AddCustomer(client, new RpcProto.Customer() { firstName = "Jack", lastName = "Dancer" }); RemoveCustomer(client, new RpcProto.Customer() { firstName = "Marry", lastName = "Player" }); } catch (RpcException rx) { if (rx.RpcError == RpcError.RPC_S_SERVER_UNAVAILABLE || rx.RpcError == RpcError.RPC_S_SERVER_TOO_BUSY) { //Use a wait handle if your on the same box... Console.Error.WriteLine("Waiting for server..."); System.Threading.Thread.Sleep(1000); attempt = true; } else { Console.Error.WriteLine(rx); } } catch (Exception ex) { Console.Error.WriteLine(ex); } } } // done... Console.WriteLine("Press [Enter] to exit..."); Console.ReadLine(); }
public JobRpcClientTest(IJobContext jobContext) : base(jobContext, JOB_TYPE.RPC_CLIENT) { client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, codeAPI); //client = new RpcClientApi(iid, RpcProtseq.ncacn_np, null, @"\pipe\" + codeAPI); //client = new RpcClientApi(iid, RpcProtseq.ncacn_ip_tcp, null, @"18081"); // Provide authentication information (not nessessary for LRPC) client.AuthenticateAs(RpcClientApi.Self); }
public Form1() { InitializeComponent(); var iid = new Guid("{04f5e707-d969-4822-95c5-2f3d4fd47f77}"); client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "3242"); client.AuthenticateAs(RpcClientApi.Self); subscribeEvent(); }
private void button1_Click(object sender, EventArgs e) { RpcLibrary.Log.VerboseEnabled = true; var iid = new Guid("{78323803-786f-4f7b-908d-b2e89c41d45f}"); var client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "11111"); client.AuthenticateAs(RpcClientApi.Self); byte[] response = client.Execute(new byte[] { 1 }); }
static void Test() { //An id to identify the endpoint interface Guid iid = Guid.Parse("430436ab-8786-4b19-905f-2e5cc11edda2"); //For the client, we specify the protocol, endpoint, and interface id to connect using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "4747")) { client.AuthenticateAs(RpcClientApi.Self); byte[] response = client.Execute(new byte[0]); } }
private static void Main(string[] args) { // The client and server must agree on the interface id to use: var iid = new Guid("{1B617C4B-BF68-4B8C-AE2B-A77E6A3ECEC5}"); bool attempt = true; while (attempt) { attempt = false; // Open the connection based on the endpoint information and interface IID using (var client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "RpcExampleClientServer")) //using (var client = new RpcClientApi(iid, RpcProtseq.ncacn_ip_tcp, null, @"18081")) { // Provide authentication information (not nessessary for LRPC) client.AuthenticateAs(RpcClientApi.Self); try { var response = client.Execute(Encoding.UTF8.GetBytes(args.Length == 0 ? "Greetings" : args[0])); Console.WriteLine("Server response: {0}", Encoding.UTF8.GetString(response)); } catch (RpcException rx) { if (rx.RpcError == RpcError.RPC_S_SERVER_UNAVAILABLE || rx.RpcError == RpcError.RPC_S_SERVER_TOO_BUSY) { // HINT: Use a wait handle if your on the same box... Console.Error.WriteLine("Waiting for server..."); System.Threading.Thread.Sleep(1000); attempt = true; } else { Console.Error.WriteLine(rx); } } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Yellow; Console.Error.WriteLine(ex); Console.ResetColor(); } } } Console.WriteLine("Client is done. Press [Enter] to exit."); Console.ReadLine(); }
public static AppMessage Send(AppMessage message) { try { Guid iid = new Guid(Constants.ACWatchDogInteropId); using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, Constants.ACWatchDogInteropEndpoint)) //using (var client = new RpcClientApi(iid, RpcProtseq.ncacn_ip_tcp, null, @"18081")) { // Provide authentication information (not nessessary for LRPC) client.AuthenticateAs(RpcClientApi.Self); // Send the request and get a response return(AppMessage.FromBytes(client.Execute(message.ToBytes()))); } } catch (Exception) { return(null); } }
public void TestClientOnAnonymousPipe() { Guid iid = Guid.NewGuid(); using (RpcServerApi server = new RpcServerApi(iid)) { server.AddProtocol(RpcProtseq.ncacn_np, @"\pipe\testpipename", 5); server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_NONE); server.StartListening(); server.OnExecute += delegate(IRpcClientInfo client, byte[] arg) { Assert.AreEqual(0, arg.Length); Assert.AreEqual(RpcAuthentication.RPC_C_AUTHN_NONE, client.AuthenticationLevel); Assert.AreEqual(RpcProtectionLevel.RPC_C_PROTECT_LEVEL_NONE, client.ProtectionLevel); Assert.AreEqual(RpcProtoseqType.NMP, client.ProtocolType); Assert.AreEqual(new byte[0], client.ClientAddress); Assert.AreEqual(0, client.ClientPid.ToInt32()); Assert.AreEqual(null, client.ClientPrincipalName); Assert.AreEqual(System.Security.Principal.WindowsIdentity.GetAnonymous().Name, client.ClientUser.Name); Assert.AreEqual(true, client.IsClientLocal); Assert.AreEqual(false, client.IsAuthenticated); Assert.AreEqual(false, client.IsImpersonating); bool failed = false; try { client.Impersonate().Dispose(); } catch (UnauthorizedAccessException) { failed = true; } Assert.AreEqual(true, failed); return(arg); }; using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncacn_np, null, @"\pipe\testpipename")) { client.AuthenticateAs(RpcClientApi.Anonymous); client.Execute(new byte[0]); } } }
static void ReversePingTest(RpcProtseq protocol, string[] hostNames, string endpoint, RpcAuthentication auth) { Guid iid = Guid.NewGuid(); using (RpcServerApi server = new RpcServerApi(iid)) { server.OnExecute += delegate(IRpcClientInfo client, byte[] arg) { Array.Reverse(arg); return(arg); }; server.AddProtocol(protocol, endpoint, 5); server.AddAuthentication(auth); server.StartListening(); byte[] input = Encoding.ASCII.GetBytes("abc"); byte[] expect = Encoding.ASCII.GetBytes("cba"); foreach (string hostName in hostNames) { using (RpcClientApi client = new RpcClientApi(iid, protocol, hostName, endpoint)) { client.AuthenticateAs(null, auth == RpcAuthentication.RPC_C_AUTHN_NONE ? RpcClientApi.Anonymous : RpcClientApi.Self, auth == RpcAuthentication.RPC_C_AUTHN_NONE ? RpcProtectionLevel.RPC_C_PROTECT_LEVEL_NONE : RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, auth); Assert.AreEqual(expect, client.Execute(input)); } } } }
public void TestClientOnNamedPipe() { Guid iid = Guid.NewGuid(); using (RpcServerApi server = new RpcServerApi(iid)) { server.AddProtocol(RpcProtseq.ncacn_np, @"\pipe\testpipename", 5); server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT); server.StartListening(); server.OnExecute += delegate(IRpcClientInfo client, byte[] arg) { Assert.AreEqual(0, arg.Length); Assert.AreEqual(RpcAuthentication.RPC_C_AUTHN_WINNT, client.AuthenticationLevel); Assert.AreEqual(RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, client.ProtectionLevel); Assert.AreEqual(RpcProtoseqType.NMP, client.ProtocolType); Assert.AreEqual(new byte[0], client.ClientAddress); Assert.AreEqual(0, client.ClientPid.ToInt32()); Assert.AreEqual(String.Empty, client.ClientPrincipalName); Assert.AreEqual(System.Security.Principal.WindowsIdentity.GetCurrent().Name, client.ClientUser.Name); Assert.AreEqual(true, client.IsClientLocal); Assert.AreEqual(true, client.IsAuthenticated); Assert.AreEqual(false, client.IsImpersonating); using (client.Impersonate()) Assert.AreEqual(true, client.IsImpersonating); Assert.AreEqual(false, client.IsImpersonating); return(arg); }; using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncacn_np, null, @"\pipe\testpipename")) { client.AuthenticateAs(RpcClientApi.Self); client.Execute(new byte[0]); } } }
public void demo1() { Thread.Sleep(3000); // The client and server must agree on the interface id to use: var iid = new Guid("{1B617C4B-BF68-4B8C-AE2B-A77E6A3ECEC5}"); bool attempt = true; while (attempt) { attempt = false; // Open the connection based on the endpoint information and interface IID //using (var client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "RpcExampleClientServer")) using (var client = new RpcClientApi(iid, RpcProtseq.ncacn_ip_tcp, null, @"18081")) { // Provide authentication information (not nessessary for LRPC) client.AuthenticateAs(RpcClientApi.Self); client.Execute(new byte[1] { 0xEC }); // Send the request and get a response try { for (int i = 0; i < 3; i++) { var response = client.Execute(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString())); Console.WriteLine("Server response: {0}", Encoding.UTF8.GetString(response)); } //client.Execute(new byte[0]); //byte[] bytes = new byte[1 * 1024 * 1024]; //1mb in/out //new Random().NextBytes(bytes); //Stopwatch stopWatch = new Stopwatch(); //stopWatch.Start(); //for (int i = 0; i < 2; i++) // client.Execute(bytes); //stopWatch.Stop(); //TimeSpan ts = stopWatch.Elapsed; //string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); //Console.WriteLine(elapsedTime + " ncalrpc-large-timming"); } catch (RpcException rx) { if (rx.RpcError == RpcError.RPC_S_SERVER_UNAVAILABLE || rx.RpcError == RpcError.RPC_S_SERVER_TOO_BUSY) { //Use a wait handle if your on the same box... Console.Error.WriteLine("Waiting for server..."); System.Threading.Thread.Sleep(1000); attempt = true; } else { Console.Error.WriteLine(rx); } } catch (Exception ex) { Console.Error.WriteLine(ex); } } } }
static void ReversePingTest(RpcProtseq protocol, string[] hostNames, string endpoint, RpcAuthentication auth) { Guid iid = Guid.NewGuid(); using (RpcServerApi server = new RpcServerApi(iid)) { server.OnExecute += delegate(IRpcClientInfo client, byte[] arg) { Array.Reverse(arg); return arg; }; server.AddProtocol(protocol, endpoint, 5); server.AddAuthentication(auth); server.StartListening(); byte[] input = Encoding.ASCII.GetBytes("abc"); byte[] expect = Encoding.ASCII.GetBytes("cba"); foreach (string hostName in hostNames) { using (RpcClientApi client = new RpcClientApi(iid, protocol, hostName, endpoint)) { client.AuthenticateAs(null, auth == RpcAuthentication.RPC_C_AUTHN_NONE ? RpcClientApi.Anonymous : RpcClientApi.Self, auth == RpcAuthentication.RPC_C_AUTHN_NONE ? RpcProtectionLevel.RPC_C_PROTECT_LEVEL_NONE : RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, auth); Assert.AreEqual(expect, client.Execute(input)); } } } }
public void TestNestedClientImpersonate() { Guid iid = Guid.NewGuid(); using (RpcServerApi server = new RpcServerApi(iid)) { server.AddProtocol(RpcProtseq.ncacn_np, @"\pipe\testpipename", 5); server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT); server.StartListening(); server.OnExecute += delegate(IRpcClientInfo client, byte[] arg) { Assert.AreEqual(false, client.IsImpersonating); using (client.Impersonate()) { Assert.AreEqual(true, client.IsImpersonating); using (client.Impersonate()) Assert.AreEqual(true, client.IsImpersonating); //does not dispose, we are still impersonating Assert.AreEqual(true, client.IsImpersonating); } Assert.AreEqual(false, client.IsImpersonating); return arg; }; using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncacn_np, null, @"\pipe\testpipename")) { client.AuthenticateAs(RpcClientApi.Self); client.Execute(new byte[0]); } } }
public void TestClientOnAnonymousPipe() { Guid iid = Guid.NewGuid(); using (RpcServerApi server = new RpcServerApi(iid)) { server.AddProtocol(RpcProtseq.ncacn_np, @"\pipe\testpipename", 5); server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_NONE); server.StartListening(); server.OnExecute += delegate(IRpcClientInfo client, byte[] arg) { Assert.AreEqual(0, arg.Length); Assert.AreEqual(RpcAuthentication.RPC_C_AUTHN_NONE, client.AuthenticationLevel); Assert.AreEqual(RpcProtectionLevel.RPC_C_PROTECT_LEVEL_NONE, client.ProtectionLevel); Assert.AreEqual(RpcProtoseqType.NMP, client.ProtocolType); Assert.AreEqual(new byte[0], client.ClientAddress); Assert.AreEqual(0, client.ClientPid.ToInt32()); Assert.AreEqual(null, client.ClientPrincipalName); Assert.AreEqual(System.Security.Principal.WindowsIdentity.GetAnonymous().Name, client.ClientUser.Name); Assert.AreEqual(true, client.IsClientLocal); Assert.AreEqual(false, client.IsAuthenticated); Assert.AreEqual(false, client.IsImpersonating); bool failed = false; try { client.Impersonate().Dispose(); } catch (UnauthorizedAccessException) { failed = true; } Assert.AreEqual(true, failed); return arg; }; using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncacn_np, null, @"\pipe\testpipename")) { client.AuthenticateAs(RpcClientApi.Anonymous); client.Execute(new byte[0]); } } }