title: C# - How to use DirectorySecurity.SetOwner() ? I'm having troubles
body: <p>I'm having troubles figuring out the <code>SetOwner()</code> method.
  In my case, I've created an user in Active Directory by code, then, I create a folder for the user.</p>
  
  <p>It all works fine, but I cannot set the newly created user as the owner of the folder.
  I'm not a C# guru, so I'm having troubles to understand the <code>DirectorySecurity.SetOwner()</code> method. Can anyone please help me out?</p>
  
  <p>Here is the code that creates the folder, sets the rights like i want it, but I also need to set the user as the owner.</p>
  
  <pre><code>string pathIntern = @"\\11fil01\brukar\" + user.UserName;
  
  System.IO.DirectoryInfo diIntern = new System.IO.DirectoryInfo(pathIntern);
  
  diIntern.Create();
  
  DirectorySecurity dsecIntern = diIntern.GetAccessControl();
  
  FileSystemAccessRule rule = new FileSystemAccessRule(user.UserName, FileSystemRights.FullControl, InheritanceFlags.None | nheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow);
  
  dsecIntern.SetAccessRule(rule);
  diIntern.SetAccessControl(dsecIntern);
  //dsecIntern.SetOwner(heeeeelp);
  </code></pre>