On Mon, Sep 22, 2014 at 8:02 PM, Sebastian Oerding <
[email protected]> wrote:
> Hello again,
>
> I tried to use an embedded Apache DS with a self written interceptor as
> (kind of) a proxy. Actually I have to "parse" incoming requests to request
> the desired data from a database. However I'm struggling doing so.
>
> 1) I do not get the complete request if parsing the request, for example
> when requesting
> "(&(objectClass=smpki)(cn=ABC))"
> and using the SearchContext in
> @Override
> public EntryFilteringCursor search(SearchOperationContext
> searchContext) { ... }
> I get the DN "ou=certificates,dc=smpki" by searchContext.getDn(). However
> I do not manage to get the searchfilter from the request (I checked the
> RequestControls and ResponseControls of the SearchContext) and do not havy
> any idea what to do next. Can someone please provide any hint on how to get
> the search filter?
>
> call searchContext.getFilter() to get the filter in object form, call
toString() on it if you want to see it as a string.
Note that this method should be called before calling super.search()
otherwise you will get a annotated filter
that is not syntactically correct for parsing later.
> 2) I simply started the embedded server using the following code (some
> unimportant lines adding my self-written interceptor omitted):
>
> DefaultDirectoryServiceFactory factory = new
> DefaultDirectoryServiceFactory();
> factory.init(INSTANCE_NAME);
> this.directoryService = factory.getDirectoryService();
> this.directoryService.getChangeLog().setEnabled(false);
> this.directoryService.setShutdownHookEnabled(true);
> InstanceLayout il = new InstanceLayout(INSTANCE_PATH);
> this.directoryService.setInstanceLayout(il);
>
> this.ldapService = new LdapServer();
> this.ldapService.setTransports(new TcpTransport(this.host,
> this.port));
> this.ldapService.setDirectoryService(this.directoryService);
>
> When I let the JUnit test run my interceptor is invoked as expected.
> However I got the following exception:
>
> javax.naming.NamingException: [LDAP: error code 80 - OTHER: failed for
> MessageType : SEARCH_REQUEST
> Message ID : 2
> SearchRequest
> baseDn : 'ou=certificates,dc=smpki'
> filter : '(&(objectClass=smpki)(cn=033e07c49e8af56994859466bebfaa
> 9057a36924))'
> scope : whole subtree
> typesOnly : false
> Size Limit : no limit
> Time Limit : no limit
> Deref Aliases : deref Always
> attributes :
> org.apache.directory.api.ldap.model.message.SearchRequestImpl@4f08934e
> ManageDsaITImpl Control
> Type OID : '2.16.840.1.113730.3.4.2'
> Criticality : 'false'
> '
> : null]; remaining name 'ou=certificates,dc=smpki'
> at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3111)
> ....
>
> Is this a problem with the configuration of the embedded Apache DS? Doch I
> need an instance layout which conforms to the request?
>
> hard to tell without seeing your code, but this issue is not related to
instance layout.
> With regards
> Sebastian
>
--
Kiran Ayyagari
http://keydap.com