You are viewing a plain text version of this content. The canonical link for it is here.
Posted to api@directory.apache.org by Narendra Kadali <na...@hotmail.com> on 2011/04/17 18:35:47 UTC

Implementing Ldap Persistent search using apache directory api

Hi All,
 
I am new to this apache directory api and there is no documentation available. I need to implement directory persistance search using this api.
 
Can any one give me sample code for implementing my scenario or any refrences for doing this.
 
Any help in this regard really appreciated.
 
Thanks,
Narendra 		 	   		  

Re: Implementing Ldap Persistent search using apache directory api

Posted by Emmanuel Lecharny <el...@gmail.com>.
On 4/18/11 9:13 AM, Narendra Kadali wrote:
> Hi Cordialement,
>
> Thanks for your reply.
>
> I need to perform this persistent search operation on Active Directory . For Active Directory OID for persistent search is 1.2.840.113556.1.4.528 which is diffrent from standard oid 2.16.840.1.113730.3.4. So how can i change defined PersistentSearchControl  OId to this new OID.

You can't. The OID is not a variable, it's used to determinate exactly 
the Control you are using.

What you can do is to use an instance of the OpaqueControl class :

          Control psearchControl = new OpaqueControl( "1.2.840.113556.1.4.528" );
          SearchRequest sr = new SearchRequestImpl();
          sr.setBase( new Dn( "ou=system" ) );
          sr.setFilter( "(objectclass=*" );
          sr.setScope( SearchScope.SUBTREE );
          sr.addControl( psearchControl );

It should work.

You can also ask for the addition of the ActiveDirectory PersistentSearch control by creating a JIRA.

PS: And again, we all thanks a lot the f*ckers at M$ who decided to use a different OID than the standard one ... :/


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com


RE: Implementing Ldap Persistent search using apache directory api

Posted by Narendra Kadali <na...@hotmail.com>.
Hi Cordialement,

Thanks for your reply.

At present I am using below code for performing persistent search.

LdapConnection connection = new LdapConnection("localhost", 389);
    connection.bind("CN=Administrator,cn=users,dc=example,dc=com", "password123");

    Control psearchControl = new PersistentSearchControl();
    SearchRequest sr = new SearchRequest();
    sr.setBaseDn("dc=orademo,dc=com");
    sr.setFilter("(objectclass=*)");
    sr.setScope(SearchScope.SUBTREE);
    sr.add(psearchControl);

    SearchCursor results = (SearchCursor) connection.search(sr);


I need to perform this persistent search operation on Active Directory . For Active Directory OID for persistent search is 1.2.840.113556.1.4.528 which is diffrent from standard oid 2.16.840.1.113730.3.4. So how can i change defined PersistentSearchControl  OId to this new OID.

Thanks,
Narendra

> Date: Sun, 17 Apr 2011 21:47:42 +0200
> From: elecharny@gmail.com
> To: api@directory.apache.org
> Subject: Re: Implementing Ldap Persistent search using apache directory api
> 
> On 4/17/11 6:35 PM, Narendra Kadali wrote:
> > Hi All,
> >
> > I am new to this apache directory api and there is no documentation available.
> The documentation effort is currently being conducted.
> 
> > I need to implement directory persistance search using this api.
> This is pretty simple.
> >
> > Can any one give me sample code for implementing my scenario or any refrences for doing this.
> Persistent search is just a normal search except that you pass the 
> PersistentSearch control with the search request.
> The search operation is explained on 
> http://directory.apache.org/api/tutorials.html.
> 
> Adding a control can be done following this sample :
> 
>          Control psearchControl = new PersistentSearchImpl();
>          SearchRequest sr = new SearchRequestImpl();
>          sr.setBase( new Dn( "ou=system" ) );
>          sr.setFilter( "(objectclass=*" );
>          sr.setScope( SearchScope.SUBTREE );
>          sr.addControl( psearchControl );
> 
>          SearchCursor results = connection.search( sr );
> 
> then process the entries.
> 
> You will also have to set the connection timeout to 0, otherwise it 
> won't last longer than 30 seconds.
> 
> Hope it helps.
> 
> -- 
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com
> 
 		 	   		  

Re: Implementing Ldap Persistent search using apache directory api

Posted by Emmanuel Lecharny <el...@gmail.com>.
On 4/17/11 6:35 PM, Narendra Kadali wrote:
> Hi All,
>
> I am new to this apache directory api and there is no documentation available.
The documentation effort is currently being conducted.

> I need to implement directory persistance search using this api.
This is pretty simple.
>
> Can any one give me sample code for implementing my scenario or any refrences for doing this.
Persistent search is just a normal search except that you pass the 
PersistentSearch control with the search request.
The search operation is explained on 
http://directory.apache.org/api/tutorials.html.

Adding a control can be done following this sample :

         Control psearchControl = new PersistentSearchImpl();
         SearchRequest sr = new SearchRequestImpl();
         sr.setBase( new Dn( "ou=system" ) );
         sr.setFilter( "(objectclass=*" );
         sr.setScope( SearchScope.SUBTREE );
         sr.addControl( psearchControl );

         SearchCursor results = connection.search( sr );

then process the entries.

You will also have to set the connection timeout to 0, otherwise it 
won't last longer than 30 seconds.

Hope it helps.

-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com