cancel
Showing results for 
Search instead for 
Did you mean: 

Syncing Active Directory users and groups

esanamr
Champ in-the-making
Champ in-the-making
I have downloaded the war and I've installed in my tomcat, W2K.
I've followed these steps: http://wiki.alfresco.com/wiki/Enterprise_Security_and_Authentication_Configuration

I want to sync my Active Directory users, not MD-5 support.

When I change my scheduled-jobs-context.xml to this:

<bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
       <property name="triggers">
           <list>
               <ref bean="tempFileCleanerTrigger" />
               <ref bean="ftsIndexerTrigger" />
               <ref bean="indexRecoveryTrigger" />
               <ref bean="indexBackupTrigger" />
               <ref bean="ldapGroupTrigger" />
           </list>
       </property>
       <property name="waitForJobsToCompleteOnShutdown">
           <value>true</value>
       </property>
       <property name="configLocation">
           <value>classpath:alfresco/domain/quartz.properties</value>
       </property>
   </bean>

It appears this error:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'schedulerFactory' defined in class path resource [alfresco/scheduled-jobs-context.xml]: Can't resolve reference to bean 'tempFileCleanerTrigger' while setting property 'triggers[0]'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tempFileCleanerTrigger' defined in class path

But I have the tempFileCleanerTrigger declarated.

If I use the scheduled-jobs-context.xml original there is no error, but the cron no sync the users:

11:36:40,309 DEBUG [org.alfresco.smb.protocol] Win32 NetBIOS Available LANAs: 0
11:36:40,324 DEBUG [org.alfresco.smb.protocol] Win32 NetBIOS server ACI0070_A (using Winsock)
11:36:40,402 DEBUG [org.alfresco.smb.protocol] Win32 NetBIOS created session handler on LANA 0
11:36:40,434 DEBUG [org.alfresco.smb.protocol] Waiting for Win32 NetBIOS session request (Winsock) …
11:36:40,434 DEBUG [org.alfresco.smb.protocol] Win32 NetBIOS host announcer enabled on LANA 0
11:36:40,465 DEBUG [org.alfresco.smb.protocol] Win32 NetBIOS register listener for LANA 0
11:36:40,496 DEBUG [org.alfresco.smb.protocol.mailslot] HostAnnouncer: Announced host ACI0070_A
11:36:45,496 DEBUG [org.alfresco.smb.protocol.mailslot] HostAnnouncer: Announced host ACI0070_A.


This is my ldap-authentication-context.xml:

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

