org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException Java Examples

The following examples show how to use org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultPartitionNexus.java    From MyVirtualDirectory with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Partition getPartition( Dn dn ) throws LdapException
{
    Partition parent = null;

    synchronized ( partitionLookupTree )
    {
        parent = partitionLookupTree.getElement( dn );
    }

    if ( parent == null )
    {
        throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_268, dn ) );
    }
    else
    {
        return parent;
    }
}
 
Example #2
Source File: DefaultOperationManager.java    From MyVirtualDirectory with Apache License 2.0 6 votes vote down vote up
private Entry getOriginalEntry( OperationContext opContext ) throws LdapException
{
    // We have to use the admin session here, otherwise we may have
    // trouble reading the entry due to insufficient access rights
    CoreSession adminSession = opContext.getSession().getDirectoryService().getAdminSession();

    Entry foundEntry = adminSession.lookup( opContext.getDn(), SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES,
        SchemaConstants.ALL_USER_ATTRIBUTES );

    if ( foundEntry != null )
    {
        return foundEntry;
    }
    else
    {
        // This is an error : we *must* have an entry if we want to be able to rename.
        LdapNoSuchObjectException ldnfe = new LdapNoSuchObjectException( I18n.err( I18n.ERR_256_NO_SUCH_OBJECT,
            opContext.getDn() ) );

        throw ldnfe;
    }
}
 
Example #3
Source File: DefaultPartitionNexus.java    From MyVirtualDirectory with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Partition getPartition( Dn dn ) throws LdapException
{
    Partition parent = null;

    if ( !dn.isSchemaAware() )
    {
        dn.apply( schemaManager );
    }

    synchronized ( partitionLookupTree )
    {
        parent = partitionLookupTree.getElement( dn );
    }

    if ( parent == null )
    {
        throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_268, dn ) );
    }
    else
    {
        return parent;
    }
}
 
Example #4
Source File: DefaultOperationManager.java    From MyVirtualDirectory with Apache License 2.0 6 votes vote down vote up
private Entry getOriginalEntry( OperationContext opContext ) throws LdapException
{
    // We have to use the admin session here, otherwise we may have
    // trouble reading the entry due to insufficient access rights
    CoreSession adminSession = opContext.getSession().getDirectoryService().getAdminSession();

    Entry foundEntry = adminSession.lookup( opContext.getDn(), SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES,
        SchemaConstants.ALL_USER_ATTRIBUTES );

    if ( foundEntry != null )
    {
        return foundEntry;
    }
    else
    {
        // This is an error : we *must* have an entry if we want to be able to rename.
        LdapNoSuchObjectException ldnfe = new LdapNoSuchObjectException( I18n.err( I18n.ERR_256_NO_SUCH_OBJECT,
            opContext.getDn() ) );

        throw ldnfe;
    }
}
 
Example #5
Source File: LDAPIAMPoller.java    From aws-iam-ldap-bridge with Apache License 2.0 6 votes vote down vote up
private Entry getExistingGroup(Group iamGroup) throws Exception {
    Dn dn = directory.getDnFactory().create(String.format(GROUP_FMT, iamGroup.getGroupName()));

    LookupOperationContext lookupContext = new LookupOperationContext( directory.getAdminSession(),
            dn,
            SchemaConstants.ALL_USER_ATTRIBUTES, SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES);

    try {
        Entry groupEntry = directory.getPartitionNexus().lookup( lookupContext );
        if (groupEntry != null && groupEntry.hasObjectClass("iamgroup")) {
            return groupEntry;
        }
    } catch (LdapNoSuchObjectException e) {
        // Fallthrough
    }
    return null;
}
 
Example #6
Source File: LdapNetworkConnection.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ExtendedResponse extended( Oid oid, byte[] value ) throws LdapException
{
    Map<String, ExtendedOperationFactory> factories = LdapApiServiceFactory.getSingleton().getExtendedRequestFactories();
    String oidStr = oid.toString();
    
    ExtendedOperationFactory factory = factories.get( oidStr );
    
    if ( factory != null )
    {
        try
        {
            if ( value == null )
            {
                return extended( factory.newRequest() );
            }
            else
            {
                return extended( factory.newRequest( value ) );
            }
        }
        catch ( DecoderException de )
        {
            throw new LdapNoSuchObjectException( de.getMessage() );
        }
    }
    else
    {
        return extended( new OpaqueExtendedRequest( oidStr, value ) );
    }
}
 
Example #7
Source File: DefaultPartitionNexus.java    From MyVirtualDirectory with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Entry lookup( LookupOperationContext lookupContext ) throws LdapException
{
    Dn dn = lookupContext.getDn();

    if ( dn.equals( subschemSubentryDn ) )
    {
        return new ClonedServerEntry( rootDse.clone() );
    }

    // This is for the case we do a lookup on the rootDSE
    if ( dn.isRootDse() )
    {
        Entry retval = new ClonedServerEntry( rootDse );

        return retval;
    }

    Partition partition = getPartition( dn );
    Entry entry = partition.lookup( lookupContext );

    if ( entry == null )
    {
        LdapNoSuchObjectException e = new LdapNoSuchObjectException( "Attempt to lookup non-existant entry: "
            + dn.getName() );

        throw e;
    }

    return entry;
}
 
Example #8
Source File: DefaultOperationManager.java    From MyVirtualDirectory with Apache License 2.0 5 votes vote down vote up
/**
 * Eagerly populates fields of operation contexts so multiple Interceptors
 * in the processing pathway can reuse this value without performing a
 * redundant lookup operation.
 *
 * @param opContext the operation context to populate with cached fields
 */
private void eagerlyPopulateFields( OperationContext opContext ) throws LdapException
{
    // If the entry field is not set for ops other than add for example
    // then we set the entry but don't freak if we fail to do so since it
    // may not exist in the first place

    if ( opContext.getEntry() == null )
    {
        // We have to use the admin session here, otherwise we may have
        // trouble reading the entry due to insufficient access rights
        CoreSession adminSession = opContext.getSession().getDirectoryService().getAdminSession();

        LookupOperationContext lookupContext = new LookupOperationContext( adminSession, opContext.getDn(),
            SchemaConstants.ALL_ATTRIBUTES_ARRAY );
        Entry foundEntry = opContext.getSession().getDirectoryService().getPartitionNexus().lookup( lookupContext );

        if ( foundEntry != null )
        {
            opContext.setEntry( foundEntry );
        }
        else
        {
            // This is an error : we *must* have an entry if we want to be able to rename.
            LdapNoSuchObjectException ldnfe = new LdapNoSuchObjectException( I18n.err( I18n.ERR_256_NO_SUCH_OBJECT,
                opContext.getDn() ) );

            throw ldnfe;
        }
    }
}
 
Example #9
Source File: DefaultPartitionNexus.java    From MyVirtualDirectory with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Entry lookup( LookupOperationContext lookupContext ) throws LdapException
{
    Dn dn = lookupContext.getDn();

    if ( dn.equals( subschemSubentryDn ) )
    {
        return new ClonedServerEntry( rootDse.clone() );
    }

    // This is for the case we do a lookup on the rootDSE
    if ( dn.isRootDse() )
    {
        Entry retval = new ClonedServerEntry( rootDse );

        return retval;
    }

    Partition partition = getPartition( dn );
    Entry entry = partition.lookup( lookupContext );

    if ( entry == null )
    {
        LdapNoSuchObjectException e = new LdapNoSuchObjectException( "Attempt to lookup non-existant entry: "
            + dn.getName() );

        throw e;
    }

    return entry;
}
 
Example #10
Source File: DefaultOperationManager.java    From MyVirtualDirectory with Apache License 2.0 5 votes vote down vote up
/**
 * Eagerly populates fields of operation contexts so multiple Interceptors
 * in the processing pathway can reuse this value without performing a
 * redundant lookup operation.
 *
 * @param opContext the operation context to populate with cached fields
 */
private void eagerlyPopulateFields( OperationContext opContext ) throws LdapException
{
    // If the entry field is not set for ops other than add for example
    // then we set the entry but don't freak if we fail to do so since it
    // may not exist in the first place

    if ( opContext.getEntry() == null )
    {
        // We have to use the admin session here, otherwise we may have
        // trouble reading the entry due to insufficient access rights
        CoreSession adminSession = opContext.getSession().getDirectoryService().getAdminSession();

        LookupOperationContext lookupContext = new LookupOperationContext( adminSession, opContext.getDn(),
            SchemaConstants.ALL_ATTRIBUTES_ARRAY );
        Entry foundEntry = opContext.getSession().getDirectoryService().getPartitionNexus().lookup( lookupContext );

        if ( foundEntry != null )
        {
            opContext.setEntry( foundEntry );
        }
        else
        {
            // This is an error : we *must* have an entry if we want to be able to rename.
            LdapNoSuchObjectException ldnfe = new LdapNoSuchObjectException( I18n.err( I18n.ERR_256_NO_SUCH_OBJECT,
                opContext.getDn() ) );

            throw ldnfe;
        }
    }
}
 
Example #11
Source File: LDAPIAMPoller.java    From aws-iam-ldap-bridge with Apache License 2.0 5 votes vote down vote up
private Entry getExistingRole(Role role) throws LdapException {
    LookupOperationContext lookupContext = new LookupOperationContext( directory.getAdminSession(),
            directory.getDnFactory().create(String.format(ROLE_FMT, role.getRoleName())), SchemaConstants.ALL_USER_ATTRIBUTES, SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES);

    try {
        Entry roleEntry = directory.getPartitionNexus().lookup( lookupContext );
        if (roleEntry != null && roleEntry.hasObjectClass("iamaccount")) {
            return roleEntry;
        }
    } catch (LdapNoSuchObjectException e) {
        // Fallthrough
    }
    return null;
}
 
Example #12
Source File: LDAPIAMPoller.java    From aws-iam-ldap-bridge with Apache License 2.0 5 votes vote down vote up
private Entry getExistingUser(User user) throws LdapException {
    LookupOperationContext lookupContext = new LookupOperationContext( directory.getAdminSession(),
            directory.getDnFactory().create(String.format(USER_FMT, user.getUserName())), SchemaConstants.ALL_USER_ATTRIBUTES, SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES);

    try {
        Entry userEntry = directory.getPartitionNexus().lookup( lookupContext );
        if (userEntry != null && userEntry.hasObjectClass("iamaccount")) {
            return userEntry;
        }
    } catch (LdapNoSuchObjectException e) {
        // Fallthrough
    }
    return null;
}