Results 1 to 2 of 2

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

  1. #1
    Join Date
    May 2011
    Posts
    10

    Default 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
    Code:
            String hardcode ="cn=cut,ou=knot,ou=auditLogger,dc=jpost3,dc=dev,dc=abccorp,dc=com";
            result = (EventConfig) ldapTemplate.lookup( hardcode, new EventConfigAttributesMapper() );
         .....
        //creator
        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?


    TIA,

    Still-learning Stuart

  2. #2
    Join Date
    Oct 2009
    Posts
    14

    Default

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •