0
我一直在使用此功能从他们的用户名(我的所有用户都在同一个域中)找到用户的电子邮件地址没有问题,但现在一些用户有已经升级到Windows 10,我得到一个错误:LDAP服务器不可操作错误在Windows 10上发生只有
The server is not operational
我已经修改了我的代码参照这个问题,答案,所以现在我拿起默认命名上下文,但错误依然存在: System.DirectoryServices - The server is not operational
Public Function UserEmail(ByRef Username As String) As String
UserEmail = ""
Dim deRoot As New DirectoryServices.DirectoryEntry("LDAP://RootDSE")
If Not deRoot Is DBNull.Value Then
Dim defaultNamingContext As String = deRoot.Properties("defaultNamingContext").Value.ToString()
Dim path As String
path = "LDAP://" & defaultNamingContext
Dim entry As New DirectoryServices.DirectoryEntry(Path)
Dim search As New DirectoryServices.DirectorySearcher(entry)
search.Filter = "(&(objectClass=user)(anr=" + Username + "))"
search.PropertiesToLoad.Add("mail")
Dim result As DirectoryServices.SearchResult
result = search.FindOne
If IsDBNull(result) Then
UserEmail = ""
Else
UserEmail = result.Properties("mail")(0)
End If
End If
Return UserEmail
End Function
该代码工作正常,我的用户使用Windows 7和8的地方。
有什么建议吗?
此代码是否在每个用户的计算机上运行? –
是的,它在Windows 7和8中可以正常工作,但在Windows 10中出错。它将电子邮件发送给其他用户,该用户名已保存在数据库中。 – DovesandChicks
这些Windows 10计算机是否与Windows 7/8相同? –