Search code examples
springldapalfresco

provide custom namespace while configuring Alfresco LDAP integration


I have an Alfresco Community 5.2 installation with ldap-ad users/group syncrhonization and all works well.

Now I have to add an aspect with some properties and let ldap handle them, adding them to the cm:person. So I have customized the common-ldap-context.xml as suggested here but I've only managed it to work overriding the original Alfresco content model, using the cm: prefix as aspect/property namespace.

If I use my personal model prefix, whenever I start Alfresco up, I receive "unkown namespace" error from spring loading common-ldap-context.xml file.

How can I import my namespace into that file? Is it possible I have to use the cm: prefix necessarily?

Here is my common-ldap-context.xml fragment

<property name="personAttributeMapping">
    <map>
        <!-- ... -->
        <entry key="myc:prop1">
           <value>${ldap.synchronization.prop1</value>
        </entry>
        <entry key="myc:prop2">
            <value>${ldap.synchronization.prop2</value>
        </entry>
        <entry key="myc:prop3">
           <value>${ldap.synchronization.prop3</value>
        </entry>
        <entry key="myc:prop4">
            <value>${ldap.synchronization.prop4</value>
        </entry>
        <!-- ... -->
    </map>
</property>

The personAttributeMapping, inside common-ldap-context.xml, is placed in path Alfresco/tomcat/shared/classes/alfresco/extension/Authentication/ldap-context.xml. The custom document model is defined in bean component, loaded from in bootstrap.context.xml

Thanks.


Solution

  • I got it working defining the required bean hint depends-on="..." (of course using your bean name loading the model).

    So my custom-ldap-context.xmlin extension/subsystems/Authentication/ldap-ad/ldap-ad1 (folder depends on your configured subsystem) looks like:

    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
    <!--
       Bean definitions shared by the ldap and ldap-ad subsystems
    -->
    
    <beans>
    
       <!-- Regularly exports user and group information from LDAP -->
    
            <bean id="ecm4u.personDetails.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
                    <property name="models">
                            <list>
                                    <value>alfresco/extension/personDetails.xml</value>
                            </list>
                    </property>
            </bean>
    
    <bean id="userRegistry" class="org.alfresco.repo.security.sync.ldap.LDAPUserRegistry" depends-on="ecm4u.personDetails.dictionaryBootstrap">
    
    <!-- snap -->
    
          <property name="personAttributeMapping">
             <map>
    
    <!-- snap -->
    
               <!-- BEGIN New properties -->
                <entry key="pd:employeeNumber">
                   <value>${ldap.synchronization.userEmployeeNumberAttributeName}</value>
                </entry>
                <!-- END New properties -->
    
    <!-- snap -->