Сервер отклонил учетные данные Windows аутентификации Windows .NET - PullRequest
0 голосов
/ 07 ноября 2018

Я получил клиентское и серверное консольное приложение на двух разных машинах. Когда я пытаюсь подключиться, я получаю сообщение об ошибке «Сервер отклонил учетные данные клиента». Мой код на стороне сервера:

 NetTcpBinding bindingForUser = new NetTcpBinding();
        bindingForUser.Security.Mode = SecurityMode.Transport;
        bindingForUser.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;
        bindingForUser.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
        bindingForUser.Security.Message.ClientCredentialType = MessageCredentialType.Windows;

        string addressForUser = "net.tcp://localhost:10001/AuthenticationService";

        ServiceHost host = new ServiceHost(typeof(AuthenticationService));
        host.AddServiceEndpoint(typeof(IAuthenticationService), bindingForUser, addressForUser);
        host.Description.Behaviors.Remove(typeof(ServiceDebugBehavior));
        host.Description.Behaviors.Add(new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true });    host.open

А на клиенте у меня есть:

NetTcpBinding binding = new NetTcpBinding();
        binding.Security.Mode = SecurityMode.Transport;
        binding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;
        binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
        string address = "net.tcp://localhost:10001/AuthenticationService";
        string username, password;
        bool loggedIn = false;
        Console.WriteLine("************************* Welcome to user terminal *************************");

        using (AccountUserProxy proxy = new AccountUserProxy(binding, address))
        {
            while (!loggedIn)
            {
                Console.WriteLine("Please enter your username >> ");
                username = Console.ReadLine();
                Console.WriteLine("Please enter your password >> ");
                password = Console.ReadLine();
                loggedIn = proxy.Login(username,password);
            }

            Console.WriteLine("Press any key to log out >> ");
            Console.ReadLine();
            proxy.LogOut();
        }

IAuthenticationService factory;

    public AccountUserProxy(NetTcpBinding binding, string address) : base(binding, address)
    {
        factory = this.CreateChannel();
    }

Может кто-нибудь увидеть проблему?

...