Announcement Announcement Module
Collapse
No announcement yet.
Problem with searching by OdmManager Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with searching by OdmManager

    My problem is : in the same branch of my LDAP ou=Person i can find two types of objects :
    - Internals : objectClass= internals, "inetOrgPerson", "organizationalPerson", "person", "top"
    - Externals : objectClass= internals, Externals, "inetOrgPerson", "organizationalPerson", "person", "top"

    My question is : how can i configure a managedClass "Personnes" where I can search both Internals and Externals ?
    In other words, is it possible to make an OdmManager.search() without filtering all objectClasses ?

    Is it possible with Spring LDAP 1.3.1 ?

  • #2
    Originally posted by elricco View Post
    My problem is : in the same branch of my LDAP ou=Person i can find two types of objects :
    - Internals : objectClass= internals, "inetOrgPerson", "organizationalPerson", "person", "top"
    - Externals : objectClass= internals, Externals, "inetOrgPerson", "organizationalPerson", "person", "top"

    My question is : how can i configure a managedClass "Personnes" where I can search both Internals and Externals ?
    In other words, is it possible to make an OdmManager.search() without filtering all objectClasses ?

    Is it possible with Spring LDAP 1.3.1 ?
    I side-stepped the problem. In the odmManager it adds all the objectClasses to the filter (wether you want it to or not) so you either get the one object or the other.

    The odmManager is final but I just made my own version of it, removing the parts where it automatically adds the Objectclasses to the filter - it's then up to you what objectclasses go into the filter. (it also check later in the code to make sure the object classes retured are the same the objects declared- so I had to amend that too).

    It's worked fine for me.

    so in the odmManagerImpl change:

    public <T> List<T> search(Class<T> managedClass, Name base, String filter, SearchControls scope) {
    EntityData entityData=getEntityData(managedClass);

    // Add a filter so we only read the object class we can deal with
    String finalFilter = filter;
    // String finalFilter = entityData.ocFilter;
    // if (filter != null && filter.length() != 0) {
    // StringBuilder fixedFilter = new StringBuilder();
    // fixedFilter.append("(&(").append(filter).append(") ").append(entityData.ocFilter).append(")");
    // finalFilter = fixedFilter.toString();
    // }

    and in the GenericContextMapper method...

    // If this is the objectclass attribute then check that values correspond to the metadata we have
    // for the Java representation
    Attribute ocAttribute = attributeValueMap.get(OBJECT_CLASS_ATTRIBUTE_CI);
    if (ocAttribute != null) {
    // Get all object class values from the JNDI attribute
    Set<CaseIgnoreString> objectClassesFromJndi = new HashSet<CaseIgnoreString>();
    NamingEnumeration<?> objectClassesFromJndiEnum = ocAttribute.getAll();
    while (objectClassesFromJndiEnum.hasMoreElements()) {
    objectClassesFromJndi.add(new CaseIgnoreString((String)objectClassesFromJndiEnum .nextElement()));
    }
    // OK - checks its the same as the meta-data we have
    // if (!objectClassesFromJndi.equals(metaData.getObjectC lasses())) {
    // // The items found has classes in addition to those searched for - so ditch it
    // return null;
    // }

    I had to create my own factory for this and then declare it in the config files:

    Hope it helps,

    oh, yes - this was in 1.3.1

    R.


    // Search from the root if we are not told where to search from
    Name localBase = base;

    Comment

    Working...
    X