You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Trustin Lee <tr...@gmail.com> on 2005/06/30 04:35:42 UTC

[apacheds] A question on return values of ContextPartition.list(Name)

Hi,
 JNDI API doc says the return value of Context.list(Name) is 
NamingEnumeration<NameClassPair>, but it seems ContextPartition.list(Name) 
returns NamingEnumeration<SearchResult>. Is this behavior correct?
 Another question, I want to retrieve the whole attributes of all decendant 
entries under a base name (it would be nice if the result includes the base 
entry itself, too). How can I do that?
 Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/

Re: [apacheds] A question on return values of ContextPartition.list(Name)

Posted by Trustin Lee <tr...@gmail.com>.
2005/6/30, Trustin Lee <tr...@gmail.com>: 
> 
> Another question, I want to retrieve the whole attributes of all decendant 
> entries under a base name (it would be nice if the result includes the base 
> entry itself, too). How can I do that?
> 
 I found the solution after some trials and errors:
  SearchControls ctrl = new SearchControls();
ctrl.setSearchScope( SearchControls.SUBTREE_SCOPE ); 
NamingEnumeration e = nexus.search( new LdapName( "uid=admin,ou=system"), 
factoryCfg.getEnvironment(), new PresenceNode( "objectClass" ), ctrl );
while( e.hasMore() )
{
SearchResult sr = ( SearchResult ) e.next();
System.out.println( "Name: " + sr.getName() + ", Attrs: " + sr.getAttributes() 
);
}
 Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/

Re: [apacheds] A question on return values of ContextPartition.list(Name)

Posted by Alex Karasulu <ao...@bellsouth.net>.
Trustin Lee wrote:

> Hi,
>  
> JNDI API doc says the return value of Context.list(Name) is 
> NamingEnumeration<NameClassPair>, but it seems 
> ContextPartition.list(Name) returns NamingEnumeration<SearchResult>.  
> Is this behavior correct?

Yes it is correct because a SearchResut inherits from Binding which is 
derived from a NameClassPair.  Heirarchical namespaces often return a 
SearchResult while flat namespaces return Bindings and NameClassPairs.  
It's just a matter of specialization.

>  
> Another question, I want to retrieve the whole attributes of all 
> decendant entries under a base name (it would be nice if the result 
> includes the base entry itself, too).  How can I do that?

The scope parameter can be used to control the search.  One level scope 
to list the children of a base entry does not return the base.  This is 
part of the LDAP specifications so we cannot change this.  You will have 
to use subtree scope which will include the base.

Alex