} else { try { return new Dn(dn).getNormName(); } catch (LdapInvalidDnException e) { LOG.debug("Invalid DN", e);
/** * Creates a new instance of DefaultEntry, with a * Dn and a list of IDs. * * @param schemaManager The SchemaManager * @param dn The Dn for this serverEntry. Can be null. * @param elements The list of attributes to create. * @throws LdapException If the provided Dn or elements are invalid */ public DefaultEntry( SchemaManager schemaManager, String dn, Object... elements ) throws LdapException { this( schemaManager, new Dn( schemaManager, dn ), elements ); }
/** * Creates a new instance of DefaultEntry, with a Dn. * * @param dn The String Dn for this serverEntry. Can be null. * @throws LdapInvalidDnException If the Dn is invalid */ public DefaultEntry( String dn ) throws LdapInvalidDnException { this.dn = new Dn( dn ); }
/** * {@inheritDoc} */ @Override public String normalize( String value ) throws LdapException { Dn dn = new Dn( schemaManager, value ); return dn.getNormName(); }
/** * {@inheritDoc} */ @Override public boolean compare( String dn, String attributeName, byte[] value ) throws LdapException { return compare( new Dn( dn ), attributeName, value ); }
/** * {@inheritDoc} */ @Override public void setDn( String dn ) throws LdapInvalidDnException { setDn( new Dn( dn ) ); }
/** * {@inheritDoc} */ @Override public boolean compare( String dn, String attributeName, Value value ) throws LdapException { return compare( new Dn( dn ), attributeName, value ); }
/** * Read the configuration from the DIT, returning a bean containing all of it. * * @param baseDn The base Dn in the DIT where the configuration is stored * @param objectClass The element to read from the DIT * @return The bean containing the configuration for the required element * @throws ConfigurationException If the configuration cannot be read */ public ConfigBean readConfig( String baseDn, String objectClass ) throws LdapException { return readConfig( new Dn( baseDn ), objectClass ); }
/** * {@inheritDoc} */ @Override public EntryCursor search( String baseDn, String filter, SearchScope scope, String... attributes ) throws LdapException { return search( new Dn( baseDn ), filter, scope, attributes ); }
/** * {@inheritDoc} */ @Override public SearchFuture searchAsync( String baseDn, String filter, SearchScope scope, String... attributes ) throws LdapException { return searchAsync( new Dn( baseDn ), filter, scope, attributes ); }
/** * {@inheritDoc} */ @Override public void modify( String dn, Modification... modifications ) throws LdapException { modify( new Dn( dn ), modifications ); }
/** * {@inheritDoc} */ @Override public void bind( String name, String credentials ) throws LdapException { bind( new Dn( schemaManager, name ), credentials ); }
/** * {@inheritDoc} */ @Override public String normalize( String value, PrepareString.AssertionType assertionType ) throws LdapException { Dn dn = new Dn( schemaManager, value ); return dn.getNormName(); }
/** * Parses a Dn from a String * * @param name The Dn to parse * @return A valid Dn * @throws org.apache.directory.api.ldap.model.exception.LdapException If the Dn was invalid */ /* No protection*/static Dn parse( String name ) throws LdapException { Dn dn = new Dn(); parseDn( null, name, dn ); return dn; }
/** * Parses a Dn from a String * * @param name The Dn to parse * @return A valid Dn * @throws org.apache.directory.api.ldap.model.exception.LdapException If the Dn was invalid */ /* No protection*/static Dn parse( String name ) throws LdapException { Dn dn = new Dn(); parseDn( null, name, dn ); return dn; }
/** * Used to convert a dn of String to a Dn object * @param principalName The principal name to be convert. * @return * @throws org.apache.directory.api.ldap.model.exception.LdapInvalidDnException if a remote exception occurs. * @throws LdapInvalidAttributeValueException */ private Dn toDn(String principalName) throws LdapInvalidDnException, LdapInvalidAttributeValueException { String[] names = principalName.split("@"); String uid = names[0]; Dn dn = new Dn(new Rdn("uid", uid), new Dn(getConfig().getString("base_dn"))); return dn; }
/** * Read the configuration from the DIT, returning a bean containing all of it. * <p> * This method implicitly uses <em>"ou=config"</em> as base Dn * * @return The Config bean, containing the whole configuration * @throws ConfigurationException If we had some issue reading the configuration */ public ConfigBean readConfig() throws LdapException { // The starting point is the DirectoryService element return readConfig( new Dn( new Rdn( SchemaConstants.OU_AT, "config" ) ) ); }
public static CoreSession getCoreSession( String principalDn, DirectoryService service, String dn ) throws LdapException { if ( principalDn == null ) { principalDn = ""; } Dn userDn = new Dn( service.getSchemaManager(), principalDn ); LdapPrincipal principal = new LdapPrincipal( service.getSchemaManager(), userDn, AuthenticationLevel.SIMPLE ); CoreSession session = service.getSession( principal ); return session; }