/** * Creates a new getDecoratedMessage() of ModifyRequestDsml. * * @param codec The LDAP Service to use */ public ModifyRequestDsml( LdapApiService codec ) { super( codec, new ModifyRequestImpl() ); }
/** * {@inheritDoc} */ @Override public ModifyRequest newModifyRequest( Dn dn ) { return new ModifyRequestImpl().setName( dn ); }
/** * {@inheritDoc} */ @Override public ModifyRequest newModifyRequest( Dn dn ) { return new ModifyRequestImpl().setName( dn ); }
/** * {@inheritDoc} */ @Override public ModifyRequest newModifyRequest( Dn dn ) { return new ModifyRequestImpl().setName( dn ); }
/** * {@inheritDoc} */ @Override public void modify( Dn dn, Modification... modifications ) throws LdapException { if ( dn == null ) { LOG.debug( "received a null dn for modification" ); throw new IllegalArgumentException( "The Dn to be modified cannot be null" ); } if ( ( modifications == null ) || ( modifications.length == 0 ) ) { String msg = "Cannot process a ModifyRequest without any modification"; LOG.debug( msg ); throw new IllegalArgumentException( msg ); } int newId = messageId.incrementAndGet(); ModifyRequest modifyRequest = new ModifyRequestImpl(); modifyRequest.setMessageId( newId ); modifyRequest.setName( dn ); for ( Modification modification : modifications ) { modifyRequest.addModification( modification ); } ModifyResponse modifyResponse = modify( modifyRequest ); processResponse( modifyResponse ); }
/** * {@inheritDoc} */ @Override public void modify( Entry entry, ModificationOperation modOp ) throws LdapException { if ( entry == null ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_04140_NULL_ENTRY_MODIFY ) ); } throw new IllegalArgumentException( I18n.err( I18n.ERR_04133_NULL_MODIFIED_ENTRY ) ); } ModifyRequest modReq = new ModifyRequestImpl(); modReq.setName( entry.getDn() ); Iterator<Attribute> itr = entry.iterator(); while ( itr.hasNext() ) { modReq.addModification( itr.next(), modOp ); } ModifyResponse modifyResponse = modify( modReq ); processResponse( modifyResponse ); }
ModifyRequest modReq = new ModifyRequestImpl(); modReq.setName( dn );
/** * {@inheritDoc} */ @Override public void modify( Entry entry, ModificationOperation modOp ) throws LdapException { if ( entry == null ) { LOG.debug( "received a null entry for modification" ); throw new IllegalArgumentException( "Entry to be modified cannot be null" ); } int newId = messageId.incrementAndGet(); ModifyRequest modifyRequest = new ModifyRequestImpl(); modifyRequest.setMessageId( newId ); modifyRequest.setName( entry.getDn() ); Iterator<Attribute> itr = entry.iterator(); while ( itr.hasNext() ) { modifyRequest.addModification( new DefaultModification( modOp, itr.next() ) ); } ModifyResponse modifyResponse = modify( modifyRequest ); processResponse( modifyResponse ); }
/** * {@inheritDoc} */ @Override public void modify( Entry entry, ModificationOperation modOp ) throws LdapException { if ( entry == null ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_04140_NULL_ENTRY_MODIFY ) ); } throw new IllegalArgumentException( I18n.err( I18n.ERR_04133_NULL_MODIFIED_ENTRY ) ); } ModifyRequest modReq = new ModifyRequestImpl(); modReq.setName( entry.getDn() ); Iterator<Attribute> itr = entry.iterator(); while ( itr.hasNext() ) { modReq.addModification( itr.next(), modOp ); } ModifyResponse modifyResponse = modify( modReq ); processResponse( modifyResponse ); }
/** * {@inheritDoc} */ @Override public void modify( Entry entry, ModificationOperation modOp ) throws LdapException { if ( entry == null ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_04140_NULL_ENTRY_MODIFY ) ); } throw new IllegalArgumentException( I18n.err( I18n.ERR_04133_NULL_MODIFIED_ENTRY ) ); } ModifyRequest modReq = new ModifyRequestImpl(); modReq.setName( entry.getDn() ); Iterator<Attribute> itr = entry.iterator(); while ( itr.hasNext() ) { modReq.addModification( itr.next(), modOp ); } ModifyResponse modifyResponse = modify( modReq ); processResponse( modifyResponse ); }
/** * {@inheritDoc} */ @Override public void action( LdapMessageContainer<ModifyRequestDecorator> container ) { // Now, we can allocate the ModifyRequest Object ModifyRequest internalModifyRequest = new ModifyRequestImpl(); internalModifyRequest.setMessageId( container.getMessageId() ); ModifyRequestDecorator modifyRequestDecorator = new ModifyRequestDecorator( container.getLdapCodecService(), internalModifyRequest ); container.setMessage( modifyRequestDecorator ); } }
/** * {@inheritDoc} */ @Override public void action( LdapMessageContainer<ModifyRequestDecorator> container ) { // Now, we can allocate the ModifyRequest Object ModifyRequest internalModifyRequest = new ModifyRequestImpl(); internalModifyRequest.setMessageId( container.getMessageId() ); ModifyRequestDecorator modifyRequestDecorator = new ModifyRequestDecorator( container.getLdapCodecService(), internalModifyRequest ); container.setMessage( modifyRequestDecorator ); } }
/** * {@inheritDoc} */ @Override public void action( LdapMessageContainer<ModifyRequestDecorator> container ) { // Now, we can allocate the ModifyRequest Object ModifyRequest internalModifyRequest = new ModifyRequestImpl(); internalModifyRequest.setMessageId( container.getMessageId() ); ModifyRequestDecorator modifyRequestDecorator = new ModifyRequestDecorator( container.getLdapCodecService(), internalModifyRequest ); container.setMessage( modifyRequestDecorator ); } }
private void removeMemberFromRoleOrGroup(final CoreSession session, final String dn, final String memberDN, final String attributeName) throws LdapException { final Entry entry = session.lookup(new Dn(dn), attributeName); final Attribute attribute = entry.get(attributeName); if (attribute != null) { attribute.remove(memberDN); final ModifyRequestImpl modifyRequestImpl = new ModifyRequestImpl(); modifyRequestImpl.setName(entry.getDn()); modifyRequestImpl.replace(attribute); session.modify(modifyRequestImpl); } }
@Override public ResultResponse process() throws PasswordException, LdapException { // Can't use Password Modify: // https://issues.apache.org/jira/browse/DIRSERVER-1935 // So revert to regular Modify MemoryClearingBuffer newPasswordBuffer = MemoryClearingBuffer.newInstance( newPassword ); try { ModifyRequest modifyRequest = new ModifyRequestImpl() .setName( userDn ) .replace( "userPassword", newPasswordBuffer.getComputedBytes() ) .addControl( passwordPolicyRequestControl ); return connection.modify( modifyRequest ); } finally { newPasswordBuffer.clear(); } } } );
@Override public ResultResponse process() throws PasswordException, LdapException { // Can't use Password Modify: // https://issues.apache.org/jira/browse/DIRSERVER-1935 // So revert to regular Modify MemoryClearingBuffer newPasswordBuffer = MemoryClearingBuffer.newInstance( newPassword ); try { ModifyRequest modifyRequest = new ModifyRequestImpl() .setName( userDn ) .replace( "userPassword", newPasswordBuffer.getComputedBytes() ) .addControl( passwordPolicyRequestControl ); return connection.modify( modifyRequest ); } finally { newPasswordBuffer.clear(); } } } );
@Override public ResultResponse process() throws PasswordException, LdapException { // Can't use Password Modify: // https://issues.apache.org/jira/browse/DIRSERVER-1935 // So revert to regular Modify MemoryClearingBuffer newPasswordBuffer = MemoryClearingBuffer.newInstance( newPassword ); try { ModifyRequest modifyRequest = new ModifyRequestImpl() .setName( userDn ) .replace( "userPassword", newPasswordBuffer.getComputedBytes() ) .addControl( passwordPolicyRequestControl ); return connection.modify( modifyRequest ); } finally { newPasswordBuffer.clear(); } } } );
private void addMemberToRoleOrGroup(final CoreSession session, final String dn, final String memberDN, final String attributeName) throws LdapException { final Entry entry = session.lookup(new Dn(dn), attributeName); Attribute attribute = entry.get(attributeName); if (attribute == null) { entry.add(attributeName, memberDN); attribute = entry.get(attributeName); } else { attribute.add(memberDN); } final ModifyRequestImpl modifyRequestImpl = new ModifyRequestImpl(); modifyRequestImpl.setName(entry.getDn()); modifyRequestImpl.replace(attribute); session.modify(modifyRequestImpl); }
@Override public Response<Void> modify(final ModifyRequest request) throws LdapException { Response<Void> response = null; try { final ApacheLdapUtils bu = new ApacheLdapUtils(); final ModifyRequestImpl mri = new ModifyRequestImpl(); if (request.getControls() != null) { mri.addAllControls(config.getControlProcessor().processRequestControls(request.getControls())); } mri.setName(new Dn(request.getDn())); for (Modification m : bu.fromAttributeModification(request.getAttributeModifications())) { mri.addModification(m); } final ModifyResponse mr = connection.modify(mri); throwOperationException(request, mr); response = createResponse(request, null, mr); } catch (LdapOperationException e) { processLdapOperationException(e); } catch (org.apache.directory.api.ldap.model.exception.LdapException e) { processLdapException(e); } return response; }
try { Dn dn = toDn(principalName); ModifyRequest modifyRequest = new ModifyRequestImpl(); modifyRequest.setName(dn); modifyRequest.replace(KerberosAttribute.KRB5_KEY_VERSION_NUMBER_AT,