check whether an attribute(like sn, cn) is existing in a OU without Search

I want to check whether an attribute(like sn,mail) is exixting some where in a User URl. Right now I am doing like this. I am doing a setReturningAttributes(sn) and will do a search which will return a naming enumeration. If the namingEnumeration is not null(has atleast one record), then the attribute is valid. But this search will take some time to finish if the OU has many users and groups. So Is there any way to identify an attribute is existing or not in a user URL or user URL. without performanc hindrance. ie a way without doing a search.

your suggestions will help

Thanks in advance

[613 byte] By [Mathewhaia] at [2007-11-27 0:42:17]
# 1
You can specify a size limit constraint not to return more than 1 entry (or 2).This will stop the search once an entry (or 2) has been returned. But will also return an LDAP error (size limit exceeded).Regards,Ludovic
ludovicpa at 2007-7-11 22:56:43 > top of Java-index,Core,Core APIs...
# 2
Thanks man,but this is the way i am doing. i set the count limit as 1. but then the attribure exists in the 4th record or 5th record. So what can I do then.
Mathewhaia at 2007-7-11 22:56:43 > top of Java-index,Core,Core APIs...
# 3

I've watched this post for a while, thinking whether there is a polite way of answering it.

Unfortunately I couldn't find a "LDAP for Dummies", seems like the closest I could find was "Active Directory for Dummies" which you can buy at Amazon, http://www.amazon.com/Active-Directory-Dummies-Marcia-Loughry/dp/0764506595/ref=pd_bbs_sr_2/103-5171893-5510229?ie=UTF8&s=books&qid=1176496954&sr=8-2

So you want to find out whether any objects have a value for either the cn or mail attribute without having to retrieve every object and iterate through each result to determine whether they contain a value for cn or mail.

If you issued a query something like:(|(mail=*)(cn=*))

it will only return objects that have a value for cn or mail.

adler_stevena at 2007-7-11 22:56:43 > top of Java-index,Core,Core APIs...
# 4

Thanks adler_steven,

But again, this is still a search, this will go down to the subtrees, search all the users with the attributes. It will take long for Bulk data. For some 10000 users, a search like that will take 40 seconds.I can make it a search with countLimit as one, but then if the attribute exists in the second record, then ? So Is there any direct way to see whether an attribute like cn or mail is valid or not.

danx,

Mathew

Mathewhaia at 2007-7-11 22:56:43 > top of Java-index,Core,Core APIs...