Query AD for groups with description value

  • Thread starter Thread starter Ryan Lashway
  • Start date Start date
R

Ryan Lashway

Guest
Thank you all in advance, this is just a feature I am hoping to get to work in my code.


I have an application that allows a user to manually enter a group name, then scan the group for members and display the results in a datagridview.

We populate all our group descriptions with the responsible users name (responsible for administrating).


Is it possible, to scan AD for groups with a description that contains the displayname of the user running the application?


It am thinking, but dont know how to, do a scan for groups with a description LIKE displayname with an cmbbox.items.add(value), but the below code I am trying will not return anything, and is a equal, not contains.



dim search as directorysearcher = New DirectorySearcher("LDAP://RootDSE")
search.PropertiestoLoad.add("description")
search.PropertiestoLoad.add("name")
search.propertiestoload.add("description")
search.filter = "(Description=Exact value)"

dim search results as searchResultcollection = search.findall()
dim de as directory entry

for each ADGroup as SearchResult in results
de = ADGroup.GetDirectoryEntry()
dim displayname as String = de.properties("displayname")(0).ToString()
Next



but I get nothing except an error "System.ArgumentOutofRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection/


I am figuring this is from the code being a Frankenstein of stuff I found.


Any help is appreciated, just feel it would be a nice feature to have.

Continue reading...
 
Back
Top