/** * {@inheritDoc} */ @Override public LookupOperationContext newLookupContext( Dn dn, String... attributes ) { LookupOperationContext lookupContext = new LookupOperationContext( session, dn, attributes ); setup( lookupContext ); return lookupContext; }
/** * {@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 ); }
/** * {@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 ); }
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(); }
/** * 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." ); } }
LookupOperationContext loc = new LookupOperationContext( getAdminSession(), systemPartition.getSuffixDn(), SchemaConstants.ALL_ATTRIBUTES_ARRAY );
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 ); } }
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 ); } }
@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 ); } };
/** * 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; }
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(); }
LookupOperationContext lookupContext = new LookupOperationContext( null, schemaModificationAttributesDn ); lookupContext.setPartition( partition );
/** * 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 ) ); } }
/** * {@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 ); }
/** * {@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; } }
LookupOperationContext lookupContext = new LookupOperationContext( session, target, attrIds ); lookupContext.addRequestControls( convertControls( true, requestControls ) ); OperationManager operationManager = service.getOperationManager();
LookupOperationContext lookupContext = new LookupOperationContext( session, dn, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY ); lookupContext.setPartition( moveContext.getPartition() );
new LookupOperationContext( session, parentDn, SchemaConstants.ALL_ATTRIBUTES_ARRAY ); lookupContext.setPartition( opContext.getPartition() ); lookupContext.setTransaction( opContext.getTransaction() );
/** * {@inheritDoc} */ public void modify( ModifyOperationContext modifyContext ) throws LdapException { Entry entry = modifyContext.getEntry(); if ( entry == null ) { LookupOperationContext lookupCtx = new LookupOperationContext( modifyContext.getSession(), modifyContext.getDn() ); lookupCtx.setPartition( this ); lookupCtx.setTransaction( modifyContext.getTransaction() ); entry = wrapped.lookup( lookupCtx ); modifyContext.setEntry( entry ); } Entry targetEntry = SchemaUtils.getTargetEntry( modifyContext.getModItems(), entry ); boolean cascade = modifyContext.hasRequestControl( Cascade.OID ); boolean hasModification = synchronizer.modify( modifyContext, targetEntry, cascade ); if ( hasModification ) { wrapped.modify( modifyContext ); } if ( !modifyContext.getDn().equals( schemaModificationDN ) ) { updateSchemaModificationAttributes( modifyContext ); } }