directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Swanson <>
Subject Re: Q: LookupFilter doesn't receive useful info
Date Mon, 13 Dec 2004 22:10:24 GMT
> >I have successfully inserted my own SWLookupFilter into eve.
> This last sentence I still don't understand.   Where is this
> LookupFilter code from?  Is this code yours?  Is this a filter you're
> writing for your custom interceptors?

Oh. _my own_ SWLookupFilter. Yes, I wrote it. :-)

I changed EveContextFactory like this:

~line 480
        FilterService filterService = new FilterServiceImpl();
        SWLookupFilter swLookupFilter = new SWLookupFilter();
        SWSearchResultFilter swSearchResultFilter = new 
        interceptor = (Interceptor)filterService;

So by tapping into the FilterService interceptor, I was hoping to do the 
dynamic rewriting the query and result here. If this is the wrong spot lemme 

> >SWLookupFilter.filter(LdapContext ctx, Name dn, Attributes entry) is
> > called and I print out "dn" and "entry". I get the following:
> >
> >dn: empty
> >entry:
> >1. Apache Software Foundation
> >2. ou=system
> >3. dc=home2,dc=mark
> >4. cn=schema,ou=system
> >
> >The problem/question is this: how is it possible for SWLookupFilter to do
> > any sort of filtering or query rewriting when SWLookupFilter isn't
> > presented with the query or baseDN? perhaps the baseDN is available in
> > the LdapContext but looking at the API doesn't reveal it (to me at
> > least).
> Well I'm going to presume u are trying to write an interceptor to filter
> entries on a return for schedule world.  There really is nothing in this
> trail that says anything like that but this is the only thing I can
> think of after scratching my head here for 5 minutes.

Close, sorry for not giving enough info.

> Also note that btw a base search on the empty string DN is valid in
> LDAP.  That's a search on the root DSE.  Now this might come into the
> server if you are hitting it with a client that reads schema info.  I
> recommend this...whip out ethereal and get it to show you what's being
> sent by the client to be absolutely sure of what's happening.

I doubt it's empty as I'm explicitly specifying it. I'll whip out ethereal in 
a minute...

> You can send that to me too.  Also if you like send the filter code.
> I'll take a look at it.  BTW just to be sure ... this is your custom dev
> code and not any bug that needs to be fixed for 0.8.0 right?


public class SWLookupFilter implements LookupFilter {

    public SWLookupFilter() {
        System.out.println("DEBUG: SWLookupFilter ctor.");

    /*public void filter(LdapContext ctx, Name dn, Attributes entry)
        throws NamingException {
        filter(ctx, dn, entry);

    public void filter(LdapContext ctx, Name dn, Attributes entry, String[] 
        throws NamingException {
        filter(ctx, dn, entry);

    public void filter(LdapContext ctx, Name dn, Attributes entry)
        throws NamingException {
        Name principalDn = ((EveContext)ctx).getPrincipal().getDn();
        System.out.println("DEBUG: SWLookupFilter.filter() principalDn:" +
        System.out.println("DEBUG: SWLookupFilter.filter() Name:" +
        System.out.println("DEBUG: SWLookupFilter.filter() dn components:");
        int count = dn.size();
        for (int i=0; i < count; ++i) {
            String component = dn.get(i);
            System.out.println("DEBUG: SWLookupFilter.filter() dn component:" 
            if (component.startsWith("mozilla")) {
                dn.add(i, "super");

        NamingEnumeration ne = entry.getAll();
        for (; ne.hasMore(); ) {
            Attribute attribute = (Attribute)ne.nextElement();
            System.out.println("DEBUG: SWLookupFilter.filter() attributes:");
            int size = attribute.size();
            for (int i=0; i < size; ++i) {
                Object o = attribute.get(i);
                System.out.println("o:" + o.toString() + ", class:" +

Free SyncML-capable J2ME & J2SE replacement for Exchange and Outlook

View raw message