在WCF CustomUserNameValidator上获取客户端IP地址

时间:2016-01-13 14:31:30

标签: c# asp.net web-services wcf c#-4.0

我们在WCF项目中使用CustomUserNameValidator。我在进行身份验证时需要获取客户端IP地址。 OperationContext为null,我无法得到它。 ı不想打开Asp.Net Compability模式。

 public class CustomUserNameValidator : UserNamePasswordValidator
{
    public override void Validate(string userName, string password)
    {
        if (null == userName || null == password)
        {
            throw new ArgumentNullException();
        }

        try
        {
            int userId = Common.AuthenticateUser(userName, password); //need ip adresses here
        }
        catch (Exception)
        {
            throw new SecurityTokenException("Unauthorized");
        }
    }
}

对此问题有任何决心吗?

0 个答案:

没有答案
相关问题