title: SharePoint 2010 & "Attempted to perform an unauthorized operation." & SPListItems.RoleAssignments
body: <p>I'm receiving an error when my code attempts to iterate through the <code>SPListItems.RoleAssignments</code> collection in my event receiver. But only for users who have contributor rights. Users who have administrator rights. </p>
  
  <p>I've tried the following:</p>
  
  <ol>
  <li>Wrapping my under SPRunElevatedPrivlages</li>
  <li><p>Windows Impersation using the following code:</p>
  
  <pre><code>WindowsImpersonationContext ctx = null;
  ctx = WindowsIdentity.Impersonate(System.IntPtr.Zero);
  SPUserToken oSysToken = GetSysToken(properties.SiteId)
  private static SPUserToken GetSysToken(Guid SPSiteID)
  {
      SPUserToken sysToken = null;
      using(SPSite oSite = new SPSite(SPSiteID))
      {
          sysToken = oSite.SystemAccount.UserToken;
      }
      if (sysToken == null)
      {
          SPSecurity.RunWithElevatedPrivileges(
          delegate()
          {
              using(SPSite site = new SPSite(SPSiteID))
              {
                  sysToken = site.SystemAccount.UserToken;
              }
          });
      }
      return sysToken;
  }
  </code></pre></li>
  <li><p>Finally I've tried <code>SPWeb.AllowUnsafeUpdates = true;</code></p></li>
  </ol>
  
  <p>I've try all method seperatly and collective together and nothing. It seems like its through an exception as well on <code>SPListItems.RoleAssignments.Count</code>.</p>