Package javax.naming.ldap

Examples of javax.naming.ldap.InitialLdapContext


        env.put( "java.naming.provider.url", "ldap://" + host + ":" + port );
        env.put( "java.naming.security.principal", "uid=admin,ou=system" );
        env.put( "java.naming.security.credentials", password );
        env.put( "java.naming.security.authentication", "simple" );

        LdapContext ctx = new InitialLdapContext( env, null );
        if ( isDebugEnabled() )
        {
            System.out.println( "Connection to the server established.\n" + "Sending extended request ... " );
        }
        ctx.extendedOperation( new LaunchDiagnosticUiRequest( 3 ) );
        ctx.close();
    }
View Full Code Here


        env.put( "java.naming.provider.url", "ldap://" + host + ":" + port );
        env.put( "java.naming.security.principal", "uid=admin,ou=system" );
        env.put( "java.naming.security.credentials", password );
        env.put( "java.naming.security.authentication", "simple" );

        LdapContext ctx = new InitialLdapContext( env, null );
        if ( !isQuietEnabled() )
        {
            System.out.println( "Connection to the server established.\n"
                + "Sending extended request and blocking for shutdown:" );
            isWaiting = true;
            Thread t = new Thread( new Ticker() );
            t.start();
        }
        try
        {
            ctx.extendedOperation( new GracefulShutdownRequest( 0, timeOffline, delay ) );
            isSuccess = true;
        }
        catch ( Throwable t )
        {
            /*
             * Sometimes because of timing issues we show a failure when the
             * shutdown has succeeded so we should check if the server is up
             * before we set success to false.
             */
            try
            {
                new InitialLdapContext( env, null );
                isSuccess = false;
                System.err.print( "shutdown request failed with error: " + t.getLocalizedMessage() );
            }
            catch ( CommunicationException e )
            {
                isSuccess = true;
            }
        }
        isWaiting = false;
        ctx.close();
    }
View Full Code Here

    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
    MockControl[] cs = { new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }),
        new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), };
    MockControl cs2 =  new MockControl("c1", false, new byte[] { 1, 2, 3, 4 });
    InitialLdapContext ilc=new InitialLdapContext(env, cs);
    assertEquals(cs2,ControlFactory.getControlInstance(cs2,ilc,env));
  }
View Full Code Here

    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
    env.put(LdapContext.CONTROL_FACTORIES,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockControlFactory");
    MockControl[] cs = { new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }),new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), };
    MockControl cs2 =  new MockControl("c1", false, new byte[] { 1, 2, 3, 4 });
    InitialLdapContext ilc=new InitialLdapContext(env, cs);

    assertEquals(cs2,ControlFactory.getControlInstance(cs2,ilc,env));
  }
View Full Code Here

   * <p>Here we are testing if this method can throw an exception of the type NoInitialContextException.</p>
   */
  public void testGetEnviroment() {
    try {
      System.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
      InitialLdapContext ilc=new InitialLdapContext(null,null);
      ilc.getEnvironment();
     
    } catch (NoInitialContextException e) {
      fail("Failed with:"+e);
    } catch (NamingException e){
      fail("Failed with:"+e);
View Full Code Here

   * <p>Here we are testing if this method can throw an exception of the type NoInitialContextException.</p>
   */
  public void testgetConnectControls() {
    try {
      System.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
      InitialLdapContext ilc=new InitialLdapContext(null,null);
      ilc.getConnectControls();
           
    }catch (NamingException e){
      fail("Failed with:"+e);
    }

View Full Code Here

      Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
      MockControl[] cs = { new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }),
          new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), };
      MockControl cs2 =  new MockControl("c1", false, new byte[] { 1, 2, 3, 4 });
      InitialLdapContext ilc=new InitialLdapContext(env, cs);
      assertEquals(cs2,ControlFactory.getControlInstance(cs2,ilc,env));
     
    } catch (NamingException e) {
     
    }
View Full Code Here

   * @param arg0 The controls to be use for the new instance.
   * @return LdapContext The new context.
   */
  public LdapContext newInstance(Control[] arg0) throws NamingException {
    if(arg0==null||arg0!=null){
      return new InitialLdapContext(env,arg0);
    }
    throw new NamingException();
  }
View Full Code Here

        if (ldapLoginPassword != null && ldapLoginPassword.length() > 0) {
            env.put(Context.SECURITY_CREDENTIALS, ldapLoginPassword);
        }
        env.put(Context.PROVIDER_URL, ldapUrl);
        try {
            ctx = new InitialLdapContext(env, null);
        } catch (NamingException e) {
            throw new NamingException("Instantiation of Ldap Context failed");
        }
        return ctx;
    }
View Full Code Here

        env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapServer.getPort() );
        env.put( Context.SECURITY_PRINCIPAL, ServerDNConstants.ADMIN_SYSTEM_DN );
        env.put( Context.SECURITY_CREDENTIALS, "secret" );
        env.put( Context.SECURITY_AUTHENTICATION, "simple" );
        return new InitialLdapContext( env, JndiUtils.toJndiControls( controls ) );
    }
View Full Code Here

TOP

Related Classes of javax.naming.ldap.InitialLdapContext

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.