cancel
Showing results for 
Search instead for 
Did you mean: 

LDAP sync and user with empty homespace

luba_s
Champ in-the-making
Champ in-the-making
Hello, i'm facing the problem with LDAP import task. I have succesfully configured task to import users and groups from Active Directory and everything seems to be OK until I tried to login with imported user.
Following frontend exception is throw:


Caused by: java.lang.NullPointerException
        at org.alfresco.repo.domain.NodeKey.<init>(NodeKey.java:44)
        at org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl.getNodeStatus(HibernateNodeDaoServiceImpl.java:314)
        at org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl.getNode(HibernateNodeDaoServiceImpl.java:413)
        at sun.reflect.GeneratedMethodAccessor81.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
        at org.alfresco.repo.transaction.TransactionalDaoInterceptor.invoke(TransactionalDaoInterceptor.java:60)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
        at $Proxy1.getNode(Unknown Source)
        at org.alfresco.repo.node.db.DbNodeServiceImpl.exists(DbNodeServiceImpl.java:135)
        at sun.reflect.GeneratedMethodAccessor141.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.alfresco.repo.service.StoreRedirectorProxyFactory$RedirectorInvocationHandler.invoke(StoreRedirectorProxyFactory.java:213)
        at $Proxy2.exists(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor141.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335)


I found that mandatory "home space" attribute of each imported users is missing. I tried some changes in configuration (companyHomeFolderProvider) but without success. Could anybody help me? Thanks

