사용자 이름과 암호를 사용할 때 WCF 서비스에 약간 새로운 기능이 있습니다. 내 웹 서비스를 사용자 이름과 암호로 보호하기 위해 http://www.codeproject.com/Articles/96028/WCF-Service-with-custom-username-password-authenti에있는 자습서를 따랐습니다.사용자 이름과 암호를 사용하는 WCF 서비스
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="NewBehavior0" name="TService">
<endpoint address="mex" binding="mexHttpBinding" contract="ITechnology" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="NewBinding0">
<security>
<message clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="NewBehavior0">
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="PeerTrust" />
</clientCertificate>
<serviceCertificate findValue="Server" storeLocation="CurrentUser"
storeName="TrustedPeople" x509FindType="FindBySubjectName" />
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="TService, Services1"/>
</serviceCredentials>
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
지금 난 내 브라우저에서 WDSL을 볼 수 있으며 로컬 예상대로 내가 인증서 작동하는 아래
내 구성 파일입니다. WCF 테스트 도구를 사용하여 서비스에 연결할 때 사용자 이름과 암호를 묻지 않습니다.
게시 된 링크에 따르면 마지막 단계 (사용자 이름과 암호를 전달하는 코드 추가)조차하지 못했지만 서비스에 계속 연결하여 모든 데이터를 검색 할 수 있습니다.
무엇을 놓치 셨나요? 그리고 사용자/서비스 만 데이터를 검색 할 수 있도록 허용하는 서비스를 어떻게 제한 할 수 있습니까?
편집 1 :
링크 CodeProject의 페이지의 빠른 검토 결과<system.serviceModel>
<services>
<service behaviorConfiguration="NewBehavior0" name="TechService">
<endpoint address="mex" binding="mexHttpBinding" contract="ITechService" />
<endpoint address="TechService.svc" binding="wsHttpBinding" bindingConfiguration="" contract="ITechService" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="NewBinding0">
<security>
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="NewBehavior0">
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="PeerTrust" />
</clientCertificate>
<serviceCertificate findValue="Server" storeLocation="CurrentUser"
storeName="TrustedPeople" x509FindType="FindBySubjectName" />
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="TechService, Services1"/>
</serviceCredentials>
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
서비스 요소 및 끝점 요소에는 정규화 된 이름 즉 namespace.TService 및 namespace.ITechnology가 있어야합니다. 귀하의 구성에 따라 엔드 포인트가 적절한 바인딩 메커니즘을 사용하고 있지 않습니다. wsHttpBinding 또는 basicHttpBinding (전송 보안 포함) – Rajesh