2010-01-11 15 views
2

Je suis en train d'utiliser l'usurpation d'identité avec mon service WCF (en utilisant net.tcp de liaison) dans IIS 7. hébergé Je suis arrivé au point où il usurpe l'identité de la client, mais chaque fois que je tente d'accéder à tous les paramètres de configuration dans le web.config en utilisant Settings.Default.SomeSetting il jette un SettingsPropertyNotFoundException. Est-ce parce que IIS est en cours d'exécution sous une identité différente de l'identité personnifié? Si oui, quels paramètres dois-je changer pour leur permettre de fonctionner sous la même identité empruntée? J'ai essayé de définir la propriété « servicePrincipalName » sans aucun succès.Accéder aux paramètres web.config en utilisant WCF avec Impersonation net.tcp liant

J'ai inclus mes paramètres web.config ci-dessous:

<system.serviceModel> 
    <services> 
     <service name="TestServices"> 
     <endpoint address="" binding="netTcpBinding" bindingConfiguration="tcpbinding" 
      contract="Test.ITestService"> 
      <identity> 
      <servicePrincipalName value="NT AUTHORITY\NETWORK SERVICE" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mextcp" binding="mexTcpBinding" contract="IMetadataExchange" /> 
     </service> 
    </services>   
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> 
    <bindings>   
     <netTcpBinding> 
     <binding name="tcpbinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" portSharingEnabled="true"> 
      <security mode="Transport"> 
      <transport clientCredentialType="Windows" protectionLevel="None"/> 
      <message clientCredentialType="Windows"/> 
      </security> 
     </binding> 
     </netTcpBinding> 
    </bindings> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="true" /> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
      <serviceAuthorization impersonateCallerForAllOperations="true" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

Répondre

2

Il semble que je n'étais pas correctement se faisant passer pour mon client sur le côté serveur que je devais régler le allowedImpersonationLevel sur mon client « usurpation d'identité » . Ceci est par défaut "Identification". Alors, quand je l'ai testé en utilisant Nom. WindowsIdentity.GetCurrent() Je suis le nom d'utilisateur, mais l'utilisateur n'a pas fait Personnifiés.

donc ajouter à mon web.config client a fait l'affaire:

<client> 
     <endpoint address="net.tcp://localhost/Test/Service/TestService.svc" 
      binding="netTcpBinding" bindingConfiguration="NetTcpBinding_ITestService" 
      contract="ServiceReference.ITestService" name="NetTcpBinding_ITestService" 
      behaviorConfiguration="ImpersonationBehavior"> 
     </endpoint> 
    </client> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="ImpersonationBehavior"> 
      <clientCredentials> 
      <windows allowedImpersonationLevel="Impersonation" /> 
      </clientCredentials> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors>