需要帮助设置ActiveDirectoryLdapAuthenticationProvider的属性

时间:2012-01-25 16:53:54

标签: java active-directory spring-security spring-ldap

我的属性不再适用于春天。

我得到的错误是:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapActiveDirectoryAuthProvider' defined in class path resource [application-context-security.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'user-search-base' of bean class [org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider]: Bean property 'user-search-base' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1396)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    at com.wm.Ldap.AuthenticationExample.main(AuthenticationExample.java:38)
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'user-search-base' of bean class [org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider]: Bean property 'user-search-base' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
    at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1064)
    at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperI

mpl.java:924)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
    ... 13 more

这是我的代码:

<bean id="ldapActiveDirectoryAuthProvider" class="org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider">
        <constructor-arg value="someurl" /> 
        <constructor-arg value="ldaps://someurl" />
        <property name="user-search-base" value=""/>
        <property name="user-search-filter" value="(sAMAccountName={0})"/>
        <property name="group-search-base" value="ou=blahblah"/>
        <property name="group-search-filter" value="member={0}"/>
        <property name="role-prefix" value="ROLE_"/>
        <property name="user-details-class" value="person"/>

    </bean>

2 个答案:

答案 0 :(得分:2)

您指定的所有属性名称都无效,属性名称中不能包含破折号(因为它们映射到setter)。

答案 1 :(得分:1)

“user-search-base”应包含类似

的内容
"OU=myou,dc=xx,dc=yy"