Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
保护WCF使用的命名管道_Wcf_Security_Named Pipes_Acl_Netnamedpipebinding - Fatal编程技术网

保护WCF使用的命名管道

保护WCF使用的命名管道,wcf,security,named-pipes,acl,netnamedpipebinding,Wcf,Security,Named Pipes,Acl,Netnamedpipebinding,我是WCF和命名管道的新手 我需要一种在同一台计算机上的UI应用程序和Windows服务之间安全通信的方法。我需要的是: -客户端UI应用程序需要向Windows服务发送(推送)各种消息类型。 -客户端UI应用程序需求将接收来自服务的各种消息类型(推式或拉式) (这里的消息只是一个结构化的序列化数据) 现在,所有这些交换应该只在授权用户帐户(可能不同于服务帐户)下进行。因此,我考虑为服务和用户帐户访问一个命名管道 但是,命名管道仅支持流。我有多种类型的消息需要通过命名管道进行交换,这意味着我需要

我是WCF和命名管道的新手

我需要一种在同一台计算机上的UI应用程序和Windows服务之间安全通信的方法。我需要的是: -客户端UI应用程序需要向Windows服务发送(推送)各种消息类型。 -客户端UI应用程序需求将接收来自服务的各种消息类型(推式或拉式)

(这里的消息只是一个结构化的序列化数据)

现在,所有这些交换应该只在授权用户帐户(可能不同于服务帐户)下进行。因此,我考虑为服务和用户帐户访问一个命名管道

但是,命名管道仅支持流。我有多种类型的消息需要通过命名管道进行交换,这意味着我需要定义它们并对它们进行序列化/反序列化

为了避免这种情况,我考虑在命名管道上使用WCF(用于序列化和RPC支持)。还可以在Windows服务中承载WCF服务

问题1) 这是一个好方法吗?我犹豫是否在WCF下使用http或tcp,因为通信必须留在机器内

问题2) 如果以及如何ACL WCF将使用的命名管道?这是我能控制的吗? 我觉得使用特定的SID访问名称管道比在客户端和服务器之间实现身份验证方案提供了更好的安全性

谢谢你的指点和建议!
Sameer

发现了这些非常有用的帖子: 我认为这是一个好办法。你的想法很正确

2) 正如您已经发现的,它是由WCF NetNamedPipe绑定创建的。它涉及到使用反射来填补Microsoft实现中的空白,该实现最初显然是为了支持设置ACL的直接机制,但没有正确完成

从中派生一个
AclSecuredNamedPipeBinding
,并从中派生一个相应的
AclSecuredNamedPipeTransportBindingElement
。binding元素具有以下内容的列表:


如果你这样做的话,一定要按照中的说明修补“蹲式漏洞”。

我尝试了上面“Chris Disson的博客”中的建议,但在以管理员权限运行服务代码后,出现了以下异常。 “StudentService存在问题,无法翻译某些或所有身份引用。” 这是我的代码,它承载着服务

AclSecuredNamedPipeBinding binding = new AclSecuredNamedPipeBinding();
SecurityIdentifier allowedGroup = (SecurityIdentifier)(new 
NTAccount("NPServiceUsers").Translate(typeof(SecurityIdentifier)));
binding.AddUserOrGroup(allowedGroup);
studentServiceHost = new ServiceHost(typeof(StudentService.StudentService));
Uri httpBaseAddress = new 
Uri("net.pipe://localhost/ServiceHost/ServiceHost");

studentServiceHost.AddServiceEndpoint(
typeof(StudentService.IStudentService),binding, httpBaseAddress); 
studentServiceHost.Open();
然后,我尝试将nTAccount从“NPServiceUsers”更改为“Administrators”,然后出现以下异常

“StudentService对象引用未设置为对象实例存在问题。”

studentService是实现IStudentService接口的类

public class StudentService : IStudentService
{
public void DoWork()
{
}
}

不幸的是,这个博客不再可用。有人记得是谁干的吗?我尝试使用反射来设置允许的用户,但这并没有达到我所希望的效果。任何帮助都很好。通过添加链接指向的内容和更新链接来改进。
AclSecuredNamedPipeBinding binding = new AclSecuredNamedPipeBinding();
SecurityIdentifier allowedGroup = (SecurityIdentifier)(new 
NTAccount("NPServiceUsers").Translate(typeof(SecurityIdentifier)));
binding.AddUserOrGroup(allowedGroup);
studentServiceHost = new ServiceHost(typeof(StudentService.StudentService));
Uri httpBaseAddress = new 
Uri("net.pipe://localhost/ServiceHost/ServiceHost");

studentServiceHost.AddServiceEndpoint(
typeof(StudentService.IStudentService),binding, httpBaseAddress); 
studentServiceHost.Open();
public class StudentService : IStudentService
{
public void DoWork()
{
}
}