Here is my LDAP config:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
     
    <!– 
    This bean is used to support general LDAP authentication. It is also used to provide read only access to users and groups
    to pull them out of the LDAP reopsitory  
    –>
  
    <bean id="ldapInitialDirContextFactory" class="org.alfresco.repo.security.authentication.ldap.LDAPInitialDirContextFactoryImpl">
        <property name="initialDirContextEnvironment">
            <map>
                <!– The LDAP provider –>
                <entry key="java.naming.factory.initial">
                    <value>com.sun.jndi.ldap.LdapCtxFactory</value>
                </entry>
              
                <!– The url to the LDAP server –>
                <entry key="java.naming.provider.url">
                    <value>ldap://ibmserver:389</value>
                </entry>
              
                <!– The authentication mechanism to use      –>
                <!– Some sasl authentication mechanisms may require a realm to be set –>
                <!–                java.naming.security.sasl.realm –>
                <!– The available options will depend on your LDAP provider –>
                <entry key="java.naming.security.authentication">
                    <value>simple</value>
                </entry>
              
                <!– The id of a user who can read group and user information –>
                <!– This does not go through the pattern substitution defined above and is used "as is" –>
                <entry key="java.naming.security.principal">
                    <value>cn=Jet Speed,ou=Jetspeed,ou=beez,DC=Company,DC=com</value>
                </entry>
              
                <!– The password for the user defined above –>
                <entry key="java.naming.security.credentials">
                    <value>Asdfghjkl1234</value>
                </entry>
            </map>
        </property>
    </bean>
  
    <!– Ldap Syncronisation support –>
  
    <!–
      
    There can be more than one stack of beans that import users or groups. For example, it may be easier
    to have a version of ldapPeopleExportSource, and associated beans, for each sub-tree of your ldap directory
    from which you want to import users. You could then limit users to be imported from two or more sub tress and ignore
    users found else where. The same applies to the import of groups.
        
    The defaults shown below are for OpenLDAP.  
      
    –>
      
  
    <!– Extract user information from LDAP and transform this to XML –>
    
    <bean id="ldapPeopleExportSource" class="org.alfresco.repo.security.authentication.ldap.LDAPPersonExportSource">
        <!–
        The query to select objects that represent the users to import.
      
        For Open LDAP, using a basic schema, the following is probably what you want:
        (objectclass=inetOrgPerson)
      
        For Active Directory:
        (objectclass=user)
        –>
        <property name="personQuery">
            <value>(objectclass=organizationalPerson)</value>
        </property>
      
        <!–
        The seach base restricts the LDAP query to a sub section of tree on the LDAP server.
        –>
        <property name="searchBase">
            <value>cn=Users,dc=Company,dc=com</value>
        </property>
      
        <!–
        The unique identifier for the user.
      
        THIS MUST MATCH WHAT THE USER TYPES IN AT THE LOGIN PROMPT  
      
        For simple LDAP authentication this is likely to be "cn" or, less friendly, "distinguishedName"
      
        In OpenLDAP, using other authentication mechanisms "uid", but this depends on how you map
        from the id in the LDAP authentication request to search for the inetOrgPerson against which
        to authenticate.
      
        In Active Directory this is most likely to be "sAMAccountName"
      
        This property is mandatory and must appear on all users found by the query defined above.
      
        –>
        <property name="userIdAttributeName">
            <value>sAMAccountName</value>
        </property>
      
        <!– Services –>
        <property name="LDAPInitialDirContextFactory">
            <ref bean="ldapInitialDirContextFactory"/>
        </property>
        <property name="personService">
            <ref bean="personService"></ref>
        </property>
        <property name="namespaceService">
            <ref bean="namespaceService"/>
        </property>
      
        <!–
        The path to the location of a space to use as the default home folder.
        This folder should be readable by all users, or a group to which all imported users belong.

        <property name="defaultHomeFolder">
            <value>/app:company_home</value>
        </property>
   –>
      
        <!–
        This property defines a mapping between attributes held on LDAP user objects and
        the properties of user objects held in the repository. The key is the QName of an attribute in
        the repository, the value is the attribute name from the user/inetOrgPerson/.. object in the
        LDAP repository.    
        –>
        <property name="attributeMapping">
            <map>
                <entry key="cm:userName">
                    <!– Must match the same attribute as userIdAttributeName –>
                    <value>sAMAccountName</value>
                </entry>
                <entry key="cm:firstName">
                    <!– OpenLDAP: "givenName" –>
                    <!– Active Directory: "givenName" –>
                    <value>givenName</value>
                </entry>
                <entry key="cm:lastName">
                    <!– OpenLDAP: "sn" –>
                    <!– Active Directory: "sn" –>
                    <value>sn</value>
                </entry>
                <entry key="cm:email">
                    <!– OpenLDAP: "mail" –>
                    <!– Active Directory: "???" –>
                    <value>mail</value>
                </entry>
                <entry key="cm:organizationId">
                    <!– OpenLDAP: "o" –>
                    <!– Active Directory: "???" –>
                    <value>company</value>
                </entry>
            </map>
        </property>
   
   <!– ADDED –>
   <property name="attributeDefaults">
       <map>
      <entry key="cm:homeFolderProvider">
          <value>companyHomeFolderProvider</value>
      </entry>
       </map>
    </property>    
    </bean>
  
    <!– Extract group information from LDAP and transform this to XML –>
  
    <bean id="ldapGroupExportSource" class="org.alfresco.repo.security.authentication.ldap.LDAPGroupExportSource">
        <!–
        The query to select objects that represent the groups to import.
      
        For Open LDAP, using a basic schema, the following is probably what you want:
        (objectclass=groupOfNames)
      
        For Active Directory:
        (objectclass=group)
        –>
        <property name="groupQuery">
            <value>(objectclass=group)</value>
        </property>
      
        <!–
        The seach base restricts the LDAP query to a sub section of tree on the LDAP server.
        –>
        <property name="searchBase">
            <value>ou=Projects,ou=beez,dc=Company,dc=com</value>
        </property>
      
        <!–
        The unique identifier for the user. This must match the userIdAttributeName on the ldapPeopleExportSource bean above.
        –>
        <property name="userIdAttributeName">
            <value>sAMAccountName</value>
        </property>
      
        <!–
        An attribute that is a unique identifier for each group found.
        This is also the name of the group with the current group implementation.
        This is mandatory for any groups found.
      
        OpenLDAP: "cn" as it is mandatory on groupOfNames
        Active Directory: "cn"
      
        –>
        <property name="groupIdAttributeName">
            <value>cn</value>
        </property>
      
        <!–
        The objectClass attribute for group members.
        For each member of a group, the distinguished name is given.
        The object is looked up by its DN. If the object is of this class it is treated as a group.
        –>
        <property name="groupType">
            <value>group</value>
        </property>
      
        <!–
        The objectClass attribute for person members.
        For each member of a group, the distinguished name is given.
        The object is looked up by its DN. If the object is of this class it is treated as a person.
        –>
        <property name="personType">
            <value>organizationalPerson</value>
        </property>
        <property name="LDAPInitialDirContextFactory">
            <ref bean="ldapInitialDirContextFactory"/>
        </property>
        <property name="namespaceService">
            <ref bean="namespaceService"/>
        </property>
      
        <!–
        The repeating attribute on group objects (found by query or as sub groups)
        used to define membership of the group. This is assumed to hold distinguished names of
        other groups or users/people; the above types are used to determine this.
      
        OpenLDAP: "member" as it is mandatory on groupOfNames
        Active Directory: "member"
      
        –>
        <property name="memberAttribute">
            <value>member</value>
        </property>
    </bean>
  
    <!– Job definitions to import LDAP people and groups –>  
    <bean id="ldapPeopleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
        <property name="jobDetail">
            <bean id="ldapPeopleJobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
                <property name="jobClass">
                    <value>org.alfresco.repo.importer.ImporterJob</value>
                </property>
                <property name="jobDataAsMap">
                    <map>
                        <entry key="bean">
                            <ref bean="ldapPeopleImport"/>
                        </entry>
                    </map>
                </property>
            </bean>
        </property>
        <!– Start after 30 seconds of starting the repository –>
        <property name="startDelay">
            <value>30000</value>
        </property>
        <!– Repeat every half hour –>
        <property name="repeatInterval">
            <value>1800000</value>
        </property>
    </bean>
  
    <bean id="ldapGroupTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
        <property name="jobDetail">
            <bean id="ldapGroupJobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
                <property name="jobClass">
                    <value>org.alfresco.repo.importer.ImporterJob</value>
                </property>
                <property name="jobDataAsMap">
                    <map>
                        <entry key="bean">
                            <ref bean="ldapGroupImport"/>
                        </entry>
                    </map>
                </property>
            </bean>
        </property>
        <!– Start after 30 seconds of starting the repository –>
        <property name="startDelay">
            <value>30000</value>
        </property>
        <!– Repeat every half hour –>
        <property name="repeatInterval">
            <value>1800000</value>
        </property>
    </bean>
  

  
    <!– The bean that imports xml describing people –>
    <bean id="ldapPeopleImport" class="org.alfresco.repo.importer.ExportSourceImporter">
        <property name="importerService">
            <ref bean="importerComponent"/>
        </property>
        <property name="transactionService">
            <ref bean="transactionComponent"/>
        </property>
        <property name="authenticationComponent">
            <ref bean="authenticationComponent"/>
        </property>
        <property name="exportSource">
            <ref bean="ldapPeopleExportSource"/>
        </property>

        <!– The store that contains people - this should not be changed –>
        <property name="storeRef">
            <value>${spaces.store}</value>
        </property>
      
        <!– The location of people nodes within the store defined above - this should not be changed –>
        <property name="path">
            <value>/${system.system_container.childname}/${system.people_container.childname}</value>
        </property>
      
        <!– If true, clear all existing people before import, if false update/add people from the xml –>
        <property name="clearAllChildren">
            <value>false</value>
        </property>
        <property name="nodeService">
            <ref bean="nodeService"/>
        </property>
        <property name="searchService">
            <ref bean="searchService"/>
        </property>
        <property name="namespacePrefixResolver">
            <ref bean="namespaceService"/>
        </property>
    </bean>
  
    <!– The bean that imports xml descibing groups –>
    <bean id="ldapGroupImport" class="org.alfresco.repo.importer.ExportSourceImporter">
        <property name="importerService">
            <ref bean="importerComponent"/>
        </property>
        <property name="transactionService">
            <ref bean="transactionComponent"/>
        </property>
        <property name="authenticationComponent">
            <ref bean="authenticationComponent"/>
        </property>
        <property name="exportSource">
            <ref bean="ldapGroupExportSource"/>
        </property>
        <!– The store that contains group information - this should not be changed –>
        <property name="storeRef">
            <value>${alfresco_user_store.store}</value>
        </property>
      
        <!– The location of group information in the store above - this should not be changed –>
        <property name="path">
            <value>/${alfresco_user_store.system_container.childname}/${alfresco_user_store.authorities_container.childname}</value>
        </property>
      
        <!– If true, clear all existing groups before import, if false update/add groups from the xml –>
        <property name="clearAllChildren">
            <value>true</value>
        </property>
        <property name="nodeService">
            <ref bean="nodeService"/>
        </property>
        <property name="searchService">
            <ref bean="searchService"/>
        </property>
        <property name="namespacePrefixResolver">
            <ref bean="namespaceService"/>
        </property>
    </bean>
  
