Возникли проблемы с аутентификацией в случае WCF wshttpbinding
Я пытаюсь общаться с WCF, создавая класс serviceclient.
удивительно, но я могу общаться с WCF, даже если я передаю неправильный домен. это произойдет только в том случае, если я передам только пользователя администратора домена. с обычным IISUser он выдает правильное исключение проверки в случае неправильного домена.
Мой тест env. in другой домен, где размещен wcf, и я могу общаться с ним, передавая неправильный домен с удаленной машины (существует в домене diff).
В приведенном ниже коде я передаю неправильное доменное имя в переменную" DomainName "и пользователя администратора домена в" UserName", и это работает нормально. Как я могу убедиться, что пользователь прошел правильный домен ?
Что я уже пробовал:
<pre> WSHttpBinding httpBinding = new WSHttpBinding(); httpBinding.Name = "WSHttpBinding_IService"; httpBinding.CloseTimeout = TimeSpan.MaxValue; httpBinding.OpenTimeout = TimeSpan.MaxValue; httpBinding.ReceiveTimeout = TimeSpan.MaxValue; httpBinding.SendTimeout = TimeSpan.MaxValue; httpBinding.BypassProxyOnLocal = false; httpBinding.TransactionFlow = false; httpBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; httpBinding.MaxBufferPoolSize = Convert.ToInt64("2147483646"); httpBinding.MaxReceivedMessageSize = Convert.ToInt64("2147483646"); httpBinding.MessageEncoding = WSMessageEncoding.Mtom; httpBinding.TextEncoding = Encoding.UTF8; httpBinding.UseDefaultWebProxy = true; httpBinding.AllowCookies = false; httpBinding.ReliableSession.Ordered = true; httpBinding.ReliableSession.InactivityTimeout = TimeSpan.MaxValue; httpBinding.ReliableSession.Enabled = false; if (ServerURL.ToLower().Contains("https://")) httpBinding.Security.Mode = SecurityMode.Transport; else httpBinding.Security.Mode = SecurityMode.Message; httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows; httpBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None; httpBinding.Security.Transport.Realm = ""; httpBinding.Security.Message.ClientCredentialType = MessageCredentialType.Windows; httpBinding.Security.Message.NegotiateServiceCredential = true; httpBinding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default; EndpointAddress endpoint = new EndpointAddress(new Uri(ServerURL + "/Service/MyService.svc"), EndpointIdentity.CreateDnsIdentity("localhost")); ServiceClient _serviceClient = new ServiceClient (httpBinding, endpoint); _serviceClient.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; _serviceClient.ClientCredentials.Windows.ClientCredential.Domain = DomainName; _serviceClient.ClientCredentials.Windows.ClientCredential.UserName = UserName; _serviceClient.ClientCredentials.Windows.ClientCredential.Password = Password; _serviceClient.Open(); string CnfgRbInstalled = _serviceClient.GetAccessToken(); _serviceClient.Close();