Note that there are some explanatory texts on larger screens.

plurals
  1. POActive Directory User Group Membership
    primarykey
    data
    text
    <p>I am trying to get a users group membership and limiting the results to those that match a string, ie I am only interested in the users group membership where the group begins with "test-".</p> <p>The following is what I have been playing around with, even though the user is apart of several groups that match the search string, the If statement is not returning True on any of them.</p> <pre><code>Private Function GetGroups(ByVal userName As String) As Collection Dim Groups As New Collection Dim intCount As Integer Dim entry As DirectoryEntry = ADEntry() Dim mySearcher As DirectorySearcher = New DirectorySearcher(entry) Dim arrList As New ArrayList() ' Limit the search results to only users mySearcher.Filter = "(&amp;(ObjectClass=User)(CN=" &amp; userName &amp; "))" ' Set the sort order mySearcher.PropertiesToLoad.Add("MemberOf") Dim searchResults As SearchResultCollection = mySearcher.FindAll() MessageBox.Show(searchResults.Count) If searchResults.Count &gt; 0 Then Dim group As New DirectoryEntry(searchResults(0).Path) For Each member As Object In group.Properties("MemberOf") MessageBox.Show("Pre: "+ member) 'This message box returns all the groups the user is apart of. If group.Properties("memberOf").Contains("test-") = True Then MessageBox.Show(member) ' This message box never shows End If Next End If Return Groups End Function </code></pre> <p>Is there any way of applying a search or If statement agains an Object where the constraint is a wildcard?</p> <p>The groups I am looking for could be one of about 60 (this amount does increase and decrease as staff leave).</p> <p>I am using VB.NET 2.0.</p> <p>Thanks,</p> <p>Matt</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload