Package javax.naming.directory

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


        // search one level scope for alias
        SearchControls controls = new SearchControls();
        controls.setDerefLinkFlag( true );
        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
        containerCtx.addToEnvironment( "java.naming.ldap.derefAliases", "never" );
        NamingEnumeration<SearchResult> ne = containerCtx.search( "", "(objectClass=*)", controls );
        assertTrue( ne.hasMore() );
        SearchResult sr = ne.next();
        assertEquals( "ou=favorite", sr.getName() );
        assertTrue( ne.hasMore() );
View Full Code Here


       
        // search one level with dereferencing turned on
        controls = new SearchControls();
        controls.setDerefLinkFlag( true );
        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
        containerCtx.addToEnvironment( "java.naming.ldap.derefAliases", "always" );
        ne = containerCtx.search( "", "(objectClass=*)", controls );
        assertTrue( ne.hasMore() );
        sr = ne.next();
        assertEquals( "ou=favorite", sr.getName() );
        assertFalse( ne.hasMore() );
View Full Code Here

       
        // search with base set to alias and dereferencing turned on
        controls = new SearchControls();
        controls.setDerefLinkFlag( false );
        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
        containerCtx.addToEnvironment( "java.naming.ldap.derefAliases", "always" );
        ne = containerCtx.search( "ou=bestFruit", "(objectClass=*)", controls );
        assertTrue( ne.hasMore() );
        sr = ne.next();
        assertEquals( "ldap://localhost:"+ ldapServer.getPort() +"/ou=favorite,ou=Fruits,ou=system", sr.getName() );
        assertFalse( ne.hasMore() );
View Full Code Here

    public void testRequestWithoutManageDsaITControl() throws Exception
    {
        DirContext ctx = getWiredContext( ldapServer );

        // this removes the ManageDsaIT control from the search request
        ctx.addToEnvironment( DirContext.REFERRAL, "throw" );

        SearchControls ctls = new SearchControls();
        String[] attrNames =
            { "objectClasses", "attributeTypes", "ldapSyntaxes", "matchingRules", "matchingRuleUse", "createTimestamp",
                "modifyTimestamp" };
View Full Code Here

                    first_name = getAttributeValue(attrs, ATTR_FIRSTNAME);
                    last_name = getAttributeValue(attrs, ATTR_LASTNAME);
                    // re-bind as user
                    conn.removeFromEnvironment(javax.naming.Context.SECURITY_PRINCIPAL);
                    conn.removeFromEnvironment(javax.naming.Context.SECURITY_CREDENTIALS);
                    conn.addToEnvironment(javax.naming.Context.SECURITY_PRINCIPAL, dnBuffer.toString());
                    conn.addToEnvironment(javax.naming.Context.SECURITY_CREDENTIALS, this.myOpaqueCredentials.credentialstring);
                    searchCtls = new SearchControls();
                    searchCtls.setReturningAttributes(new String[0]);
                    searchCtls.setSearchScope(SearchControls.OBJECT_SCOPE);
   
View Full Code Here

                    last_name = getAttributeValue(attrs, ATTR_LASTNAME);
                    // re-bind as user
                    conn.removeFromEnvironment(javax.naming.Context.SECURITY_PRINCIPAL);
                    conn.removeFromEnvironment(javax.naming.Context.SECURITY_CREDENTIALS);
                    conn.addToEnvironment(javax.naming.Context.SECURITY_PRINCIPAL, dnBuffer.toString());
                    conn.addToEnvironment(javax.naming.Context.SECURITY_CREDENTIALS, this.myOpaqueCredentials.credentialstring);
                    searchCtls = new SearchControls();
                    searchCtls.setReturningAttributes(new String[0]);
                    searchCtls.setSearchScope(SearchControls.OBJECT_SCOPE);
   
                    String attrSearch = "(" + ldapConn.getUidAttribute() + "=*)";
 
View Full Code Here

    public void testRequestWithoutManageDsaITControl() throws Exception
    {
        DirContext ctx = getWiredContext( ldapServer );

        // this removes the ManageDsaIT control from the search request
        ctx.addToEnvironment( DirContext.REFERRAL, "throw" );

        SearchControls ctls = new SearchControls();
        String[] attrNames =
            { "objectClasses", "attributeTypes", "ldapSyntaxes", "matchingRules", "matchingRuleUse", "createTimestamp",
                "modifyTimestamp" };
View Full Code Here

       
        Attributes attributes = createPerson( "description" );
        String oldRdn = getRdn( attributes, "description" );
        String newRdn = getRdn( attributes, "cn", "sn" );

        ctx.addToEnvironment( "java.naming.ldap.deleteRDN", "false" );
        ctx.rename( oldRdn, newRdn );

        // Check whether new Entry exists
        DirContext newCtx = ( DirContext ) ctx.lookup( newRdn );
        assertNotNull( newCtx );
View Full Code Here

       
        Attributes attributes = createPerson( "description" );
        String oldRdn = getRdn( attributes, "description" );
        String newRdn = getRdn( attributes, "cn", "sn" );

        ctx.addToEnvironment( "java.naming.ldap.deleteRDN", "true" );
        ctx.rename( oldRdn, newRdn );

        // Check whether new Entry exists
        DirContext newCtx = ( DirContext ) ctx.lookup( newRdn );
        assertNotNull( newCtx );
View Full Code Here

        Attributes attributes = createPerson( "cn" );
        attributes.put( "telephoneNumber", "12345" );
        String oldRdn = getRdn( attributes, "cn" );
        String newRdn = getRdn( attributes, "sn", "telephoneNumber" );

        ctx.addToEnvironment( "java.naming.ldap.deleteRDN", "false" );
        ctx.rename( oldRdn, newRdn );

        // Check whether new Entry exists
        DirContext newCtx = ( DirContext ) ctx.lookup( newRdn );
        assertNotNull( newCtx );
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.