locked
get users from ou ? RRS feed

  • Question

  • User-2053568834 posted

    Hi

    Dim oRoot As DirectoryEntry = New DirectoryEntry("LDAP://OU=IT,OU=Abosaleh,dc=zct,dc=local")
    
            Dim oSearcher As DirectorySearcher = New DirectorySearcher(oRoot)
            oSearcher.Filter = "(objectClass=user)"
            oSearcher.SearchScope = SearchScope.Subtree
            Dim oResults As SearchResultCollection
            Dim oResult As SearchResult
    
            oSearcher.PropertiesToLoad.Add("cn")
            oResults = oSearcher.FindAll
    
            For Each oResult In oResults
                TextBox5.Items.Add(oResult.GetDirectoryEntry().Properties("cn").Value)
            Next

    this is my code run and get result

    Dim oRoot As DirectoryEntry = New DirectoryEntry("LDAP://OU=IT,dc=zct,dc=local")

    and this get result

    Dim oRoot As DirectoryEntry = New DirectoryEntry("LDAP://OU=Abosaleh,dc=zct,dc=local")

    but when use two ou same this code

    Dim oRoot As DirectoryEntry = New DirectoryEntry("LDAP://OU=IT,OU=Abosaleh,dc=zct,dc=local")

    no result ??

    Sunday, November 12, 2017 5:48 AM

All replies