Announcement Announcement Module
No announcement yet.
Attribute.get() method only can be cast to String ? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Attribute.get() method only can be cast to String ?

    Greetings all,

    now that I've got a working locator, I'm having trouble with the get() method of Attribute - it doesn't seem to want to be cast to anything other than String.

    In my LDAP objectClass I have an attribute "isEnabled" that uses an attributeType of boolean. I have a corresponding private Boolean member declared in class EventConfig with a getter/setter pair defined.

    so in my java
            String hardcode ="cn=cut,ou=knot,ou=auditLogger,dc=jpost3,dc=dev,dc=abccorp,dc=com";
            result = (EventConfig) ldapTemplate.lookup( hardcode, new EventConfigAttributesMapper() );
        private class EventConfigAttributesMapper implements AttributesMapper {
            public Object mapFromAttributes(Attributes attrs) throws NamingException {
                EventConfig ec = new EventConfig();
    //          Attribute kver = attrs.get("isEnabled");
    //          if( kver != null) ec.setIsEnabled( (Boolean)attrs.get("isEnabled").get());
                return ec;
    the program runs fine and returns the object from LDAP when the lines in the mapper are commented out as shown. But uncommenting causes the lookup to fail .

    LDAP object classes can be made up of attributes with a wide array of attribute types besides String - can't Spring's Attribute.get() method handle these?


    Still-learning Stuart

  • #2
    You said it fails, can you post the error that you're seeing when it fails?