我想在 .NET 中实现一个用于服务/客户端通信的命名管道,并遇到了这段代码 http://code.msdn.microsoft.com/windowsdesktop/CSNamedPipeCommunication-33b2485c/view/SourceCode在初始化管道的服务器端时,必须为管道设置安全描述符。他们是这样做的:
PipeSecurity pipeSecurity = new PipeSecurity();
// Allow Everyone read and write access to the pipe.
pipeSecurity.SetAccessRule(new PipeAccessRule("Authenticated Users",
PipeAccessRights.ReadWrite, AccessControlType.Allow));
// Allow the Administrators group full access to the pipe.
pipeSecurity.SetAccessRule(new PipeAccessRule("Administrators",
PipeAccessRights.FullControl, AccessControlType.Allow));
但我正在查看它,我担心将 SID 指定为字符串,或者Authenticated Users
and Administrators
部分。怎样才能保证它们会被称为中文或其他语言?
您可以使用 WellKnownSidType 枚举来获取 sid 并转换为 IdentityReference:
var sid = new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null);
var everyone = sid.Translate(typeof(NTAccount));
security.AddAccessRule(new PipeAccessRule(everyone, PipeAccessRights.ReadWrite, AccessControlType.Allow));
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)