我真的很歡迎這個問題的一些幫助。我們有一個可以工作並連接到LDAP的php代碼。當我嘗試使用VB.NET 2010進行連接時,它無法綁定登錄失敗未知用戶名或密碼錯誤。以下是連接信息。當我與運行ldap服務器的人交談時,他們說我已經成功綁定了,下面是成功綁定的日誌文件?如果我繼續並嘗試執行搜索,我不會得到任何結果。服務器在Linux服務器上運行openLDAP ver 2.3.39,服務器需要連接端口636以進行安全連接,或者需要389端口進行匿名連接。VB.NET連接到LDAP失敗未知的用戶名或密碼錯誤
在代碼中使用下列進口:
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:
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=
我的搜索:
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
如果我對以下內容進行更改,將收到以下錯誤: – Toads 2011-03-23 15:58:38
如果我對Dim dirEntry進行更改爲DirectoryEntry = New DirectoryEntry(「LDAP://xxx.myDomain.xxx/cn=users,dc=myDomain ,dc = xxx「,」my-bind「,」myPassword「)我得到以下錯誤:指定了無效的dn語法。 – Toads 2011-03-23 16:03:17
如果我將我的dn更改爲path =(「LDAP://xxx.myDomain.xxx:636:/ cn = users,dc = myDomain,dc = xxx」,「myBind」,「myPassword」)我將得到的錯誤登錄失敗,或者連接到系統的設備不再起作用。 – Toads 2011-03-23 16:13:02