title: WCF Authenticate Client with database
body: <p>I have a WCF service that supposed to provide service to several clients.</p>
  <p>The WCF will have a Data-Access-Layer that will communicate with the database.</p>
  <p>This is part of my design idea : <a href="http://s15.postimage.org/apxri7mw9/Design_Idea.png" rel="nofollow noreferrer">My Design</a></p>
  <p><a href="https://i.stack.imgur.com/FBJ56.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FBJ56.png" alt="My Design" /></a></p>
  <p>As you can see - each client will connect to the 1st WCF service for pulling information (get product, update product), and also to the 2nd WCF service in a pub\sub manner, so it would be able to receive notifications about different things it wants.</p>
  <p>I have a table in the database for 'Users' with all the users in the system.
  (there is an administrator, a normal user and a technician).</p>
  <p>My question is - how do I do the 'logging' in from the client to the database ?</p>
  <p>My current idea - have a function in the services called <strong>'Connect ( username, password )'</strong> and when a client connects - it will pass the username and password to be authenticated in the database, and only if authenticated - the client will start sending commands.</p>
  <p>Problem with this is - anyone can write his own client that connects to my service and runs other functions without authenticating. I can solve this by saving in the service whether or not the client has authenticated.</p>
  <p>But is there a better solution that just having a 'Connect' function in the service ?</p>
  <p>Hope there is something simple yet effective.</p>