private static void bindingSetAuthInfo(RPC_C_AUTHN_LEVEL level, RPC_C_AUTHN[] authTypes, RpcHandle handle, string serverPrincipalName, NetworkCredential credentails) { if (credentails == null) { foreach (RPC_C_AUTHN atype in authTypes) { RPC_STATUS result = NativeMethods.RpcBindingSetAuthInfo2(handle.Handle, serverPrincipalName, level, atype, IntPtr.Zero, 0); if (result != RPC_STATUS.RPC_S_OK) { RpcTrace.Warning("Unable to register {0}, result = {1}", atype, new RpcException(result).Message); } } } else { SEC_WINNT_AUTH_IDENTITY pSecInfo = new SEC_WINNT_AUTH_IDENTITY(credentails); foreach (RPC_C_AUTHN atype in authTypes) { RPC_STATUS result = NativeMethods.RpcBindingSetAuthInfo(handle.Handle, serverPrincipalName, level, atype, ref pSecInfo, 0); if (result != RPC_STATUS.RPC_S_OK) { RpcTrace.Warning("Unable to register {0}, result = {1}", atype, new RpcException(result).Message); } } } }
private static void bindingFromStringBinding(RpcHandle handle, String bindingString) { RPC_STATUS result = NativeMethods.RpcBindingFromStringBinding(bindingString, out handle.Handle); Guard.Assert(result); RpcTrace.Verbose("RpcClient.bindingFromStringBinding({0} = {1})", handle.Handle, bindingString); }
public Client(EndpointBindingInfo endpointBindingInfo) { _handle = new RpcClientHandle(); _protocol = endpointBindingInfo.Protseq; _binding = stringBindingCompose(endpointBindingInfo, null); RpcTrace.Verbose("Client('{0}:{1}')", endpointBindingInfo.NetworkAddr, endpointBindingInfo.EndPoint); bindingFromStringBinding(_handle, _binding); }
public static void Assert(RPC_STATUS errorsCode) { if (errorsCode != RPC_STATUS.RPC_S_OK) { RpcException ex = new RpcException(errorsCode); RpcTrace.Error("RPC_STATUS.{0} - {1}", errorsCode, ex.Message); throw ex; } }
private static bool serverRegisterAuthInfo(RPC_C_AUTHN auth, string serverPrincName) { RpcTrace.Verbose("serverRegisterAuthInfo({0})", auth); RPC_STATUS response = NativeMethods.RpcServerRegisterAuthInfo(serverPrincName, (uint)auth, IntPtr.Zero, IntPtr.Zero); if (response != RPC_STATUS.RPC_S_OK) { RpcTrace.Warning("serverRegisterAuthInfo - unable to register authentication type {0}", auth); return(false); } return(true); }
private static void serverListen(int maxCalls) { RpcTrace.Verbose("Begin Server Listening"); // starts listening all server in process on registered protocols //TODO: make server isolated of other process services, make it not static as possible RPC_STATUS result = NativeMethods.RpcServerListen(1, maxCalls, 1); if (result == RPC_STATUS.RPC_S_ALREADY_LISTENING) { result = RPC_STATUS.RPC_S_OK; } Guard.Assert(result); RpcTrace.Verbose("Server Ready"); }
private static bool serverUseProtseqEp(RpcProtseq protocol, int maxCalls, String endpoint) { RpcTrace.Verbose("serverUseProtseqEp({0})", protocol); // all RPC servers within the process will be available on that protocol // once invoked this can not be undone //TODO: make server isolated of other process services, make it not static as possible RPC_STATUS err = NativeMethods.RpcServerUseProtseqEp(protocol.ToString(), maxCalls, endpoint, IntPtr.Zero); if (err != RPC_STATUS.RPC_S_DUPLICATE_ENDPOINT) { Guard.Assert(err); } return(err == RPC_STATUS.RPC_S_OK); }
private static void serverStopListening() { RpcTrace.Verbose("Stop Server Listening"); // stops listening on all registered protocols. //TODO: make server isolated of other process services, make it not static as possible RPC_STATUS result = NativeMethods.RpcMgmtStopServerListening(IntPtr.Zero); if (result != RPC_STATUS.RPC_S_OK) { RpcTrace.Warning("RpcMgmtStopServerListening result = {0}", result); } //TODO: make server isolated of other process services, make it not static as possible result = NativeMethods.RpcMgmtWaitServerListen(); if (result != RPC_STATUS.RPC_S_OK) { RpcTrace.Warning("RpcMgmtWaitServerListen result = {0}", result); } }
/// <summary> /// Disconnects the client and frees any resources. /// </summary> public void Dispose() { RpcTrace.Verbose("RpcClient('{0}').Dispose()", _binding); _handle.Dispose(); }