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 ?
}
}
答案 0 :(得分:0)
如果 companyID 是来自客户的标识符,则可能最简单的方法是将其作为userName的一部分传递:
//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];
}
}