use of javax.naming.ldap.LdapName in project spring-security by spring-projects.
the class FilterBasedLdapUserSearchTests method subTreeSearchSucceeds.
@Test
public void subTreeSearchSucceeds() throws Exception {
// Don't set the searchBase, so search from the root.
FilterBasedLdapUserSearch locator = new FilterBasedLdapUserSearch("", "(cn={0})", this.contextSource);
locator.setSearchSubtree(true);
DirContextOperations ben = locator.searchForUser("Ben Alex");
assertThat(ben.getStringAttribute("uid")).isEqualTo("ben");
assertThat(ben.getDn()).isEqualTo(new LdapName("uid=ben,ou=people"));
}
use of javax.naming.ldap.LdapName in project spring-security by spring-projects.
the class FilterBasedLdapUserSearchTests method basicSearchSucceeds.
@Test
public void basicSearchSucceeds() throws Exception {
FilterBasedLdapUserSearch locator = new FilterBasedLdapUserSearch("ou=people", "(uid={0})", this.contextSource);
locator.setSearchSubtree(false);
locator.setSearchTimeLimit(0);
locator.setDerefLinkFlag(false);
DirContextOperations bob = locator.searchForUser("bob");
assertThat(bob.getStringAttribute("uid")).isEqualTo("bob");
assertThat(bob.getDn()).isEqualTo(new LdapName("uid=bob,ou=people"));
}
use of javax.naming.ldap.LdapName in project spring-security by spring-projects.
the class FilterBasedLdapUserSearchTests method searchForNameWithCommaSucceeds.
@Test
public void searchForNameWithCommaSucceeds() throws Exception {
FilterBasedLdapUserSearch locator = new FilterBasedLdapUserSearch("ou=people", "(uid={0})", this.contextSource);
locator.setSearchSubtree(false);
DirContextOperations jerry = locator.searchForUser("jerry");
assertThat(jerry.getStringAttribute("uid")).isEqualTo("jerry");
assertThat(jerry.getDn()).isEqualTo(new LdapName("cn=mouse\\, jerry,ou=people"));
}
use of javax.naming.ldap.LdapName in project tests by datanucleus.
the class LDAPUtilTest method testLdapName.
public void testLdapName() throws Exception {
LdapName dn = new LdapName("cn=a,ou=b,dc=c");
// getRdn()
assertEquals("cn=a", dn.getRdn(dn.size() - 1).toString());
// getSuffix()
assertEquals("cn=a,ou=b,dc=c", dn.getSuffix(0).toString());
assertEquals("cn=a,ou=b", dn.getSuffix(1).toString());
assertEquals("cn=a", dn.getSuffix(2).toString());
assertEquals("", dn.getSuffix(3).toString());
assertEquals("", dn.getSuffix(dn.size()).toString());
// getPrefix
assertEquals("", dn.getPrefix(0).toString());
assertEquals("dc=c", dn.getPrefix(1).toString());
assertEquals("ou=b,dc=c", dn.getPrefix(2).toString());
assertEquals("cn=a,ou=b,dc=c", dn.getPrefix(3).toString());
}
use of javax.naming.ldap.LdapName in project directory-ldap-api by apache.
the class DnTest method testAddAllIntName.
/**
* Test for DIRSERVER-191
*/
@Test
public void testAddAllIntName() throws LdapException, InvalidNameException {
LdapName jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
Dn aName = new Dn("cn=four,cn=three,cn=two,cn=one");
assertSame(jName, jName.addAll(0, new LdapName("cn=zero,cn=zero.5")));
assertNotSame(aName, aName.add(new Dn("cn=zero,cn=zero.5")));
assertNotSame(jName.toString(), aName.toString());
assertSame(jName, jName.addAll(2, new LdapName("cn=zero,cn=zero.5")));
assertNotSame(aName, aName.add(new Dn("cn=zero,cn=zero.5")));
assertNotSame(jName.toString(), aName.toString());
assertSame(jName, jName.addAll(jName.size(), new LdapName("cn=zero,cn=zero.5")));
assertNotSame(aName, aName.add(new Dn("cn=zero,cn=zero.5")));
assertNotSame(jName.toString(), aName.toString());
}
Aggregations