Announcement Announcement Module
No announcement yet.
Configuring spring-ldap to use weblogic ldap context Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Configuring spring-ldap to use weblogic ldap context


    Most of the examples i've found that show using spring-ldap to authenticate users, show examples using spring xml files to specify the context, such as

    <bean id="contextSource" class=" ontextSource">
    <!-- Figure out how to connect to WebLogic's LDAP security realm -->
    <property name="url" value="ldap://" />
    <property name="userDn" value="uid=admin,ou=system" />
    <property name="password" value="adminpassword" />

    seen here:

    I don't really understand this model, as this configuration means building it into a war file that is only clumsily available by users.

    what i want is for spring-ldap to configure itself with the application server's information, specifically in WebLogic the LDAP server specified in a security realm.

    Are there any samples of how one goes about doing this that i could look at?


    OK, so here's my attempt at this, I could be completely off base, and probably am but..

    In my Spring.xml file i have

    <bean id="contextSource" class="">

    <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate" >
    <constructor-arg ref="contextSource" />

    <bean id="authenticator" class="" >
    <property name="ldapTemplate" ref="ldapTemplate" />

    Where WebLogicContextSource is

    public class WebLogicContextSource extends LdapContextSource {

    public void afterPropertiesSet() throws Exception {
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    Set<ObjectName> names = mbs.queryNames(null, null);
    for (ObjectName name : names) {



    I was hoping to override LdapContextSource, use JMX to look up the url, credentials, etc of the ldap server in use, and then call setters in the parent to set the values.

    But break points aren't hitting in afterPropertiesSet, and instead i see

    Error creating bean with name 'contextSource' defined in ServletContext resource [/WEB-INF/ldap-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: At least one server url must be set

    Now i would have thought that if i overrode afterPropertiesSet and had a break point there, i wouldn't get this error message (yet).

    Obviously my afterPropertiesSet currently isn't doing anything about setting the serviceUrl and that has to be done, but as i have no idea how all this works i tossed in some debug code to try to figure it out. But I would have assumed that break points would be hit.

    Can anyone point in me in the right direction?

    Last edited by dbrosius; Apr 5th, 2011, 03:57 PM.

  • #2
    BreakPoints in afterPropertiesSet

    OK, so the exact problem here is that for some reason breakpoints are not being hit in this method, but it is being called. So i guess i can try to continue.

    I am able to pull properties defined in weblogic, and built ldap urls etc. This probably will work, but i realize that perhaps i can just get weblogic to authenticate users through some jmx operation.

    Alas, I don't see anything like this tho... Am i missing something? I guess the question is off topic for a spring forum, tho. oh well.
    Last edited by dbrosius; Apr 6th, 2011, 08:10 AM.