NegotiateStream rejecting clients that aren't local admins

时间:2015-05-04 19:22:47

标签: c# windows-authentication tcpclient tcplistener

I have a very basic client/server test set up that fails with the message:

The server has rejected the client credentials.

Unless the client is logged on as an account that has admin rights on the server. This is something I do not want.

Here is my client code:

var formatter = new BinaryFormatter();

...

using (var client = new TcpClient(ip, 1248))
using (var stream = client.GetStream())
using (var negStream = new NegotiateStream(stream, false))
{
    await negStream.AuthenticateAsClientAsync(CredentialCache.DefaultNetworkCredentials, string.Empty, ProtectionLevel.EncryptAndSign, TokenImpersonationLevel.Identification));
    formatter.Serialize(negStream, "This is a test!");
}

And here is my server code:

var listener = new TcpListener.Create(1248);
listener.Start();

var tcpClient = listener.AcceptTcpClient();
using (var stream = tcpClient.GetStream())
using (var negStream = new NegotiateStream(stream, false))
{
    await negStream.AuthenticateAsServerAsync(CredentialCache.DefaultNetworkCredentials, ProtectionLevel.EncryptAndSign, TokenImpersonationLevel.Identification));
    Console.WriteLine(formatter.Deserialize(negStream));
}

How do I configure the server to accept any logged on user? Is there another setting I need to look at? Is there another way to authenticate a stream with domain credentials?

1 个答案:

答案 0 :(得分:1)

这听起来很疯狂,但是你可以尝试一下,无论如何它都适合我

打开文件夹 - >查看标签 - >选项 - >查看标签 - >向下滚动并取消选中“使用共享向导”