VB.NET连接到LDAP失败了未知用户名或密码错误

时间:2011-03-23 00:22:25

标签: vb.net

我真的很欢迎这个问题的一些帮助。我们有一个PHP代码,可以工作并连接到LDAP。当我尝试使用VB.NET 2010进行连接时,它无法与登录失败未知用户名或密码错误绑定。以下是连接信息。当我与运行ldap服务器的人交谈时,他们说我成功绑定,下面是成功绑定的日志文件?如果我继续尝试执行搜索,我就不会得到任何结果。服务器在linux服务器上运行openLDAP ver 2.3.39,服务器需要在端口636上进行连接以进行安全连接,或者需要389用于匿名连接。

在代码中使用以下导入:

Imports System.DirectoryServices
Imports System.DirectoryServices.Protocols
Imports System.Data.SqlClient
Imports System.Net.NetworkCredential

我的联系:

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

我的BindLog:

  

3月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 =我的绑定,CN =用户,DC = myDomain的,DC = XXX”   方法= 128 Mar 16 15:10:17 ldap4   slapd [17391]:conn = 110555 op = 0 BIND   DN = “UID =我的绑定,CN =用户,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 =

我的搜索:

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

1 个答案:

答案 0 :(得分:0)

New DirectoryEntry("LDAP://xxx.MyDomain.xxx/cn=users,dc=MyDomain,dc=xxx",
     

“uid = my-bind,cn = users,dc = MyDomain,dc = xxx”,“MyPassword”)

您尝试使用的构造函数可能就是

Public Sub New(ByVal path As String, ByVal username As String, ByVal password As String)

但您传递的“uid = my-bind,cn = users,dc = MyDomain,dc = xxx”作为用户名。