I'm debugging through the code below to see if I can search two different ou's based on a condition. I was under the assumption that I could specify the BaseName and that would tell where I wanted to search from.
For instance. If I wanted to search: ou=People, o=xxx, dc=xxx,dc=xxxxxx,dc=xxxx,dc=mil - I would pass that into LdapTemplate.search().
If I wanted to search: ou=Places, o=xxx, dc=xxx,dc=xxxxxx,dc=xxxx,dc=mil - I would pass that in.
Anytime I pass anything in other than empty string, I get an error:
I'm specifying the following (note i replaced values with 'x' because it's gov't):Code:org.springframework.ldap.NameNotFoundException: [LDAP: error code 32 - No Such Object]; nested exception is javax.naming.NameNotFoundException: [LDAP: error code 32 - No Such Object]; remaining name 'ou=People, o=xxx, dc=xxx,dc=xxx,dc=xxx,dc=mil'
Spring Config:Code:ApplicationContext ctx = new FileSystemXmlApplicationContext("//myDir/war/src/main/webapp/WEB-INF/lmsExport-config.xml"); String[] attrs = new String[]{"iplanet-am-user-login-status", "RxxxUsageCd", "createTimestamp", "mail", "xxxxxCd", "suffix", "xxxxssn", "uid", "givenName", "initials", "sn", "personaltitle", "userxxx", "title"}; String base = "ou=People, o=jrotc, dc=xxx,dc=xxxxxx,dc=xxxx,dc=mil"; LdapWorker csv = (LdapWorker) ctx.getBean("ldapWorker"); LdapTemplate ldt = csv.getLdapTemplate(); List x = new LinkedList(); try { x = ldt.search(base, "uid=z*", SearchControls.ONELEVEL_SCOPE, attrs, new AttributesMapper() { public String mapFromAttributes(Attributes attributes) throws NamingException { return (String) attributes.get("mail").get(); } }); } catch (Exception e) { System.out.println("ERROR ERROR ERROR"); }Any help would be appreciated.Code:<bean id="lmsContextSource" class="org.springframework.ldap.core.support.LdapContextSource"> <property name="url" value="ldap://xxxx.xxx.xxxx.mil:389"/> <property name="base" value="ou=people,o=xxx,dc=xxx,dc=xxx,dc=xxx,dc=mil"/> <property name="userDn" value="uid=xxx,ou=people,dc=xxx,dc=xxx,dc=xxx,dc=mil"/> <property name="password" value="*****"/> </bean> <bean id="lmsLdapTemplate" class="org.springframework.ldap.core.LdapTemplate"> <constructor-arg ref="lmsContextSource"/> </bean>


Reply With Quote
