성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] Java - How to use the Foreign Funct...
[정성태] 제가 큰 실수를 했군요. ^^; Delegate를 통한 Bein...
[정성태] Working with Rust Libraries from C#...
[정성태] Detecting blocking calls using asyn...
[정성태] 아쉽게도, 커뮤니티는 아니고 개인 블로그입니다. ^^
[정성태] 질문이 잘 이해가 안 됩니다. 우선, 해당 소스코드에서 ILis...
[양승조
] var대신 dinamic으로 선언해서 해결은 했습니다. 맞는 해...
[양승조
] 또 막혔습니다. ㅠㅠ var list = props[i].Ge...
[양승조
] 아. 감사합니다. 어제는 안됐던것 같은데....정신을 차려야겠네...
[정성태] "props[i].GetValue(props[i])" 코드에서 ...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <h1 style='font-family: Malgun Gothic, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>SeCreateGlobalPrivilege 특권과 WCF NamedPipe</h1> <p> 아래와 같은 질문이 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > WCF namedpipe 퍼블리싱 충돌 문제 ; <a target='tab' href='http://www.sysnet.pe.kr/3/0/1350'>http://www.sysnet.pe.kr/3/0/1350</a> </pre> <br /> 문제를 정리해 보면 대충 이렇습니다.<br /> <br /> <div style='BACKGROUND-COLOR: #ccffcc; padding: 10px 10px 5px 10px; MARGIN: 0px 10px 10px 10px; FONT-FAMILY: Malgun Gothic, Consolas, Verdana; COLOR: #005555'> "A 프로그램"이 "net.pipe://localhost/servicename/{47280BB5-44EE-49F0-B440-F83878349985}\0" 주소로 WCF NamedPipe를 열었고 "B 프로그램"에서 해당 주소로 WCF NamedPipe 연결을 할 수 있습니다.<br /> <br /> 하지만, "(NT 서비스로 등록된) C 프로그램"이 "net.pipe://localhost/0" 주소로 WCF NamedPipe를 열었는데, 이후로 "B 프로그램"에서 "A 프로그램"으로의 NamedPipe 접속이 안됨.<br /> </div><br /> <br /> 그러면서, 재현할 수 있는 최소한의 예제 코드를 올려주었기 때문에 금방 문제를 확인할 수 있었습니다. 실제로 "C 프로그램"이 뜬 상태에서 "B 프로그램"의 접속 시도 시 발생하는 예외는 다음과 같습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > C:\temp\wcf test client\bin\Debug>"wcf test client.exe" Unhandled Exception: System.ServiceModel.EndpointNotFoundException: <span style='color: blue; font-weight: bold'>There was no endpoint listening at net.pipe://</span>localhost/anothersevice/{47280BB5-44EE-49F0-B440-F83878349985}/identifier that could accept the message. This is often causedby an incorrect address or SOAP action. See InnerException, if present, for more details. Server stack trace: at System.ServiceModel.Channels.ConnectionUpgradeHelper.DecodeFramingFault(ClientFramingDecoder decoder, IConnection connection, Uri via, String contentType, TimeoutHelper& timeoutHelper) at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper) at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper) at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout) at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade) at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at AnotherService.IAnotherService.Hello() at wcf_test_client.Program.Main(String[] args) in e:\...\wcf test client\Program.cs:line 25 </pre> <br /> 게다가... 질문하신 분이 stackoverflow.com의 Q&A 하나를 소개까지 했는데요. ^^<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > 3rd party app breaks our WCF application ; <a target='tab' href='http://stackoverflow.com/questions/15981392/3rd-party-app-breaks-our-wcf-application/15987095#15987095'>http://stackoverflow.com/questions/15981392/3rd-party-app-breaks-our-wcf-application/15987095#15987095</a> </pre> <br /> 그렇습니다. 질문은 이렇게 해주셔야 ^^ 저도 답변하는 데 흥이 납니다.<br /> <br /> <hr style='width: 50%' /><br /> <a name='privileges'></a> <br /> 일단, 현상을 보니까 "A 프로그램"을 "관리자 권한"으로 실행하면 "C 프로그램"과 상관없이 "B 프로그램"에서 연결이 잘 됩니다. 결국 해답은 "<a target='tab' href='http://stackoverflow.com/questions/15981392/3rd-party-app-breaks-our-wcf-application/15987095#15987095'>3rd party app breaks our WCF application</a>" 글에 포함되어 있습니다.<br /> <br /> Administrators 그룹의 계정과 서비스 계정은 기본적으로 "SeCreateGlobalPrivilege" 특권이 허용되어 있기 때문에, 관리자 권한으로 승격한 경우와 NT 서비스들의 경우에는 해당 EXE 프로세스에 다음과 같이 "SeCreateGlobalPrivilege" 특권이 추가되어 있습니다. <br /> <br /> <img alt='wcf_namedpipe_namespace_0.png' src='/SysWebRes/bbs/wcf_namedpipe_namespace_0.png' /> <br /><br /> 이 특권이 있는 상태에서 NamedPipe를 만들면 "전역 네임스페이스"에 커널 객체의 이름이 등록됩니다. <br /> <br /> 그래서, 다시 문제를 정리해 보면,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > "A 프로그램"은 "Local 네임스페이스"에 WCF NmaedPipe 주소를 등록하고 서비스 시작 "B 프로그램"은 "전역 네임스페이스"에 등록된 WCF NamedPipe 주소를 먼저 검색하고, 없으면, "Local 네임스페이스"에 등록된 WCF NamedPipe 주소를 검색하고, 있으면 연결. </pre> <br /> 이렇게 동작하고 있는데, "C 프로그램"에서 "전역 네임스페이스"로 "A 프로그램"이 열었던 pipe 주소를 포함하는 형식의 주소가 사용되면, 이제 "B 프로그램"의 서비스 검색이 "전역 네임스페이스" 단계에서 조건을 만족하는 이름 규칙이 있으므로 거기로 연결을 시도한 것입니다. 하지만, "A 프로그램"을 "관리자 권한"으로 실행하면 "A 프로그램"의 NamedPipe 이름이 "전역 네임스페이스"에 등록되므로 정상적으로 "B 프로그램"이 서비스로 연결을 합니다.<br /> <br /> (일단, 위의 동작은 마이크로소프트 문서에서 찾은 것은 아니고... 그냥 실행을 통해 찾아낸 현상이 그런 것입니다.)<br /> <br /> <hr style='width: 50%' /><br /> <a name='access_token'></a> <br /> 그렇다면, 의문이 하나 있습니다. 현재 로그인 계정이 "Administrators"에 속해 있는데, 왜? '관리자 권한'으로 승격시켜야만 하느냐입니다. 이에 대해서는 아래의 글에서 예전에 설명한 것이 도움이 되는데요.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > UAC 이모저모 ; <a target='tab' href='http://www.sysnet.pe.kr/2/0/449'>http://www.sysnet.pe.kr/2/0/449</a> </pre> <br /> <div style='BACKGROUND-COLOR: #ccffcc; padding: 10px 10px 5px 10px; MARGIN: 0px 10px 10px 10px; FONT-FAMILY: Malgun Gothic, Consolas, Verdana; COLOR: #005555'> "<br /> UAC는 "filtered standard user access token", "full access token"의 2가지 access token을 관리.<br /> <br /> 윈도우즈 특권의 경우, 제한 목록에 있는 RID 값을 소유한 계정이 로그인한 경우 생성되는 "filtered standard user access token" 은 다음의 특권을 제외한 모든 특권들이 제거된다.<br /> <br /> <ul> <li>SeChangeNotifyPrivilege</li> <li>SeShutdownPrivilege</li> <li>SeUndockPrivilege</li> <li>SeReserveProcessorPrivilege</li> <li>SeTimeZonePrivilege</li> </ul> "<br /> </div><br /> <br /> 따라서, 로그인한 계정은 "Administrators"에 속해있어도 UAC 환경에서는 '관리자 권한'으로 승격되지 않은 상태에서는 "filtered standard user access token"을 가지고 있으므로 이 중에는 "SeCreateGlobalPrivilege" 권한을 소유할 수 없기 때문에 그런 현상이 발생하는 것입니다.<br /> <br /> <hr style='width: 50%' /><br /> <br /> 이쯤에서, 문제에 대한 해결책은 이렇게 정리됩니다.<br /> <br /> <ul> <li>WCF NamedPipe 사용 코드는, "관리자 그룹"에 속한 사용자를 관리자 권한으로 실행시키거나,</li> <li>또는, "NT 서비스"에서 NamedPipe를 열어서 사용</li> </ul> <br /> 위의 2가지 방법 이외에는, 네임스페이스 검색 우선 순위에 따라 WCF의 연결 문제를 해결할 수 없습니다.<br /> <br /> <hr style='width: 50%' /><br /> <br /> 참고로, 경우에 따라 "Administrators"에 속하지 않은 사용자가 로그인할 수도 있는데요. 이런 경우에는 해당 사용자 계정 내에서는 아무리 용을 써도 "SeCreateGlobalPrivilege" 특권을 가질 수 없습니다. 이 특권을 가지려면, 사용자가 분명하게 허용해야 합니다. 이를 위해 "gpedit.msc"에서 "Computer Configuration(컴퓨터 구성)" / "Windows Settings(설정)" / "Security Settings(보안 설정)" / "Local Policies(로컬 정책)" / "User Rights Assignment(사용자 권한 할당)"에서 "Create global objects(전역 개체 만들기)" 정책에 다음과 같이 사용자 계정을 포함시킵니다.<br /> <br /> <img onclick='toggle_img(this)' class='imgView' alt='wcf_namedpipe_namespace_1.png' src='/SysWebRes/bbs/wcf_namedpipe_namespace_1.png' /><br /> <br /> 이렇게 해줘야만, "Administrators" 그룹에 속하지 않은 사용자 계정에서 WCF NamedPipe 등록을 전역 개체로 할 수 있습니다.<br /> <br /> <hr style='width: 50%' /><br /> <br /> 혹시나 싶어서, <br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Process Privileges ; <a target='tab' href='http://processprivileges.codeplex.com/'>http://processprivileges.codeplex.com/</a> </pre> <br /> 위의 코드를 사용해서 "filtered standard user access token" 상태의 EXE 프로세스에서 SeCreateGlobalPrivilege 특권을 활성화하려고 했지만, <br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Process process = Process.GetCurrentProcess(); using (ProcessPrivileges.PrivilegeEnabler enabler = <span style='color: blue; font-weight: bold'>new ProcessPrivileges.PrivilegeEnabler( Process.GetCurrentProcess(), ProcessPrivileges.Privilege.CreateGlobal))</span> { Console.WriteLine("{0} => {1}", ProcessPrivileges.Privilege.CreateGlobal, process.GetPrivilegeState(ProcessPrivileges.Privilege.CreateGlobal)); // 출력 결과: CreateGlobal => Removed } </pre> <br /> 아쉽게도 "filtered standard user access token" 상태에서는 SeCreateGlobalPrivilege 특권이 절대 포함되지 않았습니다.<br /> <br /> 또 다른 테스트로, 이번엔 "administrators" 그룹 계정의 '관리자 권한' 승격 상태에서 정상적으로 실행하는 "A 프로그램"을, 다음과 같이 명시적으로 특권을 제거하고 WCF NamedPipe를 사용해 봤는데... <br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Process process = Process.GetCurrentProcess(); process.<span style='color: blue; font-weight: bold'>DisablePrivilege(Privilege.CreateGlobal);</span> Console.WriteLine("{0} => {1}", ProcessPrivileges.Privilege.CreateGlobal, process.GetPrivilegeState(ProcessPrivileges.Privilege.CreateGlobal)); // 출력 결과: CreateGlobal => Disabled </pre> <br /> 역시나 "B 프로그램"에서 접속 문제가 발생했습니다. 관리자 권한 승격 상태에서도 "SeCreateGlobalPrivilege" 특권이 없으면 전역 네임스페이스에 등록하지 못하므로 마찬가지의 문제가 발생하는 것입니다.<br /> <br /> 결론적으로, SeCreateGlobalPrivilege 특권의 유무에 따라 문제가 발생하는 것이 맞겠습니다.<br /> </p><br /> <br /> <br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
1664
(왼쪽의 숫자를 입력해야 합니다.)