</beans>
4 REPLIES 4

luba_s
Champ in-the-making
Champ in-the-making
I also tried another configurations:

1. add <null/> section into ldap-auth-context.xml


                <entry key="cm:organizationId">
                    <!– OpenLDAP: "o" –>
                    <!– Active Directory: "???" –>
                    <value>company</value>
                </entry

                <!– Always use the default –>
                <entry key="cm:homeFolderProvider">
                    <null/>
                </entry>
                <entry key="cm:organizationId">
                    <!– OpenLDAP: "o" –>
                    <!– Active Directory: "???" –>
                    <value>company</value>
                </entry>

                <!– Always use the default –>
                <entry key="cm:homeFolderProvider">
                    <null/>
                </entry>      
            </map>
        </property>
   
   <!– LSV ADDED –>
   <property name="attributeDefaults">
       <map>
      <entry key="cm:homeFolderProvider">
          <value>companyHomeFolderProvider</value>
      </entry>
       </map>
    </property>    
    </bean>

2. modification of cmSmiley Tongueerson in contentModel.xml:


<type name="cm:person">
         <title>Person</title>
         <parent>sys:base</parent>
         <properties>
            <property name="cm:userName">
               <type>d:text</type>
               <mandatory>true</mandatory>
            </property>
            <property name="cm:homeFolder">
               <type>d:noderef</type>
               <mandatory>true</mandatory>         
            </property>
             <property name="cm:firstName">
               <type>d:text</type>
               <mandatory>true</mandatory>
            </property>
            <property name="cm:lastName">
               <type>d:text</type>
               <mandatory>true</mandatory>
            </property>
            <property name="cm:middleName">
               <type>d:text</type>
            </property>
            <property name="cm:email">
               <type>d:text</type>
            </property>
            <property name="cm:organizationId">
               <type>d:text</type>
            </property>
            <property name="cm:homeFolderProvider">
               <type>d:text</type>
          <default>companyHomeFolderProvider</default>
            </property>
            <property name="cm:defaultHomeFolderPath">
               <type>d:text</type>
          <default>/app:company_home</default>
            </property>
         </properties>
      </type>

