title: How to use System.IdentityModel in own client-server application
body: <p>I've got a simple client-server application based on TcpClient/TcpListener and SslStream. Clients can authenticate themselves to the server using a X509Certificate or by sending a user name and password after the SslStream has been established.</p>
  
  <p>WCF makes use of the <strong>System.IdentityModel</strong> namespace for authentication purposes, but <a href="http://www.leastprivilege.com/CommentView.aspx?guid=85585fae-f04f-4de9-8207-631a0b228b06" rel="noreferrer">apparently</a> that can be used in arbitrary applications--which sounds interesting. Information on how to do this is sparse though (or my Google foo is weak today).</p>
  
  <p>So, my question is: <strong>What do I need to do to integrate System.IdentityModel with my application?</strong> I'm not sure if I need all that ClaimSet stuff, but it would be nice if users could log in just using their Windows account or any other provided authentication mechanism. (Unfortunately I can't just switch to WCF but have to use the custom protocol, although I can make some changes to it if necessary.)</p>