【问题标题】:LDAP Authentication The specified domain either does not exist or could not be contactedLDAP 身份验证 指定的域不存在或无法联系
【发布时间】:2013-01-25 16:30:39
【问题描述】:

我收到以下错误

{"指定的域不存在或不能 联系了。 "}

排队

 Dim adResults = adSearch.FindOne.Path

谁能说明为什么会这样?看到下面的代码

Dim ID As FormsIdentity = DirectCast(User.Identity, FormsIdentity)
    Dim ticket As FormsAuthenticationTicket = ID.Ticket
    Dim adTicketID As String = ticket.Name
    Dim adSearch As New DirectorySearcher
    adSearch.Filter = ("(userPrincipalName=" & adTicketID & ")")
    Dim adResults = adSearch.FindOne.Path
    Dim adResultsDirectory As New DirectoryEntry(adResults)
    Dim found As Boolean = False
    For Each entry In adResultsDirectory.Properties("memberOf")
        Response.Write(entry)
        Response.Write("<br/>")
        If entry = "CN=GroupName,CN=UserGroup,DC=my,DC=domain,DC=com" Then
            found = True
        End If

    Next
    If Not (found) Then
        Response.Redirect("login.aspx")
    End If

【问题讨论】:

    标签: asp.net vb.net exception com ldap


    【解决方案1】:

    您的域在哪里指定? DirectoryEntry 的第一个参数应该是您的 AD 服务器,如下所示:LDAP://adserver

    这是我用来检查用户是否在 AD 中经过身份验证的代码:

    Dim dsDirectoryEntry As New DirectoryEntry("LDAP://" & domain, userName, password)
    
    Dim dsSearch As New DirectorySearcher(dsDirectoryEntry)
    Dim dsResults As SearchResult = dsSearch.FindOne()
    
    If dsResults IsNot Nothing Then
        Return True
    Else
        Return False
    End If
    

    我正在从配置中读取的域,用户名和密码来自登录表单输入。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-08
      • 2021-08-04
      相关资源
      最近更新 更多