Both without success. I think there must be a bug…

andy
Champ on-the-rise
Champ on-the-rise
Hi

Which version of the repository are you using?

Have you made any changes to the homeFolderManager bean or the providers in authentication-services-context.xml?

Regards

Andy

luba_s
Champ in-the-making
Champ in-the-making
>> Which version of the repository are you using?
I use Alfresco 1.4.0 (build-105) schema 21.

>> Have you made any changes to the homeFolderManager bean
no

>> or the providers in authentication-services-context.xml?
yes, i have custom authenticationComponentImpl bean that simply override authenticate() method.

Here is a code that replace default authenticationComponentImpl bean.

<bean id="authenticationComponentImpl" class="org.alfresco.repo.security.authentication.beez.BeezAuthenticationComponent">
        <property name="allowGuestLogin">
            <value>true</value>
        </property>
    </bean>

Thanks Luba

luba_s
Champ in-the-making
Champ in-the-making
Hi

Which version of the repository are you using?

Have you made any changes to the homeFolderManager bean or the providers in authentication-services-context.xml?

Regards

Andy

Ok, I found that issue doesn't appear in Alfresco 2.0 with the same configuration.
But I found another strange things - there is something wrong with lucene indexes after import of users and groups from ldap. When I try assign any role on the folder to imported user/group, then following exception is thrown:


Caused by: org.alfresco.service.cmr.repository.InvalidNodeRefException: Node does not exist: workspace://SpacesStore/f92b1551-b831-11db-95b1-fbb198896
849
        at org.alfresco.repo.node.db.DbNodeServiceImpl.getNodeNotNull(DbNodeServiceImpl.java:121)
        at org.alfresco.repo.node.db.DbNodeServiceImpl.getProperty(DbNodeServiceImpl.java:879)
        at sun.reflect.GeneratedMethodAccessor138.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.alfresco.repo.service.StoreRedirectorProxyFactory$RedirectorInvocationHandler.invoke(StoreRedirectorProxyFactory.java:213)
        at $Proxy4.getProperty(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor138.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
        at org.alfresco.repo.node.MLPropertyInterceptor.invoke(MLPropertyInterceptor.java:61)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
        at $Proxy5.getProperty(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor138.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
        at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:116)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
        at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:80)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
        at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:41)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
        at org.alfresco.repo.audit.AuditComponentImpl.auditImpl(AuditComponentImpl.java:211)
        at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:157)
        at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:61)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
        at $Proxy14.getProperty(Unknown Source)
        at org.alfresco.web.bean.repository.User.getFullName(User.java:99)
        at org.alfresco.web.bean.wizard.InviteUsersWizard.next(InviteUsersWizard.java:488)
        at org.alfresco.web.bean.wizard.WizardManager.next(WizardManager.java:464)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)

I found that if i perform following steps:
- stop the server
- set index.recovery.mode=FULL
- delete alf_data/lucene-indexes/*

then everything runs OK. Is there any way how to automatically rebuild indexes after each ldap import without stopping the server? Thanks