Package org.apache.directory.server.core.jndi

Examples of org.apache.directory.server.core.jndi.ServerLdapContext


        {
            dn = "";
        }

        CoreSession session = service.getSession( principal );
        LdapContext ctx = new ServerLdapContext( service, session, new LdapName( dn ) );
        return ctx;
    }
View Full Code Here


        try
        {
            GetRecords getRecords = new GetRecords( question );
            String baseDn = catalog.getBaseDn( question.getDomainName() );
            CoreSession session = directoryService.getSession();
            DirContext dirContext = new ServerLdapContext( directoryService, session, new LdapName( baseDn ) );
            return getRecords.execute( dirContext, null );
        }
        catch ( LdapNoSuchObjectException lnnfe )
        {
            LOG.debug( "Name for DNS record search does not exist.", lnnfe );
View Full Code Here

    SingleBaseSearch( String searchBaseDn, DirectoryService directoryService )
    {
        try
        {
            CoreSession session = directoryService.getSession();
            ctx = new ServerLdapContext( directoryService, session, new LdapName( searchBaseDn ) );
        } catch ( Exception e )
        {
            throw new ServiceConfigurationException( I18n.err( I18n.ERR_649, searchBaseDn ), e );
        }
View Full Code Here

        {
            dn = "";
        }
       
        CoreSession session = service.getSession( principal );
        LdapContext ctx = new ServerLdapContext( service, session, new LdapName( dn ) );
        return ctx;
    }
View Full Code Here

            LdapDN userName = new LdapDN( "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 LdapDN( 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

        objectClass.add( "inetOrgPerson" );
        user.put( "sn", "bob" );
        user.put( "cn", "bob" );
        adminCtx.createSubcontext( "uid=bob,ou=users", user );

        ServerLdapContext ctx = ( ServerLdapContext ) adminCtx.lookup( "" );
        assertTrue( ctx.compare( new LdapDN( "uid=bob,ou=users,ou=system" ), "userPassword", "bobspassword" ) );
    }
View Full Code Here

     */
    @Test
    public void testAdminAccountCreation() throws Exception
    {
        String userDn = "uid=admin,ou=system";
        LdapContext ctx = new ServerLdapContext( service,
            service.getSession( new LdapDN( userDn ), "secret".getBytes() ), new LdapDN( "ou=system" ) );
        Attributes attrs = ctx.getAttributes( "uid=admin" );
        performAdminAccountChecks( attrs );
        assertTrue( ArrayUtils.isEquals( attrs.get( "userPassword" ).get(), StringTools.getBytesUtf8( "secret" ) ) );
        ctx.close();

        service.shutdown();
        service.startup();

        ctx = new ServerLdapContext( service,
            service.getSession( new LdapDN( userDn ), "secret".getBytes() ), new LdapDN( "ou=system" ) );
        attrs = ctx.getAttributes( "uid=admin" );
        performAdminAccountChecks( attrs );
        assertTrue( ArrayUtils.isEquals( attrs.get( "userPassword" ).get(), StringTools.getBytesUtf8( "secret" ) ) );
        ctx.close();
    }
View Full Code Here

    @Test
    public void test3UseAkarasulu() throws Exception
    {
        apply( service, getUserAddLdif() );
        String userDn = "uid=akarasulu,ou=users,ou=system";
        LdapContext ctx = new ServerLdapContext( service,
            service.getSession( new LdapDN( userDn ), "test".getBytes() ), new LdapDN( userDn ) );

        Attributes attrs = ctx.getAttributes( "" );
        Attribute ou = attrs.get( "ou" );
        assertTrue( ou.contains( "Engineering" ) );
        assertTrue( ou.contains( "People" ) );

        Attribute objectClass = attrs.get( "objectClass" );
View Full Code Here

     */
    @Test
    public void test8PassPrincAuthTypeSimple() throws Exception
    {
        String userDn = "uid=admin,ou=system";
        assertNotNull( new ServerLdapContext( service,
            service.getSession( new LdapDN( userDn ), "secret".getBytes() ), new LdapDN( userDn ) ) );
    }
View Full Code Here

    @Test
    public void test10TestNonAdminUser() throws Exception
    {
        apply( service, getUserAddLdif() );
        String userDn = "uid=akarasulu,ou=users,ou=system";
        assertNotNull( new ServerLdapContext( service,
            service.getSession( new LdapDN( userDn ), "test".getBytes() ), new LdapDN( userDn ) ) );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.server.core.jndi.ServerLdapContext

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.