title: Using Flags in my own C# control such as the settings in UserAccountControl in Active Directory
body: <p>I have been working with System.DirectoryServices for a while in a project involving Active Directory. I am curious on the implementation of the UserAccountControl property to  control the attributes of a particular account. If I wanted to implement settings in my own applications using a combination of bytes to determine the state of x or y setting, <strong>how would I go about doing this in C#?</strong> Say that I would like to implement a useraccountcontrol property on my own class and I want to use a combination of bytes to determine which permissions the account should have.</p>
  
  <p>Here is the way it is modified in Active Directory:
  <a href="http://support.microsoft.com/kb/305144" rel="nofollow">http://support.microsoft.com/kb/305144</a></p>
  
  <p>and here is the place with the object definition:
  <a href="http://msdn.microsoft.com/en-us/library/ms680832%28VS.85%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms680832%28VS.85%29.aspx</a></p>
  
  <p>Edit:</p>
  
  <p>Say that I have a User class of my own and I want to implement a property similar to the way UserAccountControl is implemented in Active Directory. Let's say I want to have a set of four bytes storing the settings. </p>
  
  <p>I want to use the last byte to determine the account status, 
  0 = Account Inactive 1= Account Active 2=Account Expired 4=Some Other Status 8=Yet Another Status. </p>
  
  <p>Then the next byte to the left I want to contain the account type: 
  16=Admin Account, 32=Regular Account, 64=Guest Account, 128 = Other Account. </p>
  
  <p>Then use the next byte to the left to set some other setting so that 
  256 = something, 512 = something else, 1024 = something else, etc. </p>
  
  <p>I would like to combine this to use bitwise combinations to set the account properties. I have the idea in my head, but I am not sure how to implement it, or if it even makes sense what I am trying to do.</p>
  
  <p>Edit:
  After receiving the answer and doing some more digging I found this link that talks more about setting Flags: <a href="http://msdn.microsoft.com/en-us/library/ms229062.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms229062.aspx</a></p>