[openbenno-users] Anbindung OpenBenno an Active Directory

Stefan Dorn sd at schnied.net
Tue Nov 10 19:16:14 CET 2009


uff... yes!

und wenn du das als anleitung zusammenfassen kannst, kriegst du einen
besonderen platz im howto und der faq!

gruss
stefan



Niels Jäckel schrieb:
> Hallo,
> 
>  
> 
> wir benutzen OpenBenno als Mailarchiv. Mit der integrierten
> Authentifikation über den ExternalCommandUserDetailsManager konnten wir
> bereits verifizieren, dass die Mails tatsächlich im Archiv landen.
> 
>  
> 
> Nun soll Benno an unser Active Directory angebunden werden. Über die
> Spring Security Konfiguration habe ich dazu einen
> LdapAuthenticationProvider konfiguriert. Die Authentifikation der Nutzer
> ist damit möglich und funktioniert. Allerdings werden keine E-Mails
> angezeigt.
> 
>  
> 
> Dem ExternalCommandUserDetailsManager habe ich entnommen, dass es neben
> der Rolle für den Zugriff auf die Applikation, eine weitere Rolle
> notwendig ist, die die jeweilige E-Mail-Adresse zur Ansicht
> „freischaltet“. Dazu habe ich einen OpenBennoLdapAuthoritiesPopulator
> implementiert, der zusätzlich die entsprechende Rolle bereitstellt. Per
> Debugger konnte ich nachweisen, dass die Rolle korrekt hinzugefügt wird.
> Allerdings werden noch immer keine E-Mails angezeigt. Wenn ich jedoch
> wieder den ExternalCommandUserDetailsManager einbinde, sehe ich meine
> Nachrichten.
> 
>  
> 
> Dies sind die relevanten Ausschnitte aus der
> applicationContext-security.xml:
> 
>  
> 
>       <http>
> 
>             <intercept-url pattern=/"/login.html*"/ filters=/"none"//>
> 
>             <intercept-url pattern=/"/images/**"/ filters=/"none"//>
> 
>             <intercept-url pattern=/"/**"/ access=/"ROLE_COMMUNARDO"/ />
> 
>  
> 
>             <form-login login-page=/'/login.html'//>
> 
>             <anonymous/>
> 
>             <logout/>
> 
>       </http>
> 
>  
> 
>       <beans:bean id=/"ldapProvider"/
> class=/"org.springframework.security.providers.ldap.LdapAuthenticationProvider"/>
> 
>             <custom-authentication-provider/>
> 
>             <beans:constructor-arg ref=/"ldapBindAuthenticator"/ />
> 
>             <beans:constructor-arg ref=/"authoritiesPopulator"//>
> 
>       </beans:bean>
> 
>  
> 
>       <beans:bean id=/"authoritiesPopulator"/
> class=/"de.communardo.openbenno.OpenBennoLdapAuthoritiesPopulator"/>
> 
>             <beans:constructor-arg ref=/"contextSource"//>
> 
>             <beans:constructor-arg value=/""//>
> 
>             <beans:property name=/"groupRoleAttribute"/ value=/"cn"//>
> 
>             <beans:property name=/"groupSearchFilter"/
> value=/"(&amp;(member={0})(objectClass=group))"//>
> 
>             <beans:property name=/"rolePrefix"/ value=/"ROLE_"//>
> 
>             <beans:property name=/"searchSubtree"/ value=/"true"//>
> 
>             <beans:property name=/"convertToUpperCase"/ value=/"false"//>
> 
>             <beans:property name=/"mailRoleAttribute"/ value=/"mail"//>
> 
>       </beans:bean>
> 
>  
> 
>  
> 
> Dies ist die neu implementierte Klasse:
> 
>  
> 
> /**
> 
>  * LDAP Authorities provider for the OpenBenno mail archive. Adds the
> user's email-address as
> 
>  * additional role.
> 
>  *
> 
>  * *@author* _Niels_ _Jäckel_ <niels._jaeckel at communardo_._de_>
> 
>  */
> 
> *public* *class* OpenBennoLdapAuthoritiesPopulator *extends*
> DefaultLdapAuthoritiesPopulator {
> 
>  
> 
>     /**
> 
>      * The attribute with the user's e-mail in the LDAP principal. This
> value may be directory-specific.
> 
>      */
> 
>     *private* String mailRoleAttribute = "mail";
> 
>    
> 
>     /**
> 
>      * The prefix for mail roles. This value is constant as of OpenBenno.
> 
>      */
> 
>     *private* String roleMailPrefix = "ROLE_MAIL_";
> 
>    
> 
>     /**
> 
>      * Copy this property from the DefaultLdapAuthoritiesPopulator
> 
>      */
> 
>     *protected* *boolean* convertMailToUpperCase = *true*;
> 
>  
> 
>    
> 
>     *public* OpenBennoLdapAuthoritiesPopulator(ContextSource
> contextSource, String groupSearchBase) {
> 
>         *super*(contextSource, groupSearchBase);
> 
>     }
> 
>    
> 
>     @SuppressWarnings("unchecked")
> 
>     @Override
> 
>     *protected* Set getAdditionalRoles(DirContextOperations user, String
> username) {
> 
>        
> 
>         String mailAddress = user.getStringAttribute(mailRoleAttribute);
> 
>        
> 
>         *if* (convertMailToUpperCase) {
> 
>             mailAddress = mailAddress.toUpperCase();
> 
>         }
> 
>  
> 
>         String role = roleMailPrefix + mailAddress;
> 
>        
> 
>         Set result = *new* HashSet();
> 
>         result.add(*new* GrantedAuthorityImpl(role));
> 
>        
> 
>         *return* result;
> 
>     }
> 
>    
> 
>  
> 
>     /**
> 
>      * *@param* mailRoleAttribute the mailRoleAttribute to set
> 
>      */
> 
>     *public* *void* setMailRoleAttribute(String mailRoleAttribute) {
> 
>         Assert./notNull/(mailRoleAttribute, "mailRoleAttribute must not
> be null");
> 
>         *this*.mailRoleAttribute = mailRoleAttribute;
> 
>     }
> 
>  
> 
>     /**
> 
>      * *@param* roleMailPrefix the roleMailPrefix to set
> 
>      */
> 
>     *public* *void* setRoleMailPrefix(String roleMailPrefix) {
> 
>         *this*.roleMailPrefix = roleMailPrefix;
> 
>     }
> 
>  
> 
>     /**
> 
>      * *@param* convertToUpperCase the convertToUpperCase to set
> 
>      */
> 
>     *public* *void* setConvertToUpperCase(*boolean* convertToUpperCase) {
> 
>         *this*.convertMailToUpperCase = convertToUpperCase;
> 
>         *super*.setConvertToUpperCase(convertToUpperCase);
> 
>     }
> 
> }
> 
>  
> 
>  
> 
> Müssen neben der zusätzlichen ROLE_MAIL_e.mail at adres.se weitere
> Voraussetzungen erfüllt werden, damit die E-Mails angezeigt werden?
> Sobald ein Nutzer über das AD die Nutzergruppen ADMIN oder AUDITOR
> zugewiesen bekommt, werden alle E-Mails von allen Nutzern angezeigt.
> Prinzipiell funktioniert der Zugriff also…
> 
>  
> 
>  
> 
> Vielen Dank und Grüße,
> 
> Niels Jäckel
> 
>  
> 
>  
> 
>  
> 
>  
> 
> -- 
> Communardo Software GmbH
> Human Network Competence
> 
>  
> 
> i.A. Niels Jäckel,
> 
> Softwareentwickler
> 
>  
> 
> Kleiststraße 10 a, D-01129 Dresden
> Fon:   +49 351 / 833 82 - 251
> 
> Fax:   +49 351 / 833 82 - 299
> Mail: niels.jaeckel at communardo.de <mailto:niels.jaeckel at communardo.de>
> 
>  
> 
> Web:  http://www.communardo.de <http://www.communardo.de/>
> 
> Blog:  http://www.humannetworkcompetence.de/
>          http://www.communardo.de/techblog/
>   
> 
> 
> Amtsgericht Dresden, HRB 19244, USt-ID. DE213200303
> Geschäftsführer: Ilja Hauß, Dirk Röhrborn
> 
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> users mailing list
> users at openbenno.org
> https://www.openbenno.org/mailman/listinfo/users


More information about the users mailing list