<beans>
   
    <!– DAO that rejects changes - LDAP is read only at the moment. It does allow users to be deleted with out warnings from the UI. –>
   
    <bean name="authenticationDao" class="org.alfresco.repo.security.authentication.DefaultMutableAuthenticationDao" >
        <property name="allowDeleteUser">
            <value>true</value>
        </property>
    </bean>   
  

    <!– LDAP authentication configuration –>
   
    <!–
   
    You can also use JAAS authentication for Kerberos against Active Directory or NTLM if you also require single sign on from the
    web browser. You do not have to use LDAP authentication to synchronise groups and users from an LDAP store if it supports other
    authentication routes, like Active Directory.
   
    –>
   
    <bean id="authenticationComponentImpl" class="org.alfresco.repo.security.authentication.ldap.LDAPAuthenticationComponentImpl">
        <property name="LDAPInitialDirContextFactory">
            <ref bean="ldapInitialDirContextFactory"/>
        </property>
        <property name="userNameFormat">
            <!–
           
            This maps between what the user types in and what is passed through to the underlying LDAP authentication.
           
            "%s" - the user id is passed through without modification.
            Used for LDAP authentication such as DIGEST-MD5, anything that is not "simple".
           
            "cn=%s,ou=London,dc=company,dc=com" - If the user types in "Joe Bloggs" the authentricate as "cn=Joe Bloggs,ou=London,dc=company,dc=com"
            Usually for simple authentication.
           
            –>
            <value>samaccountname=%s</</value>
        </property>
    </bean>
   
    <!–
   
    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 –>
                <!– Note you can use space separated urls - they will be tried in turn until one works –>
                <!– This could be used to authenticate against one or more ldap servers (you will not know which one ….) –>
                <entry key="java.naming.provider.url">
                    <value>ldap://172.16.0.50: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=apus00,OU=Interno Restringido,OU=Restricciones,DC=grpgines,DC=intra</value>
                </entry>
               
                <!– The password for the user defined above –>
                <entry key="java.naming.security.credentials">
                    <value>****</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><![CDATA[(&(userAccountControl=512)(givenName=*)(sn=*)(mail=*)(company=*))]]></value>
        </property>
       
        <!–
        The seach base restricts the LDAP query to a sub section of tree on the LDAP server.
        –>
        <property name="searchBase">
            <value>dc=grpgines,dc=intra</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>
       
        <!–
        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">
                       <value>samaccountname</value>
               </entry>
               <entry key="cm:firstName">
                       <value>givenName</value>
               </entry>
               <entry key="cm:lastName">
                       <value>sn</value>
               </entry>
               <entry key="cm:email">
                       <value>mail</value>
               </entry>
               <entry key="cm:organizationId">
                       <value>company</value>
               </entry>
               </map>
            </property>
            
        <!– Set a default home folder provider –>
        <!– Defaults only apply for values above –>
        <property name="attributeDefaults">
            <map>
                <entry key="cm:homeFolderProvider">
                    <value>personalHomeFolderProvider</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=Usuarios,OU=OU-Servicios Centrales,DC=grpgines,DC=intra</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>organizationalUnit</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>person</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>
       
        <property name="authorityDAO">
            <ref bean="authorityDAO"/>
        </property>
    </bean>
   
    <!– Job definitions to import LDAP people and groups –>
    <!– The triggers register themselves with the scheduler –>
    <!– You may comment in the default scheduler to enable these triggers –>
    <!– If a cron base trigger is what you want seee scheduled-jobs-context.xml for examples. –>
   
    <!– Trigger to load poeple –>
    <!– Note you can have more than one initial (context, trigger, import job and export source) set –>
    <!– This would allow you to load people from more than one ldap store –>
   
    <!– ESM
    <bean id="ldapPeopleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
    –>
    <bean id="ldapPeopleTrigger" class="org.alfresco.util.CronTriggerBean">
        <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>
        <!– ESM
        <property name="startDelay">
            <value>30000</value>
        </property>
        <property name="repeatInterval">
            <value>3600000</value>
        </property>
       –>
     <property name="scheduler">
        <ref bean="schedulerFactory" />
    </property>
    <property name="cronExpression">
        <value>0 40 11 * * ?</value> <!– daily at 06:40 –>
    </property>
    </bean>
  
   <!– ESM
   <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>
       <property name="startDelay">
           <value>60000</value>
       </property>
       <property name="repeatInterval">
           <value>3600000</value>
       </property>
   </bean>
   –>
  
   <bean id="ldapGroupTrigger" class="org.alfresco.util.CronTriggerBean">
    <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>
    <property name="scheduler">
        <ref bean="schedulerFactory" />
    </property>

    <property name="cronExpression">
        <value>0 40 11 * * ?</value> <!– daily at 06:40 –>
    </property>
</bean>



    <!– The bean that imports xml describing people –>
   
    <bean id="ldapPeopleImport" class="org.alfresco.repo.importer.ExportSourceImporter">
        <property name="importerService">
            <ref bean="importerComponentWithBehaviour"/>
        </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>
       
       
        <property name="caches">
            <set>
                <ref bean="permissionsAccessCache"/>
            </set>
        </property>
    </bean>
   
    <!– The bean that imports xml descibing groups –>
   
    <bean id="ldapGroupImport" class="org.alfresco.repo.importer.ExportSourceImporter">
        <property name="importerService">
            <ref bean="importerComponentWithBehaviour"/>
        </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>
       
        <!– caches to clear on import of groups –>
        <property name="caches">
            <set>
                <ref bean="userToAuthorityCache"/>
                <ref bean="permissionsAccessCache"/>
            </set>
        </property>
       
        <!– userToAuthorityCache –>
    </bean>
   
</beans>


The user with permissions is:
CN=apus00,OU=Interno Restringido,OU=Restricciones,DC=grpgines,DC=intra

But I want to sync other OUs like OU-Servicios Centrales, not just one.


Thanks in advance
10 REPLIES 10

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

You no longer need to change the schedulerFactory bean.

The triggers now register with an injected sceduler, if provided.
Look at the trigger bean definitions and comment in the scheduler.

You can define as many import stacks and triggers as you like to import from  as many LDAP servers as you like. You can also use chaining authentication to try authenticating against many LDAP servers - or the same LDAP server but with users in different places. The example just uses one LDAP server for simplicity.

Regards

Andy

esanamr
Champ in-the-making
Champ in-the-making
Thank you Gary, but still not Syncing and there aren't error in the log.

I have set the original scheduled-jobs-context.xml.

In the ldap-authentication-context.xml I have changed the triggers:


<bean id="ldapPeopleTrigger" class="org.alfresco.util.CronTriggerBean">
        <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>

    <property name="cronExpression">
        <value>0 15 15 * * ?</value> <!– daily at 15:15 –>
    </property>
</bean>

The cron would be at 15:15 but no users are imported and the log only shows:

15:13:59,034 DEBUG [org.alfresco.smb.protocol.mailslot] HostAnnouncer: Announced host ACI0070_A
15:16:39,032 DEBUG [org.alfresco.smb.protocol.mailslot] HostAnnouncer: Announced host ACI0070_A

In the log4j.properties I have the: log4j.logger.org.alfresco.repo.security.authentication.ldap=debug

I can't login as Active Directory user and in the table alf_authority there aren't new rows.

Thanks in advance

ribz33
Champ on-the-rise
Champ on-the-rise
You need to uncomment this to launch Syncing

        <property name="scheduler">
            <ref bean="schedulerFactory" />
        </property>

Another thing, Import dont work but AD authentification is working ?

esanamr
Champ in-the-making
Champ in-the-making
I have probe to uncomment it too and nothing.

No, AD authentification doesn't work either.

I've installed Softerra Ldap Browser and it seems that the configuration is right.

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

For LDAP simple authentication you must use the DN for the user.

Regards

Andy

esanamr
Champ in-the-making
Champ in-the-making
Thank you Andy.

The import users was solved. I had a fool error, copy the ldap-authentication-context.xml in the alfresco folder instead of the extension folder.

I have seen the table and the import was successful, but now I can't login.

The DC is right as I see in Softerra. I use an administrator user:

<entry key="java.naming.security.principal">
                    <value>CN=apus00,OU=Interno Restringido,OU=Restricciones,DC=grpgines,DC=intra</value>

I've been imported to the table and I try to login with my user which is the administrator in authority-services-context.xml but nothing. I try with other users of the AD but nothing.

This is the log:

12:28:39,848 WARN  [org.alfresco.repo.security.authentication.ldap.LDAPInitialDirContextFactoryImpl] LDAP server supports anonymous bind ldap://172.16.0.50:389
12:28:39,848 INFO  [org.alfresco.repo.security.authentication.ldap.LDAPInitialDirContextFactoryImpl] LDAP server does not fall back to anonymous bind for a string uid and password at ldap://172.16.0.50:389
12:28:39,848 INFO  [org.alfresco.repo.security.authentication.ldap.LDAPInitialDirContextFactoryImpl] LDAP server does not fall back to anonymous bind for a simple dn and password at ldap://172.16.0.50:389
12:28:39,864 INFO  [org.alfresco.repo.security.authentication.ldap.LDAPInitialDirContextFactoryImpl] LDAP server does not fall back to anonymous bind for known principal and invalid credentials at ldap://172.16.0.50:389
12:28:50,739 INFO  [org.alfresco.repo.admin.patch.PatchExecuter] Checking for patches to apply …
12:28:50,801 INFO  [org.alfresco.repo.admin.patch.PatchExecuter] No patches were required.
12:28:50,989 DEBUG [org.alfresco.smb.protocol] Added desktop action CheckInOut
12:28:51,004 DEBUG [org.alfresco.smb.protocol] Added desktop action JavaScriptURL
12:28:51,067 ERROR [org.alfresco.smb.protocol] CIFS server configuration error, Wrong authentication setup for alfresco authenticator
org.alfresco.error.AlfrescoRuntimeException: Wrong authentication setup for alfresco authenticator

Thanks in advance

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


<value>samaccountname=%s</</value>

Will not work with simple authentication.

You need to set everything up to use a DN or use DIGEST-MD5 …. or stick with your ldap import and add Kerberos/Jaas authentication.

Regards

Andy

esanamr
Champ in-the-making
Champ in-the-making
Thank you very much Andy.

Now I can login users with full name.
1) I've put the jaas-authentication-context.xml in the extension folder
2) I've created the java.login.config
3) Added the line to the java.security
login.config.url.1=file:${java.home}/lib/security/java.login.config


But in the log still shows the error:
[org.alfresco.repo.security.authentication.ldap.LDAPInitialDirContextFactoryImpl] LDAP server does not fall back to anonymous bind for known principal and invalid credentials at ldap://172.16.0.50:389
18:43:28,961 ERROR [org.alfresco.smb.protocol] CIFS server configuration error, Wrong authentication setup for alfresco authenticator

And the CIFS Server doesn't start.
My Active Directory doesn't support DIGEST-MD5.
The Active Directory supports GSS-SPNEGO and GSSAPI.

What should I do to enable CIFS Server and login with the id of the Active Directory?

Thanks in advance