title: C# gpresult /r equivalent
body: <p>I'm writing a small app that checks to see if a computer and current user are members of the appropriate security groups in Active Directory. I stumbled across this question <a href="https://stackoverflow.com/questions/16399934/get-gpo-information-using-microsoft-grouppolicy">LINK</a> but it looks like it was forgotten and I'm running into the same issues as the OP. The end result is I want to be able to create an array that is very similar to running the following command from a command prompt.</p>
  
  <pre><code>gpresult /r
  </code></pre>
  
  <p>Here is a code sample that I have tried from the above link, I'm running into the same errors as the OP specifically "out of range" exception" when attempting to set LoggingUser and LoggingComputer. Since I can't get past these errors I'm not even sure if this method is the right route.</p>
  
  <pre><code>GPRsop rsop = new GPRsop(RsopMode.Logging, "root\\RSOP\\Computer");
  rsop.LoggingComputer = "MyComputer";
  rsop.LoggingUser = "domain\\user";
  rsop.LoggingMode = LoggingMode.Computer;
  rsop.CreateQueryResults();
  rsop.GenerateReportToFile(ReportType.Xml, "C:\\Temp\\test.xml");
  </code></pre>