I'm testing a LDAP connection to my companies Active directory server and
I'm getting the "An invalid dn syntax has been specified." error all the time.
Here is my code:
Dim entry As New DirectoryEntry()
entry.Path = "LDAP://xxxxxx.company.se:389"
entry.Username = "uid=MYAPP,ou=users,ou=internal,o=company"
entry.Password = "yyyyyyyyy"
entry.AuthenticationType = AuthenticationTypes.Secure
Dim search As New DirectorySearcher(entry)
search.ExtendedDN = ExtendedDN.Standard
search.Filter = "(&(ou=ENN)(eriIsManager=Y))"
search.PropertiesToLoad.Clear()
search.PropertiesToLoad.Add("uid")
search.PropertiesToLoad.Add("eriCn")
search.PropertiesToLoad.Add("mail")
search.PropertiesToLoad.Add("title")
search.PropertiesToLoad.Add("eriResignDate")
search.SearchScope = SearchScope.OneLevel
Dim sr As SearchResultCollection
Dim x As String = ""
Dim sw As New
streamwriter(My.Computer.FileSystem.SpecialDirectories.Desktop +
"\ldaptest.txt")
sr = search.FindAll
For Each src As SearchResult In sr
For Each strKey As String In src.Properties.PropertyNames
Dim objValueCollection As ResultPropertyValueCollection
objValueCollection = src.Properties(strKey)
Dim objPropertyValue As Object
For Each objPropertyValue In objValueCollection
x += objPropertyValue.ToString + ";"
Next
Next strKey
sw.WriteLine(x)
Next
sw.Close()
entry.Close()
with this code I'm trying to figure out how to read the returned data.
The error message always comes on the FindAll line.
I have used the same settings in Apache Directory Studio and then it works.
what am I doing wrong?
rg,
Eric