TcpServerChannel 类服务

服务端:

            var provider = new BinaryServerFormatterSinkProvider();
            provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

            IDictionary props = new Hashtable();
            props["name"] = "ServerPacs";
            props["port"] = port.toInt();
            props["typeFilterLevel"] = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

            props["secure"] = true; 打开认证;
            props["impersonate"] = true;
            props["protectionLevel"] = System.Net.Security.ProtectionLevel.Sign;

           var tcpserver = new TcpServerChannel(props, provider, Auth);

            ChannelServices.RegisterChannel(tcpserver, true);/打开认证;

       

客户端:

                var bcprovider = new BinaryClientFormatterSinkProvider();
                IDictionary props = new Hashtable();

                props["name"] = "ServerPacs";
                props["secure"] = true;
                props["impersonate"] = true;
                props["protectionLevel"] = System.Net.Security.ProtectionLevel.Sign;
                props["tokenImpersonationLevel"] = System.Security.Principal.TokenImpersonationLevel.Impersonation;
                //props["authorizationModule"] = "PacsClassServer.AuthorizationModule,hello";
                //props["useDefaultCredentials"] = "false";
                //props["domain"] = "172_21_0_15";
                props["username"] = "admin";
                props["password"] = "xxxx;   
                var client = new TcpClientChannel(props, bcprovider);
                ChannelServices.RegisterChannel(client, true);

在服务器操作系统上建立一个新账号,在客户端配置,即可完整认证。

你可能感兴趣的:(服务器,运维)