Examples of LdapContext


Examples of javax.naming.ldap.LdapContext

    {
        SearchControls controls = new SearchControls();
        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
        controls.setDerefLinkFlag( false );

        LdapContext nullRootCtx = getRootContext( getService() );

        NamingEnumeration<SearchResult> list = nullRootCtx.search( "", "(cn=*)", controls );
        HashMap<String, Attributes> map = new HashMap<String, Attributes>();

        while ( list.hasMore() )
        {
            SearchResult result = list.next();
View Full Code Here

Examples of javax.naming.ldap.LdapContext

        controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
        controls.setDerefLinkFlag( false );
        controls.setReturningAttributes( new String[]
            { "*", "+" } );

        LdapContext nullRootCtx = getRootContext( getService() );

        NamingEnumeration<SearchResult> list = nullRootCtx.search( "", "(ou=testing01)", controls );
        Attributes rootDse = null;

        while ( list.hasMore() )
        {
            SearchResult result = list.next();
View Full Code Here

Examples of javax.naming.ldap.LdapContext

        controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
        controls.setDerefLinkFlag( false );
        controls.setReturningAttributes( new String[]
            { "*", "+" } );

        LdapContext nullRootCtx = getRootContext( getService() );

        NamingEnumeration<SearchResult> list = nullRootCtx.search( "", "(|(&(objectclass=posixGroup)(|(gidnumber=1)(gidnumber=1)))(objectClass=posixGroupp))", controls );
        Attributes rootDse = null;

        while ( list.hasMore() )
        {
            SearchResult result = list.next();
View Full Code Here

Examples of javax.naming.ldap.LdapContext


    @Test
    public void testSearchComplexFilter() throws Exception
    {
        LdapContext ctx = getWiredContext( getLdapServer() );
        SearchControls controls = new SearchControls();
        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
        controls.setTimeLimit( 10 );

        NamingEnumeration<SearchResult> result = ctx.search( "cn=Kim Wilde,ou=system",
            "(&(&(ObjectClass=person)(!(ObjectClass=strongAuthenticationUser))(sn=Wilde)))", controls );

        assertTrue( result.hasMore() );
        SearchResult sr = result.next();
        assertNotNull( sr );
        assertEquals( "Kim Wilde", sr.getAttributes().get( "cn" ).get() );

        // Now check with another version of the filter
        result = ctx.search( "cn=Kim Wilde,ou=system",
            "(&(sn=Wilde)(&(objectClass=person)(!(objectClass=strongAuthenticationUser))))", controls );

        assertTrue( result.hasMore() );
        sr = result.next();
        assertNotNull( sr );
View Full Code Here

Examples of javax.naming.ldap.LdapContext

     * are sent back to the client with a non-success result code.
     */
    @Test
    public void testThrowOnReferralWithJndi() throws Exception
    {
        LdapContext ctx = getWiredContextThrowOnRefferal( getLdapServer() );

        // modify failure
        Attribute attr = new BasicAttribute( "description", "referral to akarasulu" );
        ModificationItem mod = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );

        try
        {
            ctx.modifyAttributes( "uid=akarasuluref,ou=users,ou=system", new ModificationItem[]
                { mod } );
        }
        catch ( ReferralException e )
        {
            // seems JNDI only returns the first referral URL and not all so we test for it
            assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", e.getReferralInfo() );
        }

        ctx.close();
    }
View Full Code Here

Examples of javax.naming.ldap.LdapContext

     * are sent back to the client with a non-success result code.
     */
    @Test
    public void testThrowOnReferralWithJndi() throws Exception
    {
        LdapContext ctx = getWiredContextThrowOnRefferal( getLdapServer() );

        // delete success
        ctx.destroySubcontext( "ou=computers,uid=akarasulu,ou=users,ou=system" );

        try
        {
            ctx.lookup( "ou=computers,uid=akarasulu,ou=users,ou=system" );
            fail( "Should never get here." );
        }
        catch ( NameNotFoundException e )
        {
        }

        // referrals failure on delete
        try
        {
            ctx.destroySubcontext( "uid=akarasuluref,ou=users,ou=system" );
            fail( "Should never get here" );
        }
        catch ( ReferralException e )
        {
            // seems JNDI only returns the first referral URL and not all so we test for it
            assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", e.getReferralInfo() );
        }

        ctx.close();
    }
View Full Code Here

Examples of javax.naming.ldap.LdapContext


    @Test
    public void testMoveAndRdnChange() throws Exception
    {
        LdapContext ctx = getWiredContext( getLdapServer() );
        ctx.rename( DN, NEW_DN2 );

        SearchControls controls = new SearchControls();
        controls.setSearchScope( SearchControls.OBJECT_SCOPE );

        NamingEnumeration<SearchResult> results = ctx.search( NEW_DN2, "(objectClass=*)", controls );
        assertNotNull( results );
        assertTrue( "Could not find entry after move.", results.hasMore() );
        SearchResult result = results.next();
        assertNotNull( result );
        assertEquals( NEW_DN2, result.getNameInNamespace() );

        results.close();
        ctx.close();
    }
View Full Code Here

Examples of javax.naming.ldap.LdapContext

     * @throws NamingException
     */
    @Test
    public void testUnknownExtendedOperation() throws Exception
    {
        LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( "ou=system" );
        try
        {
            ctx.extendedOperation( new UnknownExtendedOperationRequest() );
            fail( "Calling an unknown extended operation should fail." );
        }
        catch ( CommunicationException ce )
        {
            // expected behaviour
View Full Code Here

Examples of javax.naming.ldap.LdapContext

     */
    protected LdapContext getContext( IoSession session, BindRequest bindRequest, Hashtable<String, Object> env )
    {
        LdapResult result = bindRequest.getResultResponse().getLdapResult();

        LdapContext ctx = null;

        try
        {
            Control[] connCtls = bindRequest.getControls().values().toArray( EMPTY );
            env.put( DirectoryService.JNDI_KEY, directoryService );
View Full Code Here

Examples of javax.naming.ldap.LdapContext

        // construct the configuration, get the port, create the service, and prepare kdc objects
        KdcConfiguration config = new KdcConfiguration(props);
        int port = PropertiesUtils.get(env, KdcConfiguration.KERBEROS_PORT_KEY, KdcConfiguration.DEFAULT_KERBEROS_PORT);
        Service service = new Service("kerberos", TransportType.DATAGRAM, new InetSocketAddress(port));
        LdapContext ctx = getBaseRealmContext(config, env);
        PrincipalStore store = new JndiPrincipalStoreImpl(ctx, new LdapName("ou=Users"));
        SamSubsystem.getInstance().setUserContext((DirContext) ctx, "ou=Users");

        try {
            minaRegistry.bind(service, new KerberosProtocolProvider(config, store));
View Full Code Here
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.