Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.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# 具有2个以上参数的WCF自定义身份验证_C#_Wcf - Fatal编程技术网

C# 具有2个以上参数的WCF自定义身份验证

C# 具有2个以上参数的WCF自定义身份验证,c#,wcf,C#,Wcf,如果companyID是来自客户端的标识符,则最简单的方法是将其作为用户名的一部分传递: public class Authentication : UserNamePasswordValidator { public override void Validate(string userName, string password, string companyID) { //How can i pass a custom data like "companyID" t

如果companyID是来自客户端的标识符,则最简单的方法是将其作为用户名的一部分传递:

public class Authentication : UserNamePasswordValidator
{

   public override void Validate(string userName, string password, string companyID)
   { 

     //How can i pass a custom data like "companyID" to Validate method ?
   }

}
只需在验证器中拆分:

//on client:
string username = companyID + ":" + realUsername;
public override void Validate(string userName, string password) {
    string companyID, realUsername;
    string[] parts = userName.Split(':', 2);
    if (parts.Length == 2) {
        companyID = parts[0];
        realUsername = parts[1];
    }
}