A
Adam J. O'Rourke
HI I'm trying to write a Vb program to get some pieces of information
for our Active directory, but when i connect to my AD server, the only
information i can seem to get is the DNS information. I wrote the
following code to try and find what search filters i needed to get the
User information i wanted, but all i get back is the DNS information,
any help you can give me would be a huge help.
Dim strpath As String =
"LDAP://server.domain.com/DC=domain,DC=com"
Dim LogonName As String = "anonymous"
Dim LogonPassword As String = ""
Dim count As Int16
StopSearch = False
Dim myDE As New
System.DirectoryServices.DirectoryEntry(strpath, LogonName,
LogonPassword)
myDE.AuthenticationType = AuthenticationTypes.ReadonlyServer
Dim MySearch As New
System.DirectoryServices.DirectorySearcher(myDE)
MySearch.SearchRoot = myDE
MySearch.SearchScope = SearchScope.Subtree
txtOutput.Text = ""
Dim results As SearchResultCollection
Try
results = MySearch.FindAll
Dim res As SearchResult
Dim key, objValue
count = 0
For Each res In results
If StopSearch Then Exit For
For Each key In res.Properties.PropertyNames
If StopSearch Then Exit For
If UCase(key) = "DC" Then txtOutput.Text &= vbCrLf
& vbCrLf
txtOutput.Text &= key & " = "
Try
For Each objValue In res.Properties(key)
If StopSearch Then Exit For
txtOutput.Text &= objValue.ToString() &
vbCrLf
Next objValue
Catch
End Try
System.Windows.Forms.Application.DoEvents()
count += 1
If count = 10 Then Exit For
Next
Next
Catch
MsgBox("invalid search")
Exit Sub
End Try
MsgBox("finished search")
This code shows me alot of information, but not the information i
want.
Thank you,
Adam J. O'Rourke
Programer/Technician
for our Active directory, but when i connect to my AD server, the only
information i can seem to get is the DNS information. I wrote the
following code to try and find what search filters i needed to get the
User information i wanted, but all i get back is the DNS information,
any help you can give me would be a huge help.
Dim strpath As String =
"LDAP://server.domain.com/DC=domain,DC=com"
Dim LogonName As String = "anonymous"
Dim LogonPassword As String = ""
Dim count As Int16
StopSearch = False
Dim myDE As New
System.DirectoryServices.DirectoryEntry(strpath, LogonName,
LogonPassword)
myDE.AuthenticationType = AuthenticationTypes.ReadonlyServer
Dim MySearch As New
System.DirectoryServices.DirectorySearcher(myDE)
MySearch.SearchRoot = myDE
MySearch.SearchScope = SearchScope.Subtree
txtOutput.Text = ""
Dim results As SearchResultCollection
Try
results = MySearch.FindAll
Dim res As SearchResult
Dim key, objValue
count = 0
For Each res In results
If StopSearch Then Exit For
For Each key In res.Properties.PropertyNames
If StopSearch Then Exit For
If UCase(key) = "DC" Then txtOutput.Text &= vbCrLf
& vbCrLf
txtOutput.Text &= key & " = "
Try
For Each objValue In res.Properties(key)
If StopSearch Then Exit For
txtOutput.Text &= objValue.ToString() &
vbCrLf
Next objValue
Catch
End Try
System.Windows.Forms.Application.DoEvents()
count += 1
If count = 10 Then Exit For
Next
Next
Catch
MsgBox("invalid search")
Exit Sub
End Try
MsgBox("finished search")
This code shows me alot of information, but not the information i
want.
Thank you,
Adam J. O'Rourke
Programer/Technician