Examples of modifyAttributes()


Examples of javax.naming.directory.DirContext.modifyAttributes()

            // Connect to LDAP.
            DirContext ctx = LDAPUserManager.bindAsAdmin();

            // Remove the permission.
            ctx.modifyAttributes(dn, DirContext.REMOVE_ATTRIBUTE, attrs);

        }
        catch (NamingException ex)
        {
            throw new DataBackendException("NamingException caught", ex);

Examples of javax.naming.directory.DirContext.modifyAttributes()

            Attributes attrs = ldapUser.getLDAPAttributes();
            String name = ldapUser.getDN();

            DirContext ctx = bindAsAdmin();

            ctx.modifyAttributes(name, DirContext.REPLACE_ATTRIBUTE, attrs);
        }
        catch (NamingException ex)
        {
            throw new DataBackendException("NamingException caught", ex);
        }

Examples of javax.naming.directory.DirContext.modifyAttributes()

        Attribute attr = new BasicAttribute( "cn" );
        ModificationItem item = new ModificationItem( DirContext.REMOVE_ATTRIBUTE, attr );

        try
        {
            ctx.modifyAttributes( rdn, new ModificationItem[]
                { item } );
            fail( "modify should fail" );
        }
        catch ( SchemaViolationException e )
        {

Examples of javax.naming.directory.DirContext.modifyAttributes()

        Attribute attr = new BasicAttribute( "cn", "Kate Bush" );
        ModificationItem item = new ModificationItem( DirContext.REMOVE_ATTRIBUTE, attr );

        try
        {
            ctx.modifyAttributes( rdn, new ModificationItem[]
                { item } );
            fail( "modify should fail" );
        }
        catch ( SchemaViolationException e )
        {

Examples of javax.naming.directory.DirContext.modifyAttributes()

            "objectclass",
            "" ) );

        try
        {
            ctx.modifyAttributes( rdn, new ModificationItem[]
                { delModOp } );
            fail( "deletion of objectclass should fail" );
        }
        catch ( SchemaViolationException e )
        {

Examples of javax.naming.directory.DirContext.modifyAttributes()

        ModificationItem delModOp = new ModificationItem( DirContext.REMOVE_ATTRIBUTE, new BasicAttribute(
            "objectclass" ) );

        try
        {
            ctx.modifyAttributes( rdn, new ModificationItem[]
                { delModOp } );
            fail( "deletion of objectclass should fail" );
        }
        catch ( SchemaViolationException e )
        {

Examples of javax.naming.directory.DirContext.modifyAttributes()

        // add objectClass:krb5Principal and krb5PrincipalName:test to entry
        Attributes tn = new BasicAttributes( true );
        tn.put( new BasicAttribute( "objectClass", "krb5Principal", true ) );
        tn.put( new BasicAttribute( "krb5PrincipalName", "test", true ) );
        ctx.modifyAttributes( RDN, DirContext.ADD_ATTRIBUTE, tn );

        // remove objectClass:krb5Principal and krb5PrincipalName
        Attributes attrs = new BasicAttributes( true );
        attrs.put( new BasicAttribute( "objectClass", "krb5Principal", true ) );
        attrs.put( new BasicAttribute( "krb5PrincipalName" ) );

Examples of javax.naming.directory.DirContext.modifyAttributes()

        // remove objectClass:krb5Principal and krb5PrincipalName
        Attributes attrs = new BasicAttributes( true );
        attrs.put( new BasicAttribute( "objectClass", "krb5Principal", true ) );
        attrs.put( new BasicAttribute( "krb5PrincipalName" ) );
        ctx.modifyAttributes( RDN, DirContext.REMOVE_ATTRIBUTE, attrs );

        // Verify, that attributes are deleted
        attrs = ctx.getAttributes( RDN );
        assertNotNull( attrs.get( "objectClass" ) );
        assertFalse( attrs.get( "objectClass" ).contains( "krb5Principal" ) );

Examples of javax.naming.directory.DirContext.modifyAttributes()

        Attribute attr = new BasicAttribute( "telephoneNumber" );
        attr.add( newValues[0] );
        attr.add( newValues[1] );
        Attributes attrs = new BasicAttributes( true );
        attrs.put( attr );
        ctx.modifyAttributes( RDN_TORI_AMOS, DirContext.ADD_ATTRIBUTE, attrs );

        // Verify, that
        // - case of attribute description is correct
        // - attribute values are present
        attrs = ctx.getAttributes( RDN_TORI_AMOS );

Examples of javax.naming.directory.DirContext.modifyAttributes()

        Attribute desc2 = new BasicAttribute( "description" );
        desc2.add( descriptions[1] );
        ModificationItem delModOp = new ModificationItem(
            DirContext.REMOVE_ATTRIBUTE, desc2 );

        ctx.modifyAttributes( rdn, new ModificationItem[]
            { addModOp,
                delModOp } );

        SearchControls sctls = new SearchControls();
        sctls.setSearchScope( SearchControls.SUBTREE_SCOPE );
TOP
Copyright © 2018 www.massapi.com. 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.