I would really welcome some help with this issue. We have a php code that works and connects to the LDAP. When I try to connect using VB.NET 2010, it fails to bind with logon failure unknown username or bad password. Below is the connection information. When I talk to the folks who run the ldap server, they say I am binding sucessfully, below is the log file for the sucessful bind? If I continue and try to execute a search I don't get any results. The server is running openLDAP ver 2.3.39 on a linux server, server requires connection on port 636 for secure connection, or 389 for anonymous.
using the following imports in code:
Imports System.DirectoryServices
Imports System.DirectoryServices.Protocols
Imports System.Data.SqlClient
Imports System.Net.NetworkCredential
my connection:
Dim dirEntry As DirectoryEntry = New DirectoryEntry("LDAP://xxx.MyDomain.xxx/cn=users,dc=MyDomain,dc=xxx", "uid=my-bind,cn=users,dc=MyDomain,dc=xxx", "MyPassword")
dirEntry.AuthenticationType = AuthenticationTypes.SecureSocketsLayer
my BindLog:
Mar 16 15:10开发者_运维技巧:17 ldap4 slapd[17391]: conn=110556 op=0 RESULT tag=97 err=0 text= Mar 16 15:10:17 ldap4 slapd[17391]: conn=110555 op=0 BIND dn="uid=my-bind,cn=users,dc=myDomain,dc=xxx" method=128 Mar 16 15:10:17 ldap4 slapd[17391]: conn=110555 op=0 BIND dn="uid=my-bind,cn=users,dc=myDomain.xxx" mech=SIMPLE ssf=0 Mar 16 15:10:17 ldap4 slapd[17391]: conn=110555 op=0 RESULT tag=97 err=0 text=
my search:
Try
Dim search As New DirectorySearcher(enTry)
search.Filter = ("(&(objectClass=users)(cn=" & myUser & "))")
Dim result As SearchResult = search.FindOne()
Dim myResult As Boolean = Nothing
If result Is Nothing Then
myResult = False
Else
myResult = True
End If
.... do some processing here
Catch f As Exception
Console.WriteLine(f.Message & vbCrLf & f.HelpLink.ToString)
End Try
New DirectoryEntry("LDAP://xxx.MyDomain.xxx/cn=users,dc=MyDomain,dc=xxx",
"uid=my-bind,cn=users,dc=MyDomain,dc=xxx", "MyPassword")
The constuctor you're trying to use is probably this
Public Sub New(ByVal path As String, ByVal username As String, ByVal password As String)
but your passing "uid=my-bind,cn=users,dc=MyDomain,dc=xxx" as the username.
精彩评论