/** * Sets the LdapTemplate, and thus the ContextSource (implicitly). * * @param ldapTemplate the LdapTemplate to query the LDAP server from. CANNOT be NULL. */ public synchronized void setLdapTemplate(final LdapTemplate ldapTemplate) { Assert.notNull(ldapTemplate, "ldapTemplate cannot be null"); this.ldapTemplate = ldapTemplate; this.contextSource = this.ldapTemplate.getContextSource(); }
/** * Sets the LdapTemplate, and thus the ContextSource (implicitly). * * @param ldapTemplate the LdapTemplate to query the LDAP server from. CANNOT be NULL. */ public synchronized void setLdapTemplate(final LdapTemplate ldapTemplate) { Assert.notNull(ldapTemplate, "ldapTemplate cannot be null"); this.ldapTemplate = ldapTemplate; this.contextSource = this.ldapTemplate.getContextSource(); }
/** * Sets the LdapTemplate, and thus the ContextSource (implicitly). * * @param ldapTemplate the LdapTemplate to query the LDAP server from. CANNOT be NULL. */ public synchronized void setLdapTemplate(final LdapTemplate ldapTemplate) { Assert.notNull(ldapTemplate, "ldapTemplate cannot be null"); this.ldapTemplate = ldapTemplate; this.contextSource = this.ldapTemplate.getContextSource(); }
public Person findByDn(String dn) throws ToutaticeAnnuaireException { Person p = (Person) context.getBean("person"); try { PersonAttributMapper personAttributMapper = new PersonAttributMapper(); DirContext DC = ldapTemplateLecture.getContextSource().getReadOnlyContext(); int i = dn.lastIndexOf(BASE_DN); String subDn=""; if(i>0 && dn.length()>i){ subDn = dn.substring(0, i-1); p = (Person) ldapTemplateLecture.lookup(new DistinguishedName(subDn), personAttributMapper); }else{ p=null; } } catch (org.springframework.ldap.NameNotFoundException e) { logger.warn("Recherche d'une personne dans l'annuaire : l'identifiant n'existe pas " + dn); p=null; } return p; }
public Organisation findByDn(String dn) throws ToutaticeAnnuaireException { Organisation org = (Organisation) context.getBean("organisation"); try { OrganisationAttributMapper organisationAttributMapper = new OrganisationAttributMapper(); DirContext DC = ldapTemplateLecture.getContextSource().getReadOnlyContext(); int i = dn.lastIndexOf(BASE_DN); String subDn=""; if(i>0 && dn.length()>i){ subDn = dn.substring(0, i-1); org = (Organisation) ldapTemplateLecture.lookup(new DistinguishedName(subDn), organisationAttributMapper); }else{ org=null; } } catch (org.springframework.ldap.NameNotFoundException e) { logger.warn("Recherche d'une organisation dans l'annuaire : l'identifiant n'existe pas " + dn); org=null; } return org; }
public Profil findByDn(String dn) { Profil profil = (Profil)context.getBean("profil"); try { ProfilAttributMapper profilAttributMapper = new ProfilAttributMapper(); DirContext DC = ldapTemplateLecture.getContextSource().getReadOnlyContext(); String BASE_DN; BASE_DN = DC.getNameInNamespace(); int i = dn.lastIndexOf(BASE_DN); if(i>0 && dn.length()>=i) { String subDn = dn.substring(0, i-1); profil = (Profil) ldapTemplateLecture.lookup(new DistinguishedName(subDn), profilAttributMapper); } else { profil = null; } } catch (NamingException e) { profil = null; } catch (javax.naming.NamingException e) { profil = null; } return profil; }
public RoleApplicatif findByDn(String dn) { RoleApplicatif role = (RoleApplicatif) context.getBean("roleApplicatif"); try { RoleApplicatifAttributMapper roleApplicatifAttributMapper = new RoleApplicatifAttributMapper(); DirContext DC = ldapTemplateLecture.getContextSource().getReadOnlyContext(); String BASE_DN = DC.getNameInNamespace(); int i = dn.lastIndexOf(BASE_DN); if(i>=0){ String subDn = dn.substring(0, i-1); role = (RoleApplicatif) ldapTemplateLecture.lookup(new DistinguishedName(subDn), roleApplicatifAttributMapper); } else { role = null; logger.error("Recherche de role applicatif : le dn "+dn+" n'existe pas dans l'annuaire" ); } } catch (NameNotFoundException e) { logger.error("Recherche de role applicatif : le dn "+dn+" n'existe pas dans l'annuaire" ); role=null; } catch (javax.naming.NamingException e) { e.printStackTrace(); role=null; } return role; }
@Test public void testAuthenticate() { DirContext ctxt = ldapTemplate.getContextSource().getContext("some.person1", "password"); assertThat(ctxt).isNotNull(); } }
ContextSource contextSource = ldapTemplate.getContextSource(); if (contextSource instanceof BaseLdapPathContextSource) { dn = ((BaseLdapPathContextSource) contextSource).getBaseLdapPathAsString();
if (ldapUserDao.getLdapTemplate().getContextSource() != null) { List<User> users = ldapUserDao.getUsers(); checkRoles();
LdapTestUtils.cleanAndSetup(template.getContextSource(), new DistinguishedName("dc=example,dc=com"), new ClassPathResource("data.ldif"));
template.getContextSource(), new DistinguishedName("dc=example,dc=com"), new ClassPathResource(ldifPath));