Package org.apache.directory.shared.ldap.model.message

Examples of org.apache.directory.shared.ldap.model.message.ModifyRequest


        catch ( Exception e )
        {
            fail( e.getMessage() );
        }

        ModifyRequest modifyRequest = ( ModifyRequest ) parser.getBatchRequest().getCurrentRequest();

        Collection<Modification> modifications = modifyRequest.getModifications();
        assertEquals( 1, modifications.size() );

        Modification modification = modifications.iterator().next();

        assertEquals( ModificationOperation.ADD_ATTRIBUTE, modification.getOperation() );
View Full Code Here


     */
    public Element toDsml( Element root )
    {
        Element element = super.toDsml( root );

        ModifyRequest request = ( ModifyRequest ) getDecorated();

        // Dn
        if ( request.getName() != null )
        {
            element.addAttribute( "dn", request.getName().getName() );
        }

        // Modifications
        Collection<Modification> modifications = request.getModifications();

        for ( Modification modification : modifications )
        {
            Element modElement = element.addElement( "modification" );

View Full Code Here

public void testModify() throws Exception
{
    Dn dn = new Dn( "uid=admin,ou=system" );

    String expected = String.valueOf( System.currentTimeMillis() );
    ModifyRequest modRequest = new ModifyRequestImpl();
    modRequest.setName( dn );
    modRequest.replace( SchemaConstants.SN_AT, expected );

    connection.modify( modRequest );

    Entry entry = session.lookup( dn );
View Full Code Here

    String gn = lookupEntry.get( "givenName" ).getString();
    assertEquals( "test", gn );

    // Now, replace the givenName
    ModifyRequest modifyRequest = new ModifyRequestImpl();
    modifyRequest.setName( dn );
    modifyRequest.replace( "givenName" );
    connection.modify( modifyRequest );

    lookupEntry = session.lookup( dn );
    Attribute giveName = lookupEntry.get( "givenName" );
    assertNull( giveName );
View Full Code Here

public void modifyAsync() throws Exception
{
    Dn dn = new Dn( "uid=admin,ou=system" );

    String expected = String.valueOf( System.currentTimeMillis() );
    ModifyRequest modifyRequest = new ModifyRequestImpl();
    modifyRequest.setName( dn );
    modifyRequest.replace( SchemaConstants.SN_AT, expected );

    assertTrue( session.exists( dn ) );

    ModifyFuture modifyFuture = connection.modifyAsync( modifyRequest );
View Full Code Here

@Test
public void testModifyEntryUUIDAndEntryCSN() throws Exception
{
    Dn dn = new Dn( "uid=admin,ou=system" );

    ModifyRequest modifyRequest = new ModifyRequestImpl();
    modifyRequest.setName( dn );
    modifyRequest.replace( SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString() );

    ModifyResponse modResp = connection.modify( modifyRequest );
    assertEquals( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS, modResp.getLdapResult().getResultCode() );

    modifyRequest = new ModifyRequestImpl();
    modifyRequest.setName( dn );
    modifyRequest.replace( SchemaConstants.ENTRY_CSN_AT, new CsnFactory( 0 ).newInstance().toString() );

    // admin can modify the entryCsn
    modResp = connection.modify( modifyRequest );
    assertEquals( ResultCodeEnum.SUCCESS, modResp.getLdapResult().getResultCode() );
View Full Code Here

            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 );
View Full Code Here

    Dn dn = new Dn( "uid=admin,ou=system" );

    String modifierName = "uid=x,ou=system";
    String modifiedTime = DateUtils.getGeneralizedTime();

    ModifyRequest modifyRequest = new ModifyRequestImpl();
    modifyRequest.setName( dn );
    modifyRequest.replace( SchemaConstants.MODIFIERS_NAME_AT, modifierName );
    modifyRequest.replace( SchemaConstants.MODIFY_TIMESTAMP_AT, modifiedTime );

    ModifyResponse modResp = connection.modify( modifyRequest );
    assertEquals( ResultCodeEnum.SUCCESS, modResp.getLdapResult().getResultCode() );

    Entry loadedEntry = connection.lookup( dn.getName(), "+" );
View Full Code Here

            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 );
View Full Code Here

        assertTrue( entry.get( "cn" ).contains( "Alex Karasulu" ) );
        assertTrue( entry.get( "facsimiletelephonenumber" ).contains( "+1 408 555 9751" ) );
        assertTrue( entry.get( "roomnumber" ).contains( "4612" ) );

        // now modify the password for akarasulu
        ModifyRequest modReq = new ModifyRequestImpl();
        modReq.setName( new Dn( userDn ) );
        modReq.replace( "userPassword", "newpwd" );
        connection.modify( modReq );

        // close and try with old password (should fail)
        connection.close();
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.model.message.ModifyRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.