Home > Archive > LDAP > July 2006 > Obtaining ldap query's results count
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Obtaining ldap query's results count
|
|
| amos_s12@zahav.net.il 2006-07-06, 4:02 am |
| Hello,
Following to my previous topic, I've got an answer that I can use
the method
$mesg->count() in order to obtain the query's result count.
I would like to know, how can I join this method in the following
code:
...
String dirStr = <certain value>
searchControls.setReturningObjFlag(false);
searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
searchControls.setReturningAttributes(retAtt);
searchControls.setCountLimit(countLimit_No_Limit);
StringBuffer filter = new StringBuffer();
filter.append("(&(objectclass=<a certain object class> )");
filter.append("(");
filter.append("certain field=");
filter.append(<certain value> );
filter.append("))");
NamingEnumeration answer = context.search(dirStr, filter.toString(),
searchControls);
if (!answer.hasMore()) {
return 0l;
}
int resultsNumbert = 0;
while (answer.hasMoreElements()) {
SearchResult searchResult = (SearchResult)answer.next();
resultsNumbert++;
}
....
return resultsNumbert;
Here I count the results myself . What I would like to know, is how
to use the method :
$mesg->count() in order to get the results count
Thank you in advance for your answer
| |
| Chris Ridd 2006-07-06, 7:04 pm |
| On 6/7/06 8:10, amos_s12@zahav.net.il <amos_s12@zahav.net.il> wrote:
> Hello,
>
> Following to my previous topic, I've got an answer that I can use
> the method
> $mesg->count() in order to obtain the query's result count.
>
> I would like to know, how can I join this method in the following
> code:
> ...
> String dirStr = <certain value>
> searchControls.setReturningObjFlag(false);
> searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
> searchControls.setReturningAttributes(retAtt);
> searchControls.setCountLimit(countLimit_No_Limit);
>
> StringBuffer filter = new StringBuffer();
>
> filter.append("(&(objectclass=<a certain object class> )");
>
> filter.append("(");
> filter.append("certain field=");
> filter.append(<certain value> );
> filter.append("))");
>
>
> NamingEnumeration answer = context.search(dirStr, filter.toString(),
> searchControls);
>
>
> if (!answer.hasMore()) {
> return 0l;
> }
>
> int resultsNumbert = 0;
> while (answer.hasMoreElements()) {
> SearchResult searchResult = (SearchResult)answer.next();
> resultsNumbert++;
> }
> ...
> return resultsNumbert;
>
>
> Here I count the results myself . What I would like to know, is how
> to use the method :
> $mesg->count() in order to get the results count
>
> Thank you in advance for your answer
The code you posted was written in (what looks like) Java. Net::LDAP is
written in perl.
You need to ask your question on a Java list!
Cheers,
Chris
|
|
|
|
|