title: Determining the IP Address of the client in a WCF SOAP UserNamePasswordValidator
body: <p>We are currently using a custom <a href="http://msdn.microsoft.com/en-us/library/system.identitymodel.selectors.usernamepasswordvalidator.aspx" rel="nofollow">UserNamePasswordValidator</a>.  This allows the consumer to specify the credentials in a SOAP header as follows:</p>
  
  <pre><code>&lt;o:Security xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" mustUnderstand="1"&gt;
  &lt;Timestamp Id="_0"&gt;
      &lt;Created&gt;
          2013-04-05T16:35:07.341Z&lt;/Created&gt;
          &lt;Expires&gt;2013-04-05T16:40:07.341Z&lt;/Expires&gt;
      &lt;/Timestamp&gt;
      &lt;o:UsernameToken Id="uuid-ac5ffd20-8137-4524-8ea9-3f4f55c0274c-12"&gt;
          &lt;o:Username&gt;someusername&lt;/o:Username&gt;
          &lt;o:Password o:Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"&gt;somepassword
      &lt;/o:Password&gt;
  &lt;/o:UsernameToken&gt;
  &lt;/o:Security&gt;
  </code></pre>
  
  <p>We need to start logging the IP Address of the client, as well as doing some IP whitelisting/blacklisting.  Unfortunately I do not see how it is possible to retrieve the IP when in this class.  At runtime both the <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontext.current.aspx" rel="nofollow">OperationContext.Current</a> and <a href="http://msdn.microsoft.com/en-us/library/system.web.httpcontext.current.aspx" rel="nofollow">HttpContext.Current</a> properties are null.  </p>