Hi,

I am getting ClassCastException when i carry out an ldap search over an anonymous context source. it works fine when i use an authenticated context source. I have attached the code below,

your help is very much appreciated.

Code:
 LdapContextSource contextSource = new LdapContextSource();
        contextSource.setAnonymousReadOnly(true);
        contextSource.setUrl(hostUrl);
        contextSource.setBase(base);
        contextSource.setPooled(false);
        contextSource.setBaseEnvironmentProperties(new HashMap());        
        contextSource.afterPropertiesSet();

ldapTemplate   = new LdapTemplate(contextSource);
p = (Person)ldapTemplate.search(Constants.LDAP_USER_DN, filter.encode(),
                                                    new ContextMapper(){
                            public Object mapFromContext(Object ctx) {
                                DirContextOperations    context = (DirContextOperations)ctx;
                                System.out.println(context.getDn());                                 
                                return new Person(context.getAttributes());
                            }
                        });
Note: the print statement is printing the context Dn successfully.