Spring LDAP Template Usage

萝らか妹 提交于 2019-12-06 00:35:09

A quick scan showed that it's the authenticationSource field of AbstractContextSource that is the culprit. That file includes the following comment on the afterPropertiesSet() method:

/**
* Checks that all necessary data is set and that there is no compatibility
* issues, after which the instance is initialized. Note that you need to
* call this method explicitly after setting all desired properties if using
* the class outside of a Spring Context.
*/
public void afterPropertiesSet() throws Exception {
    ...
}

That method then goes on to create an appropriate authenticationSource if you haven't provided one. As your test code above is most definitely not running within a Spring context, and you haven't explicitly set an authenticationSource, I think you need to edit your code as follows:

...
cs.setDirObjectFactory(factory.getClass ());

// Allow Spring to configure the Context Source:
cs.afterPropertiesSet();

LdapTemplate template = new LdapTemplate(cs);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!