Package javax.naming.ldap

Examples of javax.naming.ldap.InitialLdapContext


   * contexts, in order to support the different paging implementations they provide.
   * @return the initial LDAP Context
   */
  private InitialLdapContext initializeLDAPContext() throws ResourceException {
      // Create the root context.
    InitialLdapContext initContext;

    Hashtable connenv = new Hashtable();
    connenv.put(Context.INITIAL_CONTEXT_FACTORY, this.config.getLdapContextFactory());
    connenv.put(Context.PROVIDER_URL, this.config.getLdapUrl());
    connenv.put(Context.REFERRAL, LDAP_REFERRAL_MODE);
    // If username is blank, we will perform an anonymous bind.
    // Note: This is not supported when using Sun's VLVs, so remove this if VLVs are used.
    if(!this.config.getLdapAdminUserDN().equals("")) { //$NON-NLS-1$

      connenv.put(Context.SECURITY_AUTHENTICATION, LDAP_AUTH_TYPE);
      connenv.put(Context.SECURITY_PRINCIPAL, this.config.getLdapAdminUserDN());
      connenv.put(Context.SECURITY_CREDENTIALS, this.config.getLdapAdminUserPassword());
    } else {
      LogManager.logDetail(LogConstants.CTX_CONNECTOR, "LDAP Username DN was blank; performing anonymous bind."); //$NON-NLS-1$
      connenv.put(Context.SECURITY_AUTHENTICATION, "none"); //$NON-NLS-1$
    }
   
    if(this.config.getLdapTxnTimeoutInMillis() != -1) {
      connenv.put("com.sun.jndi.ldap.connect.timeout", this.config.getLdapTxnTimeoutInMillis()); //$NON-NLS-1$
    }
   
    // Enable connection pooling for the Initial context.
    connenv.put("com.sun.jndi.ldap.connect.pool", "true"); //$NON-NLS-1$ //$NON-NLS-2$
    connenv.put("com.sun.jndi.ldap.connect.pool.debug", "fine"); //$NON-NLS-1$ //$NON-NLS-2$
   
    try {
      initContext = new InitialLdapContext(connenv, null);
    } catch(NamingException ne){
            final String msg = LDAPPlugin.Util.getString("LDAPConnection.directoryNamingError",ne.getExplanation()); //$NON-NLS-1$
      throw new ResourceException(msg);
    }
    LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Successfully obtained initial LDAP context."); //$NON-NLS-1$
View Full Code Here


    public PooledConnection create() throws Exception
    {
        long started = System.currentTimeMillis();
        Context context;
        if (ctxclass.equalsIgnoreCase("ldap")) {
          context = new InitialLdapContext(properties, null);
        } else if (ctxclass.equalsIgnoreCase("directory")) {
          context = new InitialDirContext(properties);
        } else {
          context = new InitialContext(properties);
        }
View Full Code Here

            long startTime = System.currentTimeMillis();
            if (logger.isDebugEnabled()) {
                logger.debug("Starting Timed Operation");
            }

            InitialLdapContext context = null;
            try {
                context = getContext(hosts);
                Object doIt = doIt(context);
                return doIt;
            } catch (Exception e) {
View Full Code Here

        variables.put("java.naming.ldap.version", "3");
        variables.put("com.sun.jndi.ldap.connect.pool", "true");
        variables.put("javax.security.sasl.qop", "auth-conf,auth-int,auth");
        variables.put(Context.SECURITY_PROTOCOL, getProtocolType());

        InitialLdapContext context = new InitialLdapContext(variables, null);
        String usedUrl = (String) context.getEnvironment().get(Context.PROVIDER_URL);
        setLastContactedActiveDirectoryUrl(usedUrl);
        return context;
    }
View Full Code Here

        env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
        env.put( "java.naming.provider.url", "ldap://localhost:" + getLdapServer().getPort() + "/ou=system" );
        env.put( "java.naming.security.principal", "uid=admin,ou=system" );
        env.put( "java.naming.security.credentials", "secret" );
        env.put( "java.naming.security.authentication", "simple" );
        ctx = new InitialLdapContext( env, null );

        Attributes spContainer = new BasicAttributes( "objectClass", "top", true );
        spContainer.get( "objectClass" ).add( "organizationalUnit" );
        spContainer.put( "ou", "Stored Procedures" );
        spCtx = ( LdapContext ) ctx.createSubcontext( "ou=Stored Procedures", spContainer );
View Full Code Here

        try
        {
            Control[] connCtls = bindRequest.getControls().values().toArray( EMPTY );
            env.put( DirectoryService.JNDI_KEY, directoryService );
            ctx = new InitialLdapContext( env, JndiUtils.toJndiControls( directoryService.getLdapCodecService(),
                connCtls ) );
        }
        catch ( Exception e )
        {
            ResultCodeEnum code;
View Full Code Here

     */
    protected void setContexts( Hashtable<String, Object> env ) throws Exception
    {
        Hashtable<String, Object> envFinal = new Hashtable<String, Object>( env );
        envFinal.put( Context.PROVIDER_URL, ServerDNConstants.SYSTEM_DN );
        sysRoot = new InitialLdapContext( envFinal, null );

        envFinal.put( Context.PROVIDER_URL, "" );
        rootDse = getService().getAdminSession();

        envFinal.put( Context.PROVIDER_URL, SchemaConstants.OU_SCHEMA );
        schemaRoot = new InitialLdapContext( envFinal, null );
    }
View Full Code Here

        String dn = NamespaceTools.inferLdapName(config.getPrimaryRealm());
        cloned.put(Context.PROVIDER_URL, dn);

        log.debug("Getting initial context for realm base at " + dn + " for " + config.getPrimaryRealm());

        return new InitialLdapContext(cloned, new Control[]{});
    }
View Full Code Here

      env.put(Context.SECURITY_CREDENTIALS, credentials);
        String referrals = defaultProperties.getProperty(HANDLE_REFERRALS_PROP);
        if (referrals != null) env.put(Context.REFERRAL, referrals);
  }

        DirContext ctx = new InitialLdapContext(env, null);

        log.info("Finished binding principal.");

        return ctx;
    }
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

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.