cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the settings of the ldap-ad subsystem

alexsolomatin
Champ on-the-rise
Champ on-the-rise
Hello guys.

I'm a newbie in Alfresco and developing an Alfresco Module Package for Alfresco Enterprise 3.2.0r. I enabled LDAP-AD logging in Alfresco as it's described in the wiki. It works fine. But how can I retrieve programmatically the properties I've set in the file ldap-ad-authentication.properties? Of course I can get them by reading this file by Properties class, but it looks like a hack… Probably, I can read the properties frome some Alfresco beans, but I don't know what beans I should use…  :roll:

Could anyone help me, please?
5 REPLIES 5

gyro_gearless
Champ in-the-making
Champ in-the-making
I suppose the "global-properties" bean is you friend here, just inject it as dependency  (assuming you are writing some kind of Spring bean)

       
        <property name="properties">
            <ref bean="global-properties"/>
        </property

and add a properties property of type java.util.Properties to your bean 🙂

Cheers
Gyro

alexsolomatin
Champ on-the-rise
Champ on-the-rise
Thank you. I did it and I can see the all Alfresco global properties now. The bean contains the all data from C:\Alfresco\tomcat\shared\classes\alfresco-global.properties, but doesn't contains the settings for ldap authentication. I think I should read the properties from C:\Alfresco\tomcat\shared\classes\alfresco\extension\subsystems\Authentication\ldap-ad\ldap1\ldap-ad-authentication.properties the same way. But which bean sholud I use? I saw in alresco.log this properties file is loaded:
17:18:52,596 INFO  [org.alfresco.config.JndiPropertiesFactoryBean] Loading properties file from class path resource [alfresco/repository.properties]
17:18:52,596 INFO  [org.alfresco.config.JndiPropertiesFactoryBean] Loading properties file from class path resource [alfresco/domain/transaction.properties]
17:18:52,596 INFO  [org.alfresco.config.JndiPropertiesFactoryBean] Loading properties file from URL [file:/C:/Alfresco/tomcat/shared/classes/alfresco-global.properties]
17:18:52,784 INFO  [org.alfresco.config.JndiPropertyPlaceholderConfigurer] Loading properties file from class path resource [alfresco/alfresco-shared.properties]
17:19:05,378 INFO  [org.alfresco.config.JndiPropertiesFactoryBean] Loading properties file from file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\subsystems\Authentication\ldap-ad\ldap1\ldap-ad-authentication.properties]

sans
Champ in-the-making
Champ in-the-making
Hi Alex,
I am also trying to read a property from global-properties file.
Can you please explain me in brief what to do?

thanks
Sans!!

alexsolomatin
Champ on-the-rise
Champ on-the-rise
Hi sans.

I injected this properties in my own bean in my module context (module-context.xml). Example:

<bean id="AlfrescoConnector"
      class="com.blahblahblah.AlfrescoConnector"
      init-method="Init" >                    
        <!– some code –>    
   <property name="alfrescoGlobalProperties">
            <ref bean="global-properties"/>
        </property>                       
        <!– some code –>
</bean>

com.blahblahblah.AlfrescoConnector looks like this:
public class AlfrescoConnector {
    private Properties alfrescoGlobalProperties;
    public void Init() {
        // initialization method
        // you can use alfrescoGlobalProperties here and in the other methods too
    }
    public void setAlfrescoGlobalProperties(Properties alfrescoGlobalProperties) {
      this.alfrescoGlobalProperties = alfrescoGlobalProperties;
   }
}

sans
Champ in-the-making
Champ in-the-making
Hi Alex,
Thanks for the note!! It worked.

Cheers
Sans!!