Hello,
For the connection with my directory, i use spring-ldap.
I've got an OU: People which contains all the webmaster and i've got another OU:group which contains all the sites each webmaster can administrate.
My problem is i don't know how to get all the sites a webmaster can administrate.
To get a webmaster i'll do this :
Code:public Webmaster getWebmaster(String ou,String login) { Name dn = buildDn(ou,login); Webmaster webmaster = null; try { webmaster = (Webmaster)ldapTemplate.lookup(dn, new WebmasterContextMapper()); } catch (Exception e){ log.error("getWebmaster"+e); } return webmaster; }Code:protected Name buildDn(String ou,String login) { DistinguishedName dn = new DistinguishedName(); dn.add("ou", ou); dn.add("uid", login); return dn; }It works fine and i'll want to do the same thing to get all the sites for the webmaster. So I have done that :Code:private static class WebmasterContextMapper implements ContextMapper { public Object mapFromContext(Object ctx) { DirContextAdapter context = (DirContextAdapter)ctx; Webmaster webmaster = new Webmaster(); webmaster.setLogin(context.getStringAttribute("uid")); //webmaster.setPassword(context.getStringAttribute("userPassword")); webmaster.setRoles(context.getStringAttributes("businessCategory")); return webmaster; } }
Code:public String [] getWebmasterSites (String ou, String login){ String [] sites = null; Name dn= buildDnSites (ou, login); try { sites = (String [])ldapTemplate.lookup(dn, new WebmasterContextSitesMapper()); } catch (Exception e){ log.error("getWebmasterSites"+e); } return sites; }Code:protected Name buildDnSites(String ou,String login) { DistinguishedName dn = new DistinguishedName(); dn.add("ou", ou); dn.add("memberUid", login); return dn; }But it doesn't workCode:private static class WebmasterContextSitesMapper implements ContextMapper { public Object mapFromContext(Object ctx) { DirContextAdapter context = (DirContextAdapter)ctx; String [] sites= context.getStringAttributes("businessCategory"); return sites; } }. Can somebody help me please ?
Thanks![]()


. Can somebody help me please ?
Reply With Quote