Package org.apache.directory.ldap.client.api.message

Examples of org.apache.directory.ldap.client.api.message.ModifyRequest


     * @throws Exception if there is a problem adding the attribute
     */
    public static void addEntryACI( DN dn, String aciItem ) throws Exception
    {
        // modify the entry relative to ou=system to include the aciItem
        ModifyRequest modReq = new ModifyRequest( dn );
        modReq.add( "entryACI", aciItem );

        getAdminConnection().modify( modReq );
    }
View Full Code Here


     * @throws Exception if there is a problem adding the attribute
     */
    public static void addSubentryACI( String aciItem ) throws Exception
    {
        // modify the entry relative to ou=system to include the aciItem
        ModifyRequest modReq = new ModifyRequest( new DN( "ou=system" ) );
        modReq.add( "subentryACI", aciItem );
        getAdminConnection().modify( modReq );
    }
View Full Code Here

     * @param aciItem the new value for the ACI item
     * @throws Exception if the modify fails
     */
    public static void changePresciptiveACI( String cn, String aciItem ) throws Exception
    {
        ModifyRequest req = new ModifyRequest( new DN( "cn=" + cn + "," + ServerDNConstants.SYSTEM_DN ) );
        req.replace( "prescriptiveACI", aciItem );
        getAdminConnection().modify( req );
    }
View Full Code Here

    }


    public static void addPrescriptiveACI( String cn, String aciItem ) throws Exception
    {
        ModifyRequest modReq = new ModifyRequest( new DN( "cn=" + cn + "," + ServerDNConstants.SYSTEM_DN ) );
        modReq.add( "prescriptiveACI", aciItem );
        getAdminConnection().modify( modReq );
    }
View Full Code Here

        DN userName = new DN( "uid=" + uid + ",ou=users,ou=system" );
        // compare the telephone numbers
        LdapConnection userConnection = getConnectionAs( userName, password );

        // modify the entry as the user
        ModifyRequest modReq = new ModifyRequest( entryDN );
        modReq.addModification( mods );
        ModifyResponse resp = userConnection.modify( modReq );

        if ( resp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
        {
            result = true;
View Full Code Here

        // create the entry as admin
        DN userName = new DN( "uid=" + uid + ",ou=users,ou=system" );
        // modify the entry as the user
        LdapConnection userConnection = getConnectionAs( userName, password );
        ModifyRequest modReq = new ModifyRequest( entryDN );
        modReq.addModification( attr, modOp );

        ModifyResponse resp = userConnection.modify( modReq );

        if ( resp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
        {
View Full Code Here

    {
        // modify the entry as the user
        DN userDN = new DN( "uid=" + uid + ",ou=users,ou=system" );
        LdapConnection connection = getConnectionAs( userDN, password );

        ModifyRequest modReq = new ModifyRequest( userDN );
        modReq.addModification( mods );

        ModifyResponse resp = connection.modify( modReq );

        return resp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS;
    }
View Full Code Here

        // tag after the addition before modify ADD
        Tag t0 = service.getChangeLog().tag();
        assertPresent( sysRoot, "ou=test5,ou=system" );

        // modify the test entry to add description and test new attr appears
        ModifyRequest modReq = new ModifyRequest( entry.getDn() );
        modReq.add( "description", "a desc value" );
        sysRoot.modify( modReq );

        Entry resusitated = ( ( SearchResultEntry ) sysRoot.lookup( "ou=test5,ou=system" ) ).getEntry();
        assertNotNull( resusitated );
        EntryAttribute description = resusitated.get( "description" );
        assertNotNull( description );
        assertEquals( "a desc value", description.getString() );

        // now revert and assert that the added entry re-appears
        service.revert( t0.getRevision() );
        resusitated = ( ( SearchResultEntry ) sysRoot.lookup( "ou=test5,ou=system" ) ).getEntry();
        assertNotNull( resusitated );
        assertNull( resusitated.get( "description" ) );

        // -------------------------------------------------------------------
        // Modify REPLACE Test
        // -------------------------------------------------------------------

        // add the attribute again and make sure it is old value
        modReq = new ModifyRequest( resusitated.getDn() );
        modReq.add( "description", "old value" );
        sysRoot.modify( modReq );
        resusitated = ( ( SearchResultEntry ) sysRoot.lookup( "ou=test5,ou=system" ) ).getEntry();
        assertNotNull( resusitated );
        description = resusitated.get( "description" );
        assertNotNull( description );
        assertEquals( description.getString(), "old value" );

        // now tag then replace the value to "new value" and confirm
        Tag t1 = service.getChangeLog().tag();
        modReq = new ModifyRequest( resusitated.getDn() );
        modReq.replace( "description", "new value" );
        sysRoot.modify( modReq );

        resusitated = ( ( SearchResultEntry ) sysRoot.lookup( "ou=test5,ou=system" ) ).getEntry();
        assertNotNull( resusitated );
        description = resusitated.get( "description" );
        assertNotNull( description );
        assertEquals( description.getString(), "new value" );

        // now revert and assert the old value is now reverted
        service.revert( t1.getRevision() );
        resusitated = ( ( SearchResultEntry ) sysRoot.lookup( "ou=test5,ou=system" ) ).getEntry();
        assertNotNull( resusitated );
        description = resusitated.get( "description" );
        assertNotNull( description );
        assertEquals( description.getString(), "old value" );


        // -------------------------------------------------------------------
        // Modify REMOVE Test
        // -------------------------------------------------------------------

        Tag t2 = service.getChangeLog().tag();
        modReq = new ModifyRequest( resusitated.getDn() );
        modReq.remove( "description", "old value" );
        sysRoot.modify( modReq );

        resusitated = ( ( SearchResultEntry ) sysRoot.lookup( "ou=test5,ou=system" ) ).getEntry();
        assertNotNull( resusitated );
        description = resusitated.get( "description" );
        assertNull( description );

        // now revert and assert the old value is now reverted
        service.revert( t2.getRevision() );
        resusitated = ( ( SearchResultEntry ) sysRoot.lookup( "ou=test5,ou=system" ) ).getEntry();
        assertNotNull( resusitated );
        description = resusitated.get( "description" );
        assertNotNull( description );
        assertEquals( description.getString(), "old value" );

        // -------------------------------------------------------------------
        // Modify Multi Operation Test
        // -------------------------------------------------------------------

        // add a userPassword attribute so we can test replacing it
        modReq = new ModifyRequest( resusitated.getDn() );
        modReq.add( "userPassword", "to be replaced" );
        sysRoot.modify( modReq );
        resusitated = ( ( SearchResultEntry ) sysRoot.lookup( "ou=test5,ou=system" ) ).getEntry();
        assertPassword( resusitated, "to be replaced" );

        modReq = new ModifyRequest( resusitated.getDn() );
        modReq.remove( "description", "old value" );
        modReq.add( "seeAlso", "ou=added" );
        modReq.replace( "userPassword", "a replaced value" );
       
        Tag t3 = service.getChangeLog().tag();

        // now make the modification and check that description is gone,
        // seeAlso is added, and that the userPassword has been replaced
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 ModifyRequest( new DN( userDn ) );
        modReq.replace( "userPassword", "newpwd" );
        connection.modify( modReq );

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

        Entry entry = ( ( SearchResultEntry ) connection.lookup( userDn ) ).getEntry();
        assertNotNull( entry );
        assertTrue( entry.get( "uid" ).contains( "akarasulu" ) );

        // now modify the password for akarasulu : 'secret', encrypted using SHA
        ModifyRequest modReq = new ModifyRequest( new DN( userDn ) );
        modReq.replace( "userPassword", "{SHA}5en6G6MezRroT3XKqkdPOmY/BfQ=" );
        connection.modify( modReq );

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

TOP

Related Classes of org.apache.directory.ldap.client.api.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.