Package org.apache.ldap.common.name

Examples of org.apache.ldap.common.name.LdapName


                "userPermissions { { " +
                "protectedItems {entry, allUserAttributeTypesAndValues}, " +
                "grantsAndDenials { grantRead, grantReturnDN, grantBrowse, grantDiscloseOnError } } } } }" );

        // get a context as the user and try a lookup of a non-existant entry under ou=groups,ou=system
        DirContext userCtx = getContextAs( new LdapName( "uid=billyd,ou=users,ou=system" ), "billyd" );
        try
        {
            userCtx.lookup( "cn=blah,ou=groups" );
        }
        catch( NamingException e )
View Full Code Here


        DirContext adminContext = getContextAsAdmin();

        try
        {
            // create the entry as admin
            LdapName userName = new LdapName( "uid="+uid+",ou=users,ou=system" );
            adminContext.createSubcontext( entryRdn, testEntry );

            // modify the entry as the user
            DirContext userContext = getContextAs( userName, password );
            userContext.modifyAttributes( entryRdn, mods );
View Full Code Here

        DirContext adminContext = getContextAsAdmin();

        try
        {
            // create the entry as admin
            LdapName userName = new LdapName( "uid="+uid+",ou=users,ou=system" );
            adminContext.createSubcontext( entryRdn, testEntry );

            // modify the entry as the user
            DirContext userContext = getContextAs( userName, password );
            userContext.modifyAttributes( entryRdn, modOp, mods );
View Full Code Here

            throws NamingException
    {
        try
        {
            // modify the entry as the user
            Name userEntry = new LdapName( "uid="+uid+",ou=users,ou=system" );
            DirContext userContext = getContextAs( userEntry, password, userEntry.toString() );
            userContext.modifyAttributes( "", modOp, mods );
            return true;
        }
        catch ( LdapNoPermissionException e )
        {
View Full Code Here

            throws NamingException
    {
        try
        {
            // modify the entry as the user
            Name userEntry = new LdapName( "uid="+uid+",ou=users,ou=system" );
            DirContext userContext = getContextAs( userEntry, password, userEntry.toString() );
            userContext.modifyAttributes( "", mods );
            return true;
        }
        catch ( LdapNoPermissionException e )
        {
View Full Code Here

        objectClass.add( "top" );
        objectClass.add( "organizationalUnit" );

        try
        {
            LdapName userName = new LdapName( "uid="+uid+",ou=users,ou=system" );
            DirContext userContext = getContextAs( userName, password );
            userContext.createSubcontext( entryRdn, testEntry );

            // delete the newly created context as the admin user
            DirContext adminContext = getContextAsAdmin();
View Full Code Here

        DirContext adminContext = getContextAsAdmin();

        try
        {
            // create the entry as admin
            LdapName userName = new LdapName( "uid="+uid+",ou=users,ou=system" );
            adminContext.createSubcontext( entryRdn, testEntry );

            // compare the telephone numbers
            DirContext userContext = getContextAs( userName, password );
            ServerLdapContext ctx = ( ServerLdapContext ) userContext.lookup( "" );
            ctx.compare( new LdapName( entryRdn + ",ou=system" ), "telephoneNumber", number );

            // don't return compare result which can be false but true since op was permitted
            return true;
        }
        catch ( LdapNoPermissionException e )
View Full Code Here

     * Test case to check the schema checker operates correctly when modify
     * operations replace objectClasses.
     */
    public void testPreventStructuralClassRemovalOnModifyReplace() throws Exception
    {
        Name name = new LdapName( "uid=akarasulu,ou=users,dc=example,dc=com" );
        int mod = DirContext.REPLACE_ATTRIBUTE;
        Attributes modifyAttributes = new BasicAttributes( true );
        modifyAttributes.put( new BasicAttribute( "cn" ) );

        ObjectClassRegistry ocRegistry = registries.getObjectClassRegistry();
View Full Code Here

     * Test case to check the schema checker operates correctly when modify
     * operations remove objectClasses.
     */
    public void testPreventStructuralClassRemovalOnModifyRemove() throws Exception
    {
        Name name = new LdapName( "uid=akarasulu,ou=users,dc=example,dc=com" );
        int mod = DirContext.REMOVE_ATTRIBUTE;
        Attributes modifyAttributes = new BasicAttributes( true );
        Attribute entryObjectClasses = new BasicAttribute( "objectClass" );
        entryObjectClasses.add( "top" );
        entryObjectClasses.add( "person" );
View Full Code Here

     * operations remove RDN attributes.
     */
    public void testPreventRdnChangeOnModifyRemove() throws Exception
    {
        int mod = DirContext.REMOVE_ATTRIBUTE;
        Name name = new LdapName( "ou=user,dc=example,dc=com" );
        Attributes attributes = new BasicAttributes( true );
        attributes.put( "cn", "does not matter" );

        // postive test which should pass
        SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes );

        // test should fail since we are removing the ou attribute
        attributes.put( new BasicAttribute( "ou" ) );
        try
        {
            SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes );
            fail( "should never get here due to a LdapSchemaViolationException being thrown" );
        }
        catch ( LdapSchemaViolationException e )
        {
            assertEquals( ResultCodeEnum.NOTALLOWEDONRDN, e.getResultCode() );
        }

        // test success using more than one attribute for the Rdn but not modifying rdn attribute
        name = new LdapName( "ou=users+cn=system users,dc=example,dc=com" );
        attributes = new BasicAttributes( true );
        attributes.put( "sn", "does not matter" );
        SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes );

        // test for failure when modifying Rdn attribute in multi attribute Rdn
View Full Code Here

TOP

Related Classes of org.apache.ldap.common.name.LdapName

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.