wfc与自定义身份验证 [英] wfc with custom authentication

查看:162
本文介绍了wfc与自定义身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我无法连接到我的wfc,它是在SSL下,但这不是问题,我使用自定义身份验证......这里开始我的问题。



我连接到wfc:

ServiceReference1.Service1Client g = new ServiceReference1.Service1Client();

g.ClientCredentials.UserName.UserName =a ;

g.ClientCredentials.UserName.UserName =b;

string a = g.GetData(77);



这里我的例外



System.ServiceModel.ServiceActivationException



WFC的web.config是

Hi I can’t connect to my wfc, it is under SSL, but this is not a problem and I use custom authentication… and here starts my problems.

I connect to wfc:
ServiceReference1.Service1Client g = new ServiceReference1.Service1Client();
g.ClientCredentials.UserName.UserName = "a";
g.ClientCredentials.UserName.UserName = "b";
string a = g.GetData(77);

here my exception

System.ServiceModel.ServiceActivationException

WFC’s web.config is

<system.serviceModel>
    <services>
      <service name="WcfService1.Service1">
        <endpoint address=""

                  binding="basicHttpBinding"

                  bindingConfiguration="secureHttpBinding"

                  contract="WcfService1.IService1"/>

        <endpoint address="mex"

                  binding="mexHttpsBinding"

                  contract="IMetadataExchange" />
      </service>
    </services>
    <bindings>
      
      <basicHttpBinding>
        <binding name="secureHttpBinding">
          <security mode="TransportWithMessageCredential">
            <message clientCredentialType="UserName"/>


          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
          <serviceMetadata httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
          <serviceCredentials>
            <userNameAuthentication  userNamePasswordValidationMode="Custom"

             customUserNamePasswordValidatorType="WcfService1.UsernameAuthentication, WcfService1" />
          </serviceCredentials>
</behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>





类用户名身份验证是:





Class UsernameAuthentication is:

namespace WcfService1
{
    public class UsernameAuthentication : UserNamePasswordValidator
    {
        public override void Validate(string userName, string password)
        {
            var ok = (userName == "a") && (password == "b");
            ok = true;
            if (ok == false)
                throw new AuthenticationException(" not match");
        }
    }
}



我的服务是


My service is

namespace WcfService1
{
        [ServiceContract]
    
    public interface IService1
    {

        [OperationContract]
        string GetData(int value);
    }
}





有人可以帮帮我吗?

谢谢erika



can somebody help me?
thanks erika

推荐答案

这篇关于wfc与自定义身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