我正在寻找在 .NET 中为服务/客户端通信实现命名管道并遇到了 this code也就是说,在初始化管道的服务器端时,必须为管道设置一个安全描述符。他们是这样做的:
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
和 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));
关于c# - .NET 中安全身份的本地化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15890860/