Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在WCF中使用iParameterInspector进行身份验证_C#_Wcf_Validation_Authentication_Wcf Security - Fatal编程技术网

C# 在WCF中使用iParameterInspector进行身份验证

C# 在WCF中使用iParameterInspector进行身份验证,c#,wcf,validation,authentication,wcf-security,C#,Wcf,Validation,Authentication,Wcf Security,您好,我想使用下面的startegy来保护通过internet公开的WCF服务 在webconfig中将TransportWithMessageCredentials用作的安全模式 SSL和基于消息的安全性。但是我不想用 clientCredentialType=“Username”设置,原因如下 用户名密码验证程序出现问题 使用自定义用户名密码验证器的问题是,使用这种方法只能验证用户名和密码。如果我 需要验证客户端在 请求对象,则此方法不起作用(至少我是 (不知道) net以外的客户端在设置

您好,我想使用下面的startegy来保护通过internet公开的WCF服务

在webconfig中将TransportWithMessageCredentials用作的安全模式 SSL和基于消息的安全性。但是我不想用 clientCredentialType=“Username”设置,原因如下

用户名密码验证程序出现问题

  • 使用自定义用户名密码验证器的问题是,使用这种方法只能验证用户名和密码。如果我 需要验证客户端在 请求对象,则此方法不起作用(至少我是 (不知道)

  • net以外的客户端在设置clientCredential时经常遇到问题

  • 因此,我不想使用clientCredentialType作为“UserName”,而是考虑设置clientCredentialType=“None”,这样我就不会使用身份验证了 WCF框架提供的支持

  • 创建由IPParameterInspector派生到的ParamInspector类
    检查请求参数,请求对象将具有用户名 、密码和其他一些详细信息

  • 我的requestDTO将从具有所有 验证所需的属性

  • 然后,我可以在运行时访问parameterinspector类中的请求对象,然后 验证baseRequestDTO

    public object BeforeCall(string operationName, object[] inputs)
        { 
    for (int index = 0; index < inputs.Length; index++)
              {
                  if (index == 0)
                  {
                      baseRequestDTO obj = inputs[index] as baseRequestDTO ;
                      if (obj != null))
                      {
                        // Call Authentication service passing baseRequestDTO
                        // validate username,password and other details                                 
                      }
    
                      break;
                   }
               }
    }
    
    调用前公共对象(字符串操作名,对象[]输入) { for(int index=0;index 这种方法有什么问题吗?还是有更好的方法?想知道是否有其他人在做不同的事情