title: SSRS get list of AD groups for current user but #error
body: <p>I have a piece of code that allows you to retrieve the AD groups of a user in a SSRS report.
  However, I get an #error in my report locally but also when I run it via the SSRS portal. I think it has something to do with additional permissions? Does anyone know how to get it to work?</p>
  <pre><code>Public Function GetUserMembership(ByVal strUser As String ) As String
  Dim groups As String
  Try
   Dim obEntry As New System.DirectoryServices.DirectoryEntry(&quot;LDAP://DC=aw,DC=com&quot;)
   Dim srch As New System.DirectoryServices.DirectorySearcher(obEntry, &quot;(sAMAccountName=&quot; &amp; strUser &amp; &quot;)&quot;)
   Dim res As System.DirectoryServices.SearchResult = srch.FindOne()
   If res IsNot Nothing Then
   Dim obUser As New System.DirectoryServices.DirectoryEntry(res.Path)
   ' Invoke Groups method.
   Dim obGroups As Object = obUser.Invoke(&quot;Groups&quot;)
   For Each ob As Object In DirectCast(obGroups, System.Collections.IEnumerable)
    ' Create object for each group.
    Dim obGpEntry As New System.DirectoryServices.DirectoryEntry(ob)
    groups = groups + obGpEntry.Name + &quot;;&quot;
   Next
   End If
  Catch ex As Exception
   groups = &quot;&quot;
  End Try
  Return groups
  End Function
  </code></pre>
  <p>To use it in the report:</p>
  <pre><code>=Code.GetUserMembership(Split(User!UserUD, &quot;\&quot;)(1))
  </code></pre>
  <p>Additional, I found an assembly reference is required to use the class System.DirectoryServices.DirectoryEntry. In my case I found the .dll (DirectoryServices) at the following location: C:\Windows\Microsoft.NET\Framework\v4.0.30319.</p>
  <p>Source: <a href="https://social.msdn.microsoft.com/Forums/en-US/6f00f6bc-15dc-4ca4-b0c7-99cabf5abd90/ssrs-2008-r2-how-to-get-the-logged-user-group-information?forum=sqlreportingservices" rel="nofollow noreferrer">https://social.msdn.microsoft.com/Forums/en-US/6f00f6bc-15dc-4ca4-b0c7-99cabf5abd90/ssrs-2008-r2-how-to-get-the-logged-user-group-information?forum=sqlreportingservices</a></p>