title: Querying LDAP in VB.NET. I have the user account, and I want a list of groups the user in in
body: <p>I know the SAMAccountName, and now want to populate a list of groups with entries that reflect this user's group membership across the whole directory. Here's my start, but I'm stumped:</p>
  
  <pre><code>        Dim path As String = WebConfigurationManager.AppSettings("ldapPath")
          Dim entry As New DirectoryEntry(path)
          Dim search As DirectorySearcher = New DirectorySearcher(entry)
          Dim groupList As StringBuilder = New StringBuilder()
          search.Filter = "(SAMAccountName=" &amp; _thisUser.UserName &amp; ")"
          search.PropertiesToLoad.Add("memberOf")
          'search.SearchScope = SearchScope.Subtree
  
          For Each res As SearchResult In search.FindAll
          Next  ''Just doing this so I can look at "res" objects in debug
  </code></pre>
  
  <p>I've no idea how to traverse this. Please, any pointers?</p>