title: How to convert WindowsIdentity to a NetworkCredential?
body: <p>How do we convert a <code>WindowsIdentity</code> to a <code>NetworkCredential</code>? I am testing my WCF service to verify that anonymous callers are blocked. To do this I want to do something like:</p>
  
  <pre><code>myProxy.ClientCredentials.Windows.ClientCredential = foo(WindowsIdentity.GetAnonymous());
  </code></pre>
  
  <p>where <code>foo</code> is a method that converts a <code>WindowsIdentity</code> to a <code>NetworkCredential</code></p>