Package javax.naming.directory

Examples of javax.naming.directory.InitialDirContext


            }
            env.put(Context.SECURITY_PROTOCOL, connectionProtocol == null ? "" : connectionProtocol);
            env.put(Context.PROVIDER_URL, connectionURL == null ? "" : connectionURL);
            env.put(Context.SECURITY_AUTHENTICATION, authentication == null ? "" : authentication);
            env.put(Context.REFERRAL, (followReferrals) ? "follow" : "ignore");
            context = new InitialDirContext(env);

        } catch (NamingException e) {
            log.error(e);
            throw e;
        }
View Full Code Here


        props.setProperty(Context.URL_PKG_PREFIXES, URL_CONTEXT_PREFIX);
        props.setProperty(Context.REFERRAL, REFERRALS_IGNORE);
        props.setProperty(Context.SECURITY_AUTHENTICATION,
            SEARCH_SECURITY_LEVEL);

        DirContext ctx = new InitialDirContext(props);
        return ctx;
    }
View Full Code Here

        props.setProperty(Context.URL_PKG_PREFIXES, URL_CONTEXT_PREFIX);
        props.setProperty(Context.REFERRAL, REFERRALS_IGNORE);
        props.setProperty(Context.SECURITY_AUTHENTICATION,
            SEARCH_SECURITY_LEVEL);

        DirContext ctx = new InitialDirContext(props);
        return ctx;
    }
View Full Code Here

            return (context);

        try {

            // Ensure that we have a directory context available
            context = new InitialDirContext(getDirectoryContextEnvironment());

        } catch (Exception e) {

            connectionAttempt = 1;

            // log the first exception.
            log(sm.getString("jndiRealm.exception"), e);

            // Try connecting to the alternate url.
            context = new InitialDirContext(getDirectoryContextEnvironment());

        } finally {

            // reset it in case the connection times out.
            // the primary may come back.
View Full Code Here

            return (context);

        try {

            // Ensure that we have a directory context available
            context = new InitialDirContext(getDirectoryContextEnvironment());

        } catch (NamingException e) {

            connectionAttempt = 1;

            // log the first exception.
            log(sm.getString("jndiRealm.exception"), e);

            // Try connecting to the alternate url.
            context = new InitialDirContext(getDirectoryContextEnvironment());

        } finally {

            // reset it in case the connection times out.
            // the primary may come back.
View Full Code Here

        }
        env.put(Context.SECURITY_PRINCIPAL, dn);
        env.put(Context.SECURITY_CREDENTIALS, password);
        try {
            // Create initial context
            DirContext ldapCtx = new InitialDirContext(env);
            ldapCtx.close();
        } catch (NamingException e) {
            Debug.logVerbose("LDAP authentication failed: " + e.getMessage(), module);
            return false;
        }
        Debug.logVerbose("LDAP authentication succeeded", module);
View Full Code Here

        constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
        constraints.setCountLimit(0);
        constraints.setDerefLinkFlag(true);
        constraints.setTimeLimit(settings.getSearchTimeout());
        List<SearchResult> tmp = new ArrayList<SearchResult>();
        InitialDirContext context = null;
        try {
            context = new InitialDirContext(new Hashtable<String,String>(ldapEnvironment));
            NamingEnumeration<SearchResult> namingEnumeration = context.search(baseDN, filter, attributes, constraints);
            while (namingEnumeration.hasMore()) {
                tmp.add(namingEnumeration.next());
            }
        } catch (NamingException e) {
            log.error("LDAP search failed", e);
        } finally {
            if (context != null) {
                context.close();
            }
        }
        return tmp;
    }
View Full Code Here

            Hashtable<String,String> env = new Hashtable<String,String>(ldapEnvironment);
            env.put(Context.SECURITY_PRINCIPAL, user.getDN());
            env.put(Context.SECURITY_CREDENTIALS, user.getLdapPassword());
            //TODO
            env.put(Context.SECURITY_AUTHENTICATION, "simple");
            new InitialDirContext(env).close();
        } catch (NamingException e) {
            throw new LoginException("Could not create initial LDAP context for user " + user.getDN() + ": " + e.getMessage());
        }
    }
View Full Code Here

        Hashtable env = new Hashtable();
        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
        env.put(Context.PROVIDER_URL,            ldapURI.toString());
        env.put(Context.SECURITY_PRINCIPAL,      ldapUser);
        env.put(Context.SECURITY_CREDENTIALS,    ldapPassword);
        ldapContext = new InitialDirContext(env);
    }
View Full Code Here

            }
            env.put(Context.SECURITY_PROTOCOL, connectionProtocol == null ? "" : connectionProtocol);
            env.put(Context.PROVIDER_URL, connectionURL == null ? "" : connectionURL);
            env.put(Context.SECURITY_AUTHENTICATION, authentication == null ? "" : authentication);
            env.put(Context.REFERRAL, (followReferrals) ? "follow" : "ignore");
            context = new InitialDirContext(env);
        } catch (NamingException e) {
            log.error("Failed to open context", e);
            throw e;
        }
        return context;
View Full Code Here

TOP

Related Classes of javax.naming.directory.InitialDirContext

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.