title: Authenticate user in WinForms (Nothing to do with ASP.Net)
body: <p>Note: <a href="https://serverfault.com/q/586829/215219">Cross-posted to ServerFault</a>, based on comments.</p>
  
  <h1>Intro</h1>
  
  <p>I need to password protect some actions in my application, such as loading/saving files, clicking check-boxes, etc.  This is a standard C# .Net 4.0, WinForms application which will run on Windows 7 in a corporate network.</p>
  
  <p>I was about to roll my own very basic system (read obfuscation with wide open backdoors) with a text file of users/passwords/permissions (hashed and salted) until after some searching I found what looks like a 
  <a href="https://stackoverflow.com/a/351876/1718702">tantalizingly simple approach</a> , but I'm having trouble finding a good tutorial on Roles that <strong>isn't</strong> about ASP.NET.</p>
  
  <h1>Question</h1>
  
  <p>So does anyone know of one or more tutorials that show me how to:</p>
  
  <ol>
  <li>Create a Windows User/Group and give that User/Group a <code>Role</code> or Permission.
  
  <ul>
  <li>Note that I'm testing this from my company's networked laptop, but will deploy it on the customer's corporate network (Not sure if this is an issue, or how tricky this will get).</li>
  </ul></li>
  <li>Create winforms/console app sample with even just a single method that prints "Hello World" if I'm authenticated or throws an exception if I'm not?</li>
  <li>I've never done Network Admin or anything related and I keep reading about Active Directory and Local Users Vs Networked Users... I was hoping for an approach where I could build to an <code>Interface</code> and just ask Windows if the current user has permission <em>ABC</em> and not care too much about how Windows figured that out. Then I can make a concrete implementation for each Local/Network/ActiveDirectory/etc. use case as required (or <em>if</em> required... as I don't even know that right now).</li>
  </ol>
  
  <h1>Background</h1>
  
  <pre><code>- read if interested, but not required to answer question
  </code></pre>
  
  <p>Just to make sure I'm going in the right direction here, basically I need/want to test this on my development PC to make sure it's going to have a good end-user experience for my customer.  The problem is that currently they run an Auto-login script for each computer that runs my application and there are several different operators that use my application throughout the day.  The customer wants password protection on certain features of my app and only provide that to certain operators.  I have no problem fitting this in, as I've expected the request for a while, I just haven't ever programmed authentication before.</p>
  
  <p>I think it's worthwhile to convince my customer to give each operator their own network account and assign whatever permissions they want to that operator or group, in case they need to fire somebody, change permissions, etc. It also means I just open several options for them and they can group those permissions however they see fit based on internal corporate policies, which I really shouldn't have to be worried about (but will be if I have to roll my own, as they're IT department knows almost nothing of my application).</p>
  
  <p>From what I can tell it also makes my life a lot easier by not having to deal with hashing passwords and encryption, etc. and just handle which Role is required to click this or that button.</p>