2013-04-08 2 views
9

.NET에서 서비스/클라이언트 통신을 위해 명명 된 파이프를 구현하려고했는데 this code에 도달했습니다. 파이프의 서버 쪽을 초기화하는 동안 파이프에 대한 보안 설명자를 설정해야했습니다. 그들은 이런 식으로했다 : 나는 그것을 찾고 있어요.NET에서 보안 ID에 대한 지역화

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)); 

그러나, 그리고 내가 문자열 또는 Authenticated UsersAdministrators 부품으로 SID를 지정하는 방법에 대한 걱정. 중국어 또는 다른 언어로 부름을받을 수 있다는 보장은 무엇입니까? (OP의 원래의 질문에서 추출)

+0

확인을. 나는 그것을 스스로 확인했다. 작동하는 것 같습니다. – ahmd0

+5

이것을 적절한 질문/답변 쌍으로 분리하는 것을 고려해야합니다. – slugster

+0

네, 당신은 당신 자신의 질문에 대답 할 수 있습니다. – DWright

답변

0

나는이 대안 내놓았다 :

PipeSecurity pipeSecurity = new PipeSecurity(); 

// Allow Everyone read and write access to the pipe. 
pipeSecurity.SetAccessRule(new PipeAccessRule(
    "Authenticated Users", 
    new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null), 
    PipeAccessRights.ReadWrite, AccessControlType.Allow)); 

// Allow the Administrators group full access to the pipe. 
pipeSecurity.SetAccessRule(new PipeAccessRule(
    "Administrators", 
    new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null), 
    PipeAccessRights.FullControl, AccessControlType.Allow)); 
+0

그건 나를 위해, 그 문자열과'SecurityIdentifier' [여기를 참조하십시오 걸리는 과부하가 작동하지 않습니다 (https://msdn.microsoft.com/en-us/library/system.io.pipes 참조). pipeaccessrule.pipeaccessrule (v = vs.110) .aspx). 문자열 리터럴''인증 된 사용자 ''와''관리자''를 제거하십시오. – doug65536

2

당신은 SID를 얻을 수 WellKnownSidType 열거를 사용 할 IdentityReference로 번역 할 수 있습니다 :

 var sid = new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null); 
     var everyone = sid.Translate(typeof(NTAccount)); 
     security.AddAccessRule(new PipeAccessRule(everyone, PipeAccessRights.ReadWrite, AccessControlType.Allow)); 
+1

"모두"는 좋은 생각이 아닙니다. 아마도 적어도 WellKnownSidType.AuthenticatedUserSid를 원할 것입니다. 편집증 이외의 'WorldSid' (Everyone)를 사용하는 특별한 이유가 있습니까? – doug65536

+0

바로! 변경됨. –

+1

알 수없는 보안 문제가 발생하면 누구나 생각해 볼 수 있습니다. 사용하면 코드가 제대로 작동하는지 확인하기 위해 온 전성 테스트를 통과하여 실제로 필요한 보안 수준을 좁힐 수 있습니다. – TheLegendaryCopyCoder