Hi.
Would it by possible to have LDAP User authentication ?
It would be awesome if Subsonic could authenticate users against Active Directory.
Thanks,
Svenni
Moderator: moderators
<bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager">
<property name="providers">
<list>
<!-- add the following line for LDAP authentication -->
<ref local="activeDirectoryAuthenticationProvider"/>
<!-- comment out the following line to disable database authentication -->
<!-- <ref local="daoAuthenticationProvider"/> -->
<bean class="org.acegisecurity.providers.anonymous.AnonymousAuthenticationProvider">
<property name="key" value="subsonic"/>
</bean>
<bean class="org.acegisecurity.providers.rememberme.RememberMeAuthenticationProvider">
<property name="key" value="subsonic"/>
</bean>
</list>
</property>
</bean>
<bean id="initialDirContextFactory"
class="org.acegisecurity.ldap.DefaultInitialDirContextFactory">
<constructor-arg
value="ldap://domain.com.hostname:389/cn=Users,dc=domain,dc=com" />
<property name="managerDn">
<value>
<!-- the DN of a user that is able to read data from LDAP -->
<![CDATA[CN=LDAP,CN=Users,DC=domain,DC=com]]>
</value>
</property>
<property name="managerPassword">
<!-- the password of the DN set above -->
<value>secretpassword</value>
</property>
<property name="extraEnvVars">
<map>
<entry>
<key>
<value>java.naming.referral</value>
</key>
<value>follow</value>
</entry>
</map>
</property>
</bean>
<bean id="activeDirectoryAuthenticationProvider"
class="org.acegisecurity.providers.ldap.LdapAuthenticationProvider">
<constructor-arg>
<ref local="bindAuthenticator" />
</constructor-arg>
<constructor-arg>
<ref local="userDetailsServiceBasedAuthoritiesPopulator" />
</constructor-arg>
</bean>
<bean id="bindAuthenticator"
class="org.acegisecurity.providers.ldap.authenticator.BindAuthenticator">
<constructor-arg>
<ref local="initialDirContextFactory" />
</constructor-arg>
<property name="userSearch">
<ref local="userSearch" />
</property>
</bean>
<bean id="userDetailsServiceBasedAuthoritiesPopulator"
class="net.sourceforge.subsonic.ldap.UserDetailsServiceBasedAuthoritiesPopulator">
<property name="userDetailsService" ref="securityService"/>
</bean>
<bean id="userSearch"
class="org.acegisecurity.ldap.search.FilterBasedLdapUserSearch">
<constructor-arg>
<value></value>
</constructor-arg>
<constructor-arg>
<value>(sAMAccountName={0})</value>
</constructor-arg>
<constructor-arg>
<ref local="initialDirContextFactory" />
</constructor-arg>
<property name="searchSubtree">
<value>true</value>
</property>
<property name="derefLinkFlag">
<value>true</value>
</property>
</bean>
package net.sourceforge.subsonic.ldap;
import org.acegisecurity.GrantedAuthority;
import org.acegisecurity.ldap.LdapDataAccessException;
import org.acegisecurity.providers.ldap.LdapAuthoritiesPopulator;
import org.acegisecurity.userdetails.UserDetailsService;
import org.acegisecurity.userdetails.ldap.LdapUserDetails;
/**
* An {@link LdapAuthoritiesPopulator} that retrieves the roles from the
* database using the {@link UserDetailsService} instead of retrieving the roles
* from LDAP. An instance of this class can be configured for the
* {@link org.acegisecurity.providers.ldap.LdapAuthenticationProvider} when
* authentication should be done using LDAP and authorization using the
* information stored in the database.
*
* @author Thomas M. Hofmann
*/
public class UserDetailsServiceBasedAuthoritiesPopulator implements
LdapAuthoritiesPopulator {
private UserDetailsService userDetailsService;
public GrantedAuthority[] getGrantedAuthorities(LdapUserDetails userDetails)
throws LdapDataAccessException {
return userDetailsService.loadUserByUsername(userDetails.getUsername())
.getAuthorities();
}
public void setUserDetailsService(UserDetailsService userDetailsService) {
this.userDetailsService = userDetailsService;
}
}
mistaox wrote:This feature should allow for Users to be managed exclusively by AD and the roles should be handled by Subsonic.
[2008-04-03 13:39:31,850] INFO SubsonicLdapBindAuthenticator - Failed to authenticate user 'testuser' in LDAP.
org.acegisecurity.ldap.LdapDataAccessException: LdapCallback;[LDAP: error code 1 - 00000000: LdapErr: DSID-0C090627, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, vece]; nested exception is javax.naming.NamingException: [LDAP: error code 1 - 00000000: LdapErr: DSID-0C090627, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, vece]; remaining name ''
Caused by: javax.naming.NamingException: [LDAP: error code 1 - 00000000: LdapErr: DSID-0C090627, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, vece]; remaining name ''
Users browsing this forum: No registered users and 7 guests