directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wu, James C." <James.C...@disney.com>
Subject RE: what cause InvalidCursonPositionException?
Date Thu, 18 Apr 2013 21:26:39 GMT
The following code works. But I am not sure it is the most efficient way.

                                SearchRequest searchRequest = new SearchRequestImpl();
                                Dn dn = new Dn("dc=example,dc=com");
                                searchRequest.setBase(dn);
                                searchRequest.setScope(SearchScope.ONELEVEL);
                                searchRequest.setFilter("(uid=maxUidNumber)");
                                searchRequest.addAttributes("uidNumber");
                                DirectoryService service = getDirectoryService();
                                CoreSession session = service.getAdminSession();
                                EntryFilteringCursor cursor = session.search(searchRequest);
                                cursor.beforeFirst();
                                cursor.next();
                                Entry entry = cursor.get();

james


From: dev-return-42941-James.C.Wu=disney.com@directory.apache.org [mailto:dev-return-42941-James.C.Wu=disney.com@directory.apache.org]
On Behalf Of Wu, James C.
Sent: Thursday, April 18, 2013 2:08 PM
To: Apache Directory Developers List
Subject: RE: what cause InvalidCursonPositionException?

Hi Kiran,

I added this line, but it does not help.

                searchRequest.setScope(SearchScope.OBJECT);

Basically, I just want to read an entity given its DN, is there an easier way?

Regards,

james


From: ayyagarikiran@gmail.com<mailto:ayyagarikiran@gmail.com> [mailto:ayyagarikiran@gmail.com]
On Behalf Of Kiran Ayyagari
Sent: Thursday, April 18, 2013 11:53 AM
To: Apache Directory Developers List
Subject: Re: what cause InvalidCursonPositionException?

based on your code you need to specify the scope to OBJECT level , by default the scope will
be set to ONELEVEL

On Fri, Apr 19, 2013 at 12:12 AM, Wu, James C. <James.C.Wu@disney.com<mailto:James.C.Wu@disney.com>>
wrote:
Hi Guys,

I am trying to query an attribute of a DN in my customerized authenticator that overrides
the SimpleAuthenticator.  The following is the code.

                SearchRequest searchRequest = new SearchRequestImpl();
                Dn dn = new Dn(maxUidDN);
                searchRequest.setBase(dn);
                searchRequest.addAttributes("uidNumber");
                DirectoryService service = getDirectoryService();
                CoreSession session = service.getAdminSession();
                EntryFilteringCursor cursor = session.search(searchRequest);
                cursor.beforeFirst();
                cursor.next();
                Entry entry = cursor.get();

The DN is defined as follows:

                dn: uid=maxUidNumber,dc=example,dc=com
                objectClass: top
                objectClass: account
                objectClass: extensibleObject
                uidNumber: 1000

and maxUidDN is set to "uid=maxUidNumber,dc=example,dc=com"

I keep getting the InvalidCursonPositionException at the last line of the code. I am wondering
why the cursor position can be invalid. Can anyone give me some clue? Thanks.

James



--
Kiran Ayyagari
http://keydap.com

Mime
View raw message