メッセージセキュリティモードと認証を使用して認証する2種類の認証:wcfのウィンドウとユーザー名を使用できます。自分のユーザー名認証CFG /コードが見えます:
サーバーのCFG:
WCF混合認証ユーザー名とウィンドウ
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceCredentialsBehavior">
<serviceCredentials>
<serviceCertificate findValue="cn=cool" storeName="TrustedPeople" storeLocation="CurrentUser" />
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Util.CustomUserNameValidator, Util" />
</serviceCredentials>
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ServiceCredentialsBehavior" name="Service">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="MessageAndUserName" name="SecuredByTransportEndpoint" contract="IService"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="MessageAndUserName">
<security mode="Message">
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client/>
</system.serviceModel>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
クライアントCFG:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="LocalCertValidation">
<clientCredentials>
<serviceCertificate>
<authentication certificateValidationMode="PeerTrust" trustedStoreLocation="CurrentUser" />
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService" >
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:48097/WCFServer/Service.svc"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService"
contract="ServiceReference1.IService"
name="WSHttpBinding_IService" behaviorConfiguration="LocalCertValidation">
<identity>
<dns value ="cool" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
は何を変更するには、サーバーにアクセスするには、Windowsのアイデンティティを知るためには?
いいえ動作しません。 私は正しくWindows資格情報を設定していないかもしれませんし、サーバーから取得する方法もありますか? – croisharp
本当に2つの異なる認証方法が必要ですか?クライアントのWindows資格情報をサービスに渡して、サービスを[ユーザーを偽装する]ようにすることができます(http://www.danrigsby.com/blog/index.php/2008/04/17/impersonate-a-clients- identity-in-wcf /)である。これは、認証タイプを混在させて一致させるよりも優れた解決策です。ユーザー名を確認する場合は、データベースに保存し、WindowsIdentity.GetCurrent()から返されたオブジェクトの偽装クライアントユーザーの詳細と比較することができます(ユーザー名を変更できるため、sidを格納する方が良いでしょう)。 ) – Franchesca
はい私は2つの認証が必要です。メソッド+ NetSqlAzManとの認可が、私はすべての方法を知っている、これは混在認証で私の問題です.. – croisharp