LDAP:服务器无法用于 VB.NET Winforms 应用程序

问题描述 投票:0回答:1

我们有一个使用LDAP来获取用户基本信息的应用程序。多年来它一直运行良好。我们还有一个测试应用程序可以成功连接到 LDAP,除非您执行 Clean Solution;然后它会失败并显示服务器无法运行。从干净的状态恢复文件,它又可以工作了。此外,当我们发布应用程序时,用户会看到此错误。用户将在一段时间内(1-2 天)收到该错误消息,然后它会突然开始工作。

其他一些背景;我们提升了两个新的 DC,降级了两个,这就是问题开始的时候。 LDP.exe 连接得很好。当连接失败时,Wireshark 显示“LDAP ping”并且没有其他 LDAP 通信。成功时,Wireshark 显示 SASL/GSSAPI 连接。

测试应用程序的代码片段。

        Dim ident As WindowsIdentity = WindowsIdentity.GetCurrent()
        Dim username As String = ident.Name.Substring(ident.Name.IndexOf("\") + 1)
        Dim protocol As String = "LDAP"
        Dim path As String = "domain.com"
        Dim sResult As SearchResult = Nothing
        Dim ldapPath As String = If(String.IsNullOrEmpty(path), String.Format("{0}:", protocol), String.Format("{0}://{1}", protocol, path))
        Using de As New DirectoryEntry(ldapPath)
            Try
                If de.Properties.Count > 0 Then
                    Using adSearch As New DirectorySearcher(de)
                        adSearch.Filter = String.Format("(&(objectClass=user)(sAMAccountName={0}))", username)
                        sResult = adSearch.FindOne()
                    End Using
                End If
            Catch ex As Exception
                Label1.Text = ex.Message
                
            End Try
        End Using
        Return sResult

这听起来与我们的问题非常相似,但通过重新启动修复了它。 VB.NET LDAP 身份验证错误:“服务器无法运行”

vb.net winforms active-directory ldap
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.