Announcement Announcement Module
Collapse
No announcement yet.
Setting up Ldap authentication Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Setting up Ldap authentication

    Hi,

    I am a newbie to Spring framework. As part of the project, I need to perform Ldap authentication for the user. I followed the documentation and created the following...
    Code:
    <bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
    		<property name="url" value="ldap://xxx.xxx.xxx:xxx" />
    		<property name="base" value="ou=active,ou=employees,ou=people,o=xxxxxxx.com" />
    		<property name="authenticationSource" ref="springSecurityAuthenticationSource" />
    	</bean>
    	<bean id="springSecurityAuthenticationSource"
    		class="org.springframework.security.ldap.authentication.SpringSecurityAuthenticationSource" />
    		
    	<bean id="ldapBean" class="com.learn.authz.AuthorizeUser">
    		<property name="contextSource" ref="contextSource"></property>
    	</bean>
    the beans using this are below:
    Code:
    import org.springframework.ldap.core.ContextSource;
    import org.springframework.ldap.core.LdapTemplate;
    
    public class AuthorizeUser implements UserAuthentication {
    	private LdapTemplate ldapTemplate;
    
    	public void setContextSource(ContextSource contextSource) throws Exception {
    		// TODO Auto-generated method stub
    		this.ldapTemplate = new LdapTemplate(contextSource);
    	}
    
    	public boolean isAuthenticated(String username, String password)
    			throws Exception {
    		boolean val = ldapTemplate.authenticate("", "(uid=" + username + ")",password);
    		return val;
    	}
    
    }
    This fails when I load the beans using ClassPathXMLApplicationContext.
    I get the following error:
    Code:
    Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
    PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'contextSource' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/EmptyResultDataAccessException
    	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102)
    	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1350)
    	... 13 more
    Am I missing any parameters in the xml configuration file?

    Appreciate any pointers towards this.

    Thanks,
    Rishikesh R.

  • #2
    Hi,

    I managed to figure out the error. The jar file spring-tx-3.0.2.RELEASE.jar was missing from the build path. As I found out 'spring-tx.jar' supersedes the previous 'spring-dao.jar'. I was trying to include the spring-dao.jar.

    Thanks,
    Rishikesh R.

    Comment

    Working...
    X