使用UserNamePasswordValidation和Sessions的WCF服务

时间:2012-08-13 15:18:09

标签: wcf session authentication

我有一个当前使用basicHttpBindinguserNamePasswordValidationModeTransportWithMessageCredential的WCF服务,这是我的配置:

<behavior name="Secure">
      <serviceMetadata httpsGetEnabled="true" httpGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <serviceCredentials>
        <userNameAuthentication userNamePasswordValidationMode="Custom"
                                customUserNamePasswordValidatorType="Kestrel.MIS3.Server.Services.Security.LoginAuthentication, Kestrel.MIS3.Server.Services" />
      </serviceCredentials>
      <serviceAuthorization principalPermissionMode="Custom">
        <authorizationPolicies>
          <add policyType="Kestrel.MIS3.Server.Services.Security.AuthorizationPolicy, Kestrel.MIS3.Server.Services"/>
        </authorizationPolicies>
      </serviceAuthorization>
<behaviour>

<services>
  <service name="Kestrel.MIS3.Server.Services.UserService" behaviorConfiguration="Secure">
    <endpoint address=""
              binding="wsHttpBinding"
              bindingConfiguration="wsSecure"
              contract="Kestrel.MIS3.Server.Services.IUserService" />
    <endpoint address="mex"
              binding="mexHttpsBinding"
              contract="IMetadataExchange" />
  </service>
</services>

<wsHttpBinding>
    <binding name="wsSecure">
      <reliableSession enabled="true"/>
      <security mode="TransportWithMessageCredential">
        <message clientCredentialType="UserName" />
      </security>
    </binding>
  </wsHttpBinding>

我希望能够使用Session,以便在创建服务实例时,我不需要立即查找用户详细信息。这可能吗?

我已使用以下内容标记了服务,但没有运气:

[ServiceContract(SessionMode = SessionMode.Required)]    
public interface IUserService

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
public class UserService : ServiceBase, IUserService

0 个答案:

没有答案