【问题标题】:How to search Single user From LADP:如何从 LADP 搜索单个用户:
【发布时间】:2015-01-16 17:26:12
【问题描述】:

我有一种方法可以将特定用户搜索到 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 一样搜索?

【问题讨论】:

    标签: findall adam


    【解决方案1】:

    效果很好:

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

    'here search & txtUserName & works SQL Like 操作 objSearcher = 新 DirectorySearcher(objEntry, "(cn=" & txtUserName & ")") objSearcher.SearchScope = SearchScope.Base 和 SearchScope.OneLevel 暗淡结果 As SearchResult = search.FindOne()

    【讨论】:

      猜你喜欢
      • 2016-09-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-10
      • 1970-01-01
      • 2020-12-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多