我无法使用LDAP成功验证ASP.NET Web应用程序的用户 . 我已经在我们自己的网络上针对Active Directory这样做了,但这是针对我们网络之外的服务器,即OID(Oracle Internet Directory) .
通常,我使用以下代码没有问题 .
Dim myDirectoryEntry As New System.DirectoryServices.DirectoryEntry("LDAP://1.2.3.4:999/OU=SomeOU,DC=Something,DC=com")
myDirectoryEntry.AuthenticationType = System.DirectoryServices.AuthenticationTypes.Sealing
myDirectoryEntry.AuthenticationType = System.DirectoryServices.AuthenticationTypes.Secure
Try
myDirectoryEntry.Username = txtUserID.Text.Trim
myDirectoryEntry.Password = txtPassword.Text.Trim
Dim mySearcher As New System.DirectoryServices.DirectorySearcher(myDirectoryEntry)
mySearcher.Filter = ("(anr= " & txtUserID.Text & ")")
Dim result As System.DirectoryServices.SearchResult = mySearcher.FindOne
Catch ex As Exception
'failed log in handling
End Try
对于这个应用程序,我将反对我们网络外的目录,上述方法失败(服务器不支持请求的身份验证方法 . ) .
我可以使用以下命令成功绑定到LDAP服务器:
Dim serverName As String = "1.2.3.4:999"
Dim dn As String = "cn=somename,cn=users,dc=something,dc=gov"
Dim ServerCon As New LdapConnection(serverName)
ServerCon.AuthType = AuthType.Basic
Dim cred As New System.Net.NetworkCredential(dn, "password")
ServerCon.Bind(cred)
之后,我找不到用密码验证用户登录信息的方法,然后撤回一些信息 .