gpt4 book ai didi

.net - 使用 Windows 身份验证从 Mono 调用 WCF 服务

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:40:07 26 4
gpt4 key购买 nike

我在带有 IIS 的 Windows 服务器上托管了一个 WCF 服务,并设置为 Windows 身份验证(公司内部的用户必须使用域身份验证才能登录他们的桌面)。我想从带有 Mono 的 linux (ubuntu) 调用此 WCF 服务。我们使用 netTcp 协议(protocol),但它可以改变。我将服务创建为:

var s = new WebTestService.TestServiceClient();
s.ClientCredentials.UserName.UserName = "mydomain\\myuser";
s.ClientCredentials.UserName.Password = "myPassword";

但是还是不能通信。

有谁知道在哪里修复这个错误?有可能解决吗?提前致谢。

Unhandled Exception: System.IO.IOException: Unable to read data from the transport connection: Connection reset by peer. ---> System.Net.Sockets.SocketException: Connection reset by peer at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags) [0x00052] in :0 at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x000b4] in :0
--- End of inner exception stack trace --- at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_remoting_wrapper (intptr,intptr)
at (wrapper remoting-invoke) MonoTest.WebTestService.ITestService:GetIdentity () at MonoTest.WebTestService.TestServiceClient.GetIdentity () [0x00007] in <27f805f676fd42ad978ebb382e24c2d7>:0 at MonoTest.Program.Main (System.String[] args) [0x00050] in <27f805f676fd42ad978ebb382e24c2d7>:0 [ERROR] FATAL UNHANDLED EXCEPTION: System.IO.IOException: Unable to read data from the transport connection: Connection reset by peer. ---> System.Net.Sockets.SocketException: Connection reset by peer at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags) [0x00052] in :0 at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x000b4] in :0 --- End of inner exception stack trace --- at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_remoting_wrapper (intptr,intptr)
at (wrapper remoting-invoke) MonoTest.WebTestService.ITestService:GetIdentity () at MonoTest.WebTestService.TestServiceClient.GetIdentity () [0x00007] in <27f805f676fd42ad978ebb382e24c2d7>:0 at MonoTest.Program.Main (System.String[] args) [0x00050] in <27f805f676fd42ad978ebb382e24c2d7>:0

最佳答案

我在我的一个 wcf web 服务中使用用户名和密码进行 Windows 身份验证,我像这样分配用户名和密码:

s.ClientCredentials.Windows.ClientCredential.UserName = "mydomain\\myuser";
//in my case I don't use a domain though.
s.ClientCredentials.Windows.ClientCredential.Password = "myPassword";
//I acutally use .SecurePassword and assign it SecureString

关于.net - 使用 Windows 身份验证从 Mono 调用 WCF 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43757949/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com