문제

WCF 서비스를 작성하고있어 가장 필요합니다.

로컬 컴퓨터에서 전화를 시도했지만 원격 시스템에서 항상 오류로 실패했습니다.

보안 지원 공급자 인터페이스 (SSPI) 인증에 실패했습니다.서버가 ID '호스트 / 호스트 이름'으로 계정에서 실행되지 않을 수 있습니다.서버가 서비스 계정 (예 : 네트워크 서비스)에서 실행 중이면 계정의 ServicePrinciPalName을 서버의 EndpointAddress의 ID로 지정하십시오.서버가 사용자 계정에서 실행 중이면 계정의 userprincipalname을 서버의 EndpointAddress의 ID로 지정하십시오.

UPN을 제공하면 ID가 실패한 예외가 발생했습니다.

여기에 내 구성이 있습니다.

서버 구성 (앱) :

<system.serviceModel>    
    <behaviors>
      <serviceBehaviors>
        <behavior name="default">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceAuthorization impersonateCallerForAllOperations="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <netTcpBinding>
        <binding name="DataService.netTcpBinding">
          <readerQuotas maxArrayLength="65535" maxBytesPerRead="2147483647" maxStringContentLength="2147483647"/>
          <reliableSession enabled="true" inactivityTimeout="24:00:00" ordered="true"/>          
          <security mode="TransportWithMessageCredential">
            <message clientCredentialType="Windows" />
            <transport clientCredentialType="Windows"/>          
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
    <services>
      <service behaviorConfiguration="default" name="DataService.DataService">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration="DataService.netTcpBinding" 
          name="DataService.DataService" contract="DataService.IDataService"/>
        <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://address:4504/"/>
            <add baseAddress="net.tcp://address:4503/"/>
          </baseAddresses>
        </host>
      </service>
    </services>
</system.serviceModel>
.

클라이언트 구성 :

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>     
        <bindings>
            <netTcpBinding>
                <binding name="DataService.DataService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                    maxReceivedMessageSize="65536">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="24.00:00:00"
                        enabled="true" />
                    <security mode="TransportWithMessageCredential">
                        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                        <message clientCredentialType="Windows" algorithmSuite="Default" />
                    </security>
                </binding>
            </netTcpBinding>
        </bindings>
        <client>
            <endpoint address="net.tcp://address:4503/" binding="netTcpBinding"
                bindingConfiguration="DataService.DataService"
                contract="ataService.IDataService" name="DataService.DataService">
              <identity>
                <dns value="DOMAIN"/>                                                  
              </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>
.

도움이 크게 감사 할 것입니다.

도움이 되었습니까?

해결책

Windows 서비스는 사용자 주체 이름 또는 서비스 주체 ( " 문서 ). 그 링크에서 인용하기 : " localsystem, localservice 또는 networkservice 계정에서 서비스가 실행 중이면 서비스 주체 이름 (SPN)은 호스트의 형태로 서비스 주체 이름 (SPN)이 호스트의 형태로 생성되므로 해당 계정이 컴퓨터에 액세스 할 수 있기 때문에 서비스 주체 이름 (SPN)이 기본적으로 생성됩니다. SPN 데이터. WCF (Windows Communication Foundation)는 @. "인 Windows Communication Foundation (WCF)이 UPN을 생성합니다. 실제로이 인용문은 오류 메시지가 표시되는 것과 오히려 유사합니다. 그래서 그것은 그 것처럼 보입니다 ...

a) 서비스가 로컬 서비스 계정 또는 이와 유사한 표준 계정에서 실행 중이면 클라이언트 구성 파일을 조정하여 실제 서버의 이름이 "주소"인 경우이 파일을 조정해야합니다. 엔드 포인트는 포트 4503에서 실행 중입니다.

<identity>
     <servicePrincipalName value="host/address:4503" />
</identity>
.

b)를 번갈아, 전용 서비스 계정으로 실행중인 경우 (도메인 "mydomain"에서 "ServiceAccount" "ServiceAccount"를 호출하십시오),

<identity>
     <userPrincipalName value="ServiceAccount@MyDomain" />
</identity>
.

포리스트 및 트리 레벨을 포함하여 두 경우 모두 완전한 도메인 이름을 사용해야 할 수도 있습니다. 개인 LAN / WAN의 내부의 간단한 도메인의 경우 address.mydomain.local 및 serviceaccount@mydomain.local을 의미합니다. 도메인이 MyTree라는 트리에있는 경우 serviceacount@mydomain.mytree.local이됩니다. 그것이 myforest라는 포리스트에있는 경우 serviceacount@mydomain.mytree.myforest.local (및 servicePrinciPalName에서도 유사)됩니다. 정규화 된 이름은 당신이 인증을 위해 Kerberos를 사용하고 있습니다.

다른 팁

게시 된 여기에 , 여기에서 여기 , 및 여기 .

더미 서비스 주체 이름 (SPN)을 제공 할 수 있습니다.이 경우 WCF가 실패하지 않습니다. 그러나 주체를 확인하지 않는 인증을 위해 NTLM으로 돌아갑니다.

그래서 구성 :

    <identity>
      <servicePrincipalName value="dummy" >
    </identity>
.

및 프로그래밍 방식으로

    EndpointIdentity identity = EndpointIdentity.CreateSpnIdentity("dummy");
.

channelfactory 사용 :

    Uri uri = new Uri("net.tcp://<myServer>:<myPort>/myServiceAddress");
    ChannelFactory channelFactory = new ChannelFactory<IMyContract>(new NetTcpBinding());
    channelFactory.CreateChannel(new EndpointAddress(uri, identity)
.

도 작동합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top