Example #1
0
 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);
             }
         }
     }
 }
Example #2
0
        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);
        }
Example #3
0
        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);
            }
        }