10

.NET でサービス/クライアント通信用の名前付きパイプを実装しようとしていたところ、パイプのサーバー側を初期化するときに、パイプのセキュリティ記述子を設定する必要があるこのコードに出会いました。彼らはこのようにしました:

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。たとえば、中国語や他の言語で呼ばれるという保証は何ですか?

4

2 に答える 2

3

WellKnownSidType enum を使用して sid を取得し、IdentityReference に変換できます。

        var sid = new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null);
        var everyone = sid.Translate(typeof(NTAccount));
        security.AddAccessRule(new PipeAccessRule(everyone, PipeAccessRights.ReadWrite, AccessControlType.Allow));
于 2016-06-29T13:45:17.127 に答える