list all security groups in active directory

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2008
Posts: 115
Reputation: ninjaimp is an unknown quantity at this point 
Solved Threads: 6
ninjaimp ninjaimp is offline Offline
Junior Poster

list all security groups in active directory

 
0
  #1
Jul 7th, 2009
Hi

Im trying to to simply list all security groups from active directory as i will then be doing checks on folders with the mathcing security group.

I can list all the users from active directory with this:
  1. Dim myDirectoryEntry As DirectoryEntry = New DirectoryEntry(String.Format("LDAP://DC=domain,DC=org"))
  2. Dim mySearcher As DirectorySearcher = New DirectorySearcher(myDirectoryEntry)
  3. Dim mySort As SortOption = New SortOption("sn", SortDirection.Ascending)
  4. mySearcher.Filter = ("(objectClass=user)")
  5. mySearcher.Sort = mySort
  6. For Each resEnt As SearchResult In mySearcher.FindAll()
  7. Try
  8. 'If Not String.IsNullOrEmpty(resEnt.Properties("Mail")(0).ToString()) _
  9. ' AndAlso System.Text.RegularExpressions.Regex.IsMatch(resEnt.Properties("DisplayName")(0).ToString(), " |admin|test|service|system|[$]", System.Text.RegularExpressions.RegexOptions.IgnoreCase) Then
  10. Dim space As Integer = resEnt.Properties("DisplayName")(0).ToString().IndexOf(" ")
  11. Dim formattedName As String = String.Format("{0}{1}{2}", _
  12. resEnt.Properties("DisplayName")(0).ToString().Substring(space).PadRight(25), _
  13. resEnt.Properties("DisplayName")(0).ToString().Substring(0, space).PadRight(15), _
  14. resEnt.Properties("Mail")(0).ToString() _
  15. )
  16. userList.Add(formattedName)
  17. 'End If
  18. Catch
  19. badEntries = badEntries + 1
  20. End Try
  21. Next

but all want all the confugred security groups/users

wondered if anyone had any ideas?
Please mark this post as 'Solved' if it has helped and fixed your issue.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC