Public Sub ADRETRIEVE()
' On Error GoTo Next
Dim dirEntry As DirectoryEntry = New DirectoryEntry()
' NOTE: This path should be comma delimited, not semi-colon delimited
' Each label in the domain name should be a separate Domain Component (DC)
dirEntry.Path = "LDAP://OU=NAZ,OU=User Accounts,DC=one,DC=ads,DC=che,DC=org"
' dirEntry.Username = "ONE\Powerst9"
' dirEntry.Password = "Megadeth666$"
Dim mySearcher As DirectorySearcher = New DirectorySearcher(dirEntry)
' This value can be passed in the constructor if preferred.
mySearcher.Filter = "(objectClass=Person)"
mySearcher.PageSize = 1001
For Each resEnt As SearchResult In mySearcher.FindAll()
tscmbUsers.Items.Add(resEnt.Properties("Name")(0).ToString())
Dim lvi As ListViewItem = New ListViewItem()
' Dim listItem As New ListViewItew.Add(p.ProcessName.ToString())
lvi.ImageIndex = 0
lvi.SubItems.Add(resEnt.Properties("Name")(0).ToString())
lvi.SubItems.Add(resEnt.Properties("sAMAccountName")(0).ToString())
lvi.SubItems.Add(resEnt.Properties("Distinguishedname")(0).ToString())
' lvi.SubItems.Add(resEnt.Properties("phone")(0).ToString())
' List box is a bit simple for these unless I missed something
' lbADUsers.Items.Add(resEnt.Properties("sAMAccountName")(0).ToString())
' tscmbUsers.Items.Add(resEnt.Properties("aDSPath")(0).ToString())
' And this one needs some work unless you're attaching to every object within the directory.
' lbADUsers.Items.Add(resEnt.Properties("objectGUID")(0).ToString())
Next
txtNazUsers.Text = tscmbUsers.Items.Count
End Sub
OK Know this is a Global OU with Group I want to pull all Groups from but I get a Com Unspecified ErrorPublic Sub ADGlobal()
' On Error GoTo Next
Dim dirEntry As DirectoryEntry = New DirectoryEntry()
' NOTE: This path should be comma delimited, not semi-colon delimited
' Each label in the domain name should be a separate Domain Component (DC)
dirEntry.Path = "OU=Unified Data Centers,OU=Groups Application,DC=one,DC=ads,DC=che,DC=org"
dirEntry.Username = "ONE\Powerst9"
dirEntry.Password = "Megadeth666$"
Dim mySearcher As DirectorySearcher = New DirectorySearcher(dirEntry)
' This value can be passed in the constructor if preferred.
mySearcher.Filter = "(objectClass=group)"
mySearcher.PageSize = 1001
lvGroups.Columns.Add("Image", 100, HorizontalAlignment.Center)
lvGroups.Columns.Add("Global Group Name", 650, HorizontalAlignment.Center)
For Each resEnt As SearchResult In mySearcher.FindAll()
' tscmbUsers.Items.Add(resEnt.Properties("Name")(0).ToString())
Dim lvi As ListViewItem = New ListViewItem()
' Dim listItem As New ListViewItew.Add(p.ProcessName.ToString())
lvi.ImageIndex = 1
' lvi.SubItems.Add(resEnt.Properties("Name")(0).ToString())
lvi.SubItems.Add(resEnt.Properties("sAMAccountName")(0).ToString())
lvGlobal.Items.Add(lvi)
' lvGroups.Sort(resEnt.Properties("Name")(0).ToString())
lvGlobal.EndUpdate()
Next
txtNazUsers.Text = tscmbUsers.Items.Count
End Sub
Not grabbing Global OU I'm remotted into my PC at Work I'll be back after areboot no memory to take screenshots.
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.