[ 
https://issues.apache.org/jira/browse/DIRSERVER-2371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17571354#comment-17571354
 ] 

Emmanuel Lécharny commented on DIRSERVER-2371:
----------------------------------------------

Ok, so I tested such a search on M27 branch:
{code:java}
    @Test
    public void testSearchWithTop() throws Exception
    {
        SearchControls controls = new SearchControls();
        controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
        controls.setDerefLinkFlag( false );
        sysRoot.addToEnvironment( 
JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, 
AliasDerefMode.NEVER_DEREF_ALIASES
            .getJndiValue() );
        HashMap<String, Attributes> map = new HashMap<String, Attributes>();

        NamingEnumeration<SearchResult> list = sysRoot.search( "", 
"(&(objectClass=top)(objectClass=person)"
            + 
"(objectClass=organizationalPerson)(objectClass=inetOrgPerson)(cn=si*))", 
controls );

        while ( list.hasMore() )
        {
            SearchResult result = list.next();
            map.put( result.getName(), result.getAttributes() );
        }

        list.close();

        assertEquals( 1, map.size(), "Expected number of results returned was 
incorrect!" );
        assertTrue( map.containsKey( "cn=with-dn,ou=system" ) );
    }

{code}

The data contains this entry:

{code}
        dn: cn=with-dn, ou=system
        objectClass: top
        objectClass: person
        objectClass: organizationalPerson
        objectClass: inetorgPerson
        cn: singer
        sn: manager
        telephoneNumber: 123456
       manager: cn=Heather Nova, ou=system
{code}
 
and the test passes green.

I'll have to check on 2.0.0-M26

> Inclusion of 'top' objectclass in searches yields no results
> ------------------------------------------------------------
>
>                 Key: DIRSERVER-2371
>                 URL: https://issues.apache.org/jira/browse/DIRSERVER-2371
>             Project: Directory ApacheDS
>          Issue Type: Bug
>          Components: search
>    Affects Versions: 2.0.0.AM26
>         Environment: Windows
>            Reporter: Carlo Accorsi
>            Priority: Minor
>
> Hi, it's been a while since I've posted here and I hope this note finds you 
> all well. 
> We stayed on a very old ApacheDS version (M17) for many years and have 
> finally moved to AM26. 
> Many of our queries for users, groups, etc logically AND objectclasses with 
> the search criteria. We do this to limit the types of entries that are 
> returned in a particular search. For example to find users with CN's starting 
> with 'A' the query would look like this. 
> (&
> (objectClass=top)
> (objectClass=person)
> (objectClass=organizationalPerson)
> (objectClass=inetOrgPerson)
> (cn=A*)
> )
> This query works in M17, but not AM26. 
> If I remove the 'top' value from the query as shown below, it works. I'm 
> assuming because it's abstract. 
> (&
> (objectClass=person)
> (objectClass=organizationalPerson)
> (objectClass=inetOrgPerson)
> (cn=A*)
> )
> We define objectclasses of entry types in a configuration file. So we easily 
> fixed our queries by removing 'top' from the config file. However we have  
> functions like isUser, isGroup, isEquipment , etc that take an Entry and 
> compare the equality of its objectclass array with values defined in the 
> configuration file. This introduced a breaking change for us - which isn't 
> horrible and we can fix. However, I'm just wondering if it was intentional to 
> return no results when the top objectclass is present in the query?
> Thanks!
> Carlo
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to