private Entry getEntry( OperationContext opContext ) throws LdapException { /** * Exclude operational attributes while doing lookup * especially subentry related ones like "triggerExecutionSubentries". */ CoreSession session = opContext.getSession(); LookupOperationContext lookupContext = new LookupOperationContext( session, modifiedEntryName, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY ); lookupContext.setPartition( opContext.getPartition() ); lookupContext.setTransaction( opContext.getTransaction() ); return session.getDirectoryService().getPartitionNexus().lookup( lookupContext ); } }
LookupOperationContext lookupContext = new LookupOperationContext( session, target, attrIds ); lookupContext.addRequestControls( convertControls( true, requestControls ) ); OperationManager operationManager = service.getOperationManager(); Entry serverEntry = operationManager.lookup( lookupContext ); responseControls = JndiUtils.toJndiControls( getDirectoryService().getLdapCodecService(), lookupContext.getResponseControls() ); if ( ( lookupContext.getReturningAttributes() != null ) && ( lookupContext.getReturningAttributes().size() != 0 ) && ( serverEntry.get( SchemaConstants.OBJECT_CLASS_AT ) != null ) && ( serverEntry.get( SchemaConstants.OBJECT_CLASS_AT ).size() == 0 ) )
/** * {@inheritDoc} */ @Override public Entry lookup( LookupOperationContext lookupContext ) throws LdapException { Dn dn = lookupContext.getDn(); if ( dn.getNormName().equals( subschemaSubentryDn.getNormName() ) ) { Entry serverEntry = SchemaService.getSubschemaEntry( directoryService, lookupContext ); serverEntry.setDn( dn ); return serverEntry; } Entry entry = next( lookupContext ); denormalizeEntryOpAttrs( entry ); // Add the nbChildren/nbSubordinates attributes if required processSubordinates( lookupContext, lookupContext.getReturningAttributes(), lookupContext.isAllOperationalAttributes(), entry ); return entry; }
/** * {@inheritDoc} */ @Override public Entry lookup( Dn dn, Control[] controls, String... attrIds ) throws LdapException { OperationManager operationManager = directoryService.getOperationManager(); LookupOperationContext lookupContext = new LookupOperationContext( this, dn, attrIds ); if ( controls != null ) { lookupContext.addRequestControls( controls ); } return operationManager.lookup( lookupContext ); }
/** * Used to encapsulate [de]marshalling of controls before and after lookup operations. * * @param target The Dn we are looking for * @return The found entry * @throws Exception If the lookup failed */ protected Entry doLookupOperation( Dn target ) throws Exception { // setup the op context and populate with request controls // execute lookup/getRootDSE operation LookupOperationContext lookupContext = new LookupOperationContext( session, target ); lookupContext.addRequestControls( convertControls( true, requestControls ) ); OperationManager operationManager = service.getOperationManager(); Entry serverEntry = operationManager.lookup( lookupContext ); // clear the request controls and set the response controls requestControls = EMPTY_CONTROLS; responseControls = JndiUtils.toJndiControls( getDirectoryService().getLdapCodecService(), lookupContext.getResponseControls() ); return serverEntry; }
/** * {@inheritDoc} */ @Override public LookupOperationContext newLookupContext( Dn dn, String... attributes ) { LookupOperationContext lookupContext = new LookupOperationContext( session, dn, attributes ); setup( lookupContext ); return lookupContext; }
new LookupOperationContext( session, remoteEntry.getDn(), attributes ); lookupCtx.setSyncreplLookup( true ); lookupCtx.setTransaction( partitionTxn ); localEntry = session.getDirectoryService().getOperationManager().lookup( lookupCtx );
KerberosAttribute.KRB5_PRINCIPAL_NAME_AT, KerberosAttribute.KRB5_KEY_VERSION_NUMBER_AT ); lookupContext.setPartition( modContext.getPartition() ); lookupContext.setTransaction( modContext.getTransaction() );
/** * {@inheritDoc} */ @Override public Entry lookup( LookupOperationContext lookupContext ) throws LdapException { Dn dn = lookupContext.getDn(); if ( dn.getNormName().equals( subschemaSubentryDn.getNormName() ) ) { return new ClonedServerEntry( rootDse.clone() ); } // This is for the case we do a lookup on the rootDSE if ( dn.isRootDse() ) { return new ClonedServerEntry( rootDse ); } Partition partition = getPartition( dn ); Entry entry = partition.lookup( lookupContext ); if ( entry == null ) { throw new LdapNoSuchObjectException( "Attempt to lookup non-existant entry: " + dn.getName() ); } return entry; }
/** * {@inheritDoc} */ @Override public Entry lookup( Dn dn, String... attrIds ) throws LdapException { OperationManager operationManager = directoryService.getOperationManager(); LookupOperationContext lookupContext = new LookupOperationContext( this, dn, attrIds ); return operationManager.lookup( lookupContext ); }
private Entry getDeletedEntry( OperationContext opContext ) throws LdapException { /** * Using LOOKUP_EXCLUDING_OPR_ATTRS_BYPASS here to exclude operational attributes * especially subentry related ones like "triggerExecutionSubentries". */ CoreSession session = opContext.getSession(); LookupOperationContext lookupContext = new LookupOperationContext( session, deletedEntryName, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY ); lookupContext.setPartition( opContext.getPartition() ); lookupContext.setTransaction( opContext.getTransaction() ); return session.getDirectoryService().getPartitionNexus().lookup( lookupContext ); } }
public PersistentSearchListener( LdapSession session, SearchRequest req ) { this.session = session; this.req = req; req.addAbandonListener( this ); this.psearchControl = ( PersistentSearch ) req.getControls().get( PersistentSearch.OID ); filterCtx = new LookupOperationContext( session.getCoreSession(), req.getAttributes().toArray( Strings.EMPTY_STRING_ARRAY ) ); schemaManager = session.getCoreSession().getDirectoryService().getSchemaManager(); }
@Override public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws LdapException { Generic_LDAP_CONTEXT ldapCtxParam = ( Generic_LDAP_CONTEXT ) param; Dn ldapCtxName = ldapCtxParam.getCtxName(); CoreSession session = opContext.getSession(); LookupOperationContext lookupContext = new LookupOperationContext( session, ldapCtxName, SchemaConstants.ALL_ATTRIBUTES_ARRAY ); lookupContext.setPartition( opContext.getPartition() ); lookupContext.setTransaction( opContext.getTransaction() ); return session.getDirectoryService().getPartitionNexus().lookup( lookupContext ); } };
/** * Displays security warning messages if any possible secutiry issue is found. * @throws Exception if there are failures parsing and accessing internal structures */ protected void showSecurityWarnings() throws Exception { // Warn if the default password is not changed. boolean needToChangeAdminPassword = false; Dn adminDn = getDnFactory().create( ServerDNConstants.ADMIN_SYSTEM_DN ); Entry adminEntry = partitionNexus.lookup( new LookupOperationContext( adminSession, adminDn ) ); Value<?> userPassword = adminEntry.get( SchemaConstants.USER_PASSWORD_AT ).get(); needToChangeAdminPassword = Arrays.equals( PartitionNexus.ADMIN_PASSWORD_BYTES, userPassword.getBytes() ); if ( needToChangeAdminPassword ) { LOG.warn( "You didn't change the admin password of directory service " + "instance '" + instanceId + "'. " + "Please update the admin password as soon as possible " + "to prevent a possible security breach." ); } }
/** * {@inheritDoc} */ public void move( MoveOperationContext moveContext ) throws LdapException { boolean cascade = moveContext.hasRequestControl( Cascade.OID ); CoreSession session = moveContext.getSession(); LookupOperationContext lookupContext = new LookupOperationContext( session, moveContext.getDn(), SchemaConstants.ALL_ATTRIBUTES_ARRAY ); lookupContext.setPartition( this ); lookupContext.setTransaction( moveContext.getTransaction() ); Entry entry = session.getDirectoryService().getPartitionNexus().lookup( lookupContext ); synchronizer.move( moveContext, entry, cascade ); wrapped.move( moveContext ); updateSchemaModificationAttributes( moveContext ); }
LookupOperationContext loc = new LookupOperationContext( getAdminSession(), systemPartition.getSuffixDn(), SchemaConstants.ALL_ATTRIBUTES_ARRAY );
/** * {@inheritDoc} */ public void moveAndRename( MoveAndRenameOperationContext moveAndRenameContext ) throws LdapException { boolean cascade = moveAndRenameContext.hasRequestControl( Cascade.OID ); CoreSession session = moveAndRenameContext.getSession(); LookupOperationContext lookupContext = new LookupOperationContext( session, moveAndRenameContext.getDn(), SchemaConstants.ALL_ATTRIBUTES_ARRAY ); lookupContext.setPartition( this ); lookupContext.setTransaction( moveAndRenameContext.getTransaction() ); Entry entry = session.getDirectoryService().getPartitionNexus().lookup( lookupContext ); synchronizer.moveAndRename( moveAndRenameContext, entry, cascade ); wrapped.moveAndRename( moveAndRenameContext ); updateSchemaModificationAttributes( moveAndRenameContext ); }
/** * Gets attributes required for modifications. * * @param dn the dn of the entry to get * @return the entry's attributes (may be immutable if the schema subentry) * @throws Exception on error accessing the entry's attributes */ private Entry getAttributes( OperationContext opContext ) throws LdapException { Dn dn = opContext.getDn(); Entry serverEntry; // @todo make sure we're not putting in operational attributes that cannot be user modified if ( dn.equals( ServerDNConstants.CN_SCHEMA_DN ) ) { return SchemaService.getSubschemaEntryCloned( directoryService ); } else { CoreSession session = opContext.getSession(); LookupOperationContext lookupContext = new LookupOperationContext( session, dn, SchemaConstants.ALL_ATTRIBUTES_ARRAY ); lookupContext.setPartition( opContext.getPartition() ); lookupContext.setTransaction( opContext.getTransaction() ); serverEntry = directoryService.getPartitionNexus().lookup( lookupContext ); } return serverEntry; } }
public static Entry getSubschemaEntryCloned( DirectoryService directoryService ) throws LdapException { if ( schemaSubentry == null ) { Dn schemaModificationAttributesDn = new Dn( directoryService.getSchemaManager(), SchemaConstants.SCHEMA_MODIFICATIONS_DN ); Partition partition = directoryService.getSchemaPartition(); LookupOperationContext lookupContext = new LookupOperationContext( null, schemaModificationAttributesDn ); lookupContext.setPartition( partition ); try ( PartitionTxn partitionTxn = partition.beginReadTransaction() ) { lookupContext.setTransaction( partitionTxn ); generateSchemaSubentry( directoryService.getSchemaManager(), directoryService.getSchemaPartition().lookup( lookupContext ) ); } catch ( IOException ioe ) { throw new LdapOtherException( ioe.getMessage(), ioe ); } } return schemaSubentry.clone(); }
/** * Get the administrativePoint role */ private void checkAdministrativeRole( OperationContext opContext, Dn apDn ) throws LdapException { CoreSession session = opContext.getSession(); LookupOperationContext lookupContext = new LookupOperationContext( session, apDn, SchemaConstants.ALL_ATTRIBUTES_ARRAY ); lookupContext.setPartition( opContext.getPartition() ); lookupContext.setTransaction( opContext.getTransaction() ); Entry administrationPoint = directoryService.getPartitionNexus().lookup( lookupContext ); // The administrativeRole AT must exist and not be null Attribute administrativeRole = administrationPoint.get( directoryService.getAtProvider() .getAdministrativeRole() ); // check that administrativeRole has something valid in it for us if ( ( administrativeRole == null ) || ( administrativeRole.size() <= 0 ) ) { LOG.error( "The entry on {} is not an AdministrativePoint", apDn ); throw new LdapNoSuchAttributeException( I18n.err( I18n.ERR_306, apDn ) ); } }