0

我有一种方法可以将特定用户搜索到 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 获取结果:Like '%strUserName%',但我发现只有方法FindOne()只搜索完整字符串“strUserName”,但它不执行 SQL Like 操作。任何想法我怎样才能像 SQL LIKE 一样搜索?

4

1 回答 1

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()

'这里 search & txtUserName & works SQL Like Operation objSearcher = New DirectorySearcher(objEntry, "(cn=" & txtUserName & ")") objSearcher.SearchScope = SearchScope.Base And SearchScope.OneLevel Dim result As SearchResult = search.FindOne()

于 2015-01-19T13:23:24.083 回答