我有一个将特定用户搜索到ADAM的方法。
'set up the LDAP entry object
objEntry = New DirectoryEntry("LDAP://" & m_strLDAPServer & ":" & m_strLDAPPort & "/" & m_strLDAPEntry)
is the default but it must be set explicitly so that the props array can be passed in
objSearcher = New DirectorySearcher(objChild, "(objectClass=*)", strProps)
objSearcher.SearchScope = SearchScope.Base
objSearcher = New DirectorySearcher(objChild, "(objectClass=*)", strProps)
objSearcher.SearchScope = SearchScope.Base
'carry out the search
Try
objResult = objSearcher.FindOne()
Catch
objResult = Nothing
End Try
我想从ADAM获得结果 SQL:喜欢'%strUserName%' ,但我发现只有方法 FindOne()才会搜索完整的字符串" strUserName&#34 ;,但它不执行SQL Like操作。 任何想法如何像SQL LIKE一样搜索?
答案 0 :(得分:0)
它的工作正常:
eobjEntry = New DirectoryEntry("LDAP://" & m_strLDAPServer & ":" & m_strLDAPPort & "/" & "cn=" & txtUserName & "," & m_strLDAPEntry)
'set the user name and password, if necessary
Dim search As New DirectorySearcher()
'这里搜索& txtUserName&适用于SQL Like Operation objSearcher = New DirectorySearcher(objEntry,“(cn =”& txtUserName&“)”) objSearcher.SearchScope = SearchScope.Base和SearchScope.OneLevel 昏暗的结果As SearchResult = search.FindOne()