Example usage for javax.naming Context PROVIDER_URL

List of usage examples for javax.naming Context PROVIDER_URL

Introduction

In this page you can find the example usage for javax.naming Context PROVIDER_URL.

Prototype

String PROVIDER_URL

To view the source code for javax.naming Context PROVIDER_URL.

Click Source Link

Document

Constant that holds the name of the environment property for specifying configuration information for the service provider to use.

Usage

From source file:org.apache.hadoop.security.authentication.server.LdapAuthenticationHandler.java

private void authenticateWithTlsExtension(String userDN, String password) throws AuthenticationException {
    LdapContext ctx = null;/*from   ww w .  ja  v a  2 s  .c om*/
    Hashtable<String, Object> env = new Hashtable<String, Object>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, providerUrl);

    try {
        // Create initial context
        ctx = new InitialLdapContext(env, null);
        // Establish TLS session
        StartTlsResponse tls = (StartTlsResponse) ctx.extendedOperation(new StartTlsRequest());

        if (disableHostNameVerification) {
            tls.setHostnameVerifier(new HostnameVerifier() {
                @Override
                public boolean verify(String hostname, SSLSession session) {
                    return true;
                }
            });
        }

        tls.negotiate();

        // Initialize security credentials & perform read operation for
        // verification.
        ctx.addToEnvironment(Context.SECURITY_AUTHENTICATION, SECURITY_AUTHENTICATION);
        ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, userDN);
        ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, password);
        ctx.lookup(userDN);
        logger.debug("Authentication successful for {}", userDN);

    } catch (NamingException | IOException ex) {
        throw new AuthenticationException("Error validating LDAP user", ex);
    } finally {
        if (ctx != null) {
            try {
                ctx.close();
            } catch (NamingException e) { /* Ignore. */
            }
        }
    }
}

From source file:org.apache.axis2.transport.jms.JMSListener.java

/**
 * Initialize the defined connection factories, parsing the TransportIn
 * descriptions/*from ww w .  jav  a2s  .  c  om*/
 *
 * @param transprtIn The Axis2 Transport in for the JMS
 */
private void initializeConnectionFactories(TransportInDescription transprtIn) {
    // iterate through all defined connection factories
    Iterator conFacIter = transprtIn.getParameters().iterator();

    while (conFacIter.hasNext()) {

        Parameter param = (Parameter) conFacIter.next();
        JMSConnectionFactory jmsConFactory = new JMSConnectionFactory(param.getName());

        ParameterIncludeImpl pi = new ParameterIncludeImpl();
        try {
            pi.deserializeParameters((OMElement) param.getValue());
        } catch (AxisFault axisFault) {
            handleException(
                    "Error reading Parameters for JMS connection " + "factory" + jmsConFactory.getName(),
                    axisFault);
        }

        // read connection facotry properties
        Iterator params = pi.getParameters().iterator();

        while (params.hasNext()) {
            Parameter p = (Parameter) params.next();

            if (Context.INITIAL_CONTEXT_FACTORY.equals(p.getName())) {
                jmsConFactory.addProperty(Context.INITIAL_CONTEXT_FACTORY, (String) p.getValue());
            } else if (Context.PROVIDER_URL.equals(p.getName())) {
                jmsConFactory.addProperty(Context.PROVIDER_URL, (String) p.getValue());
            } else if (Context.SECURITY_PRINCIPAL.equals(p.getName())) {
                jmsConFactory.addProperty(Context.SECURITY_PRINCIPAL, (String) p.getValue());
            } else if (Context.SECURITY_CREDENTIALS.equals(p.getName())) {
                jmsConFactory.addProperty(Context.SECURITY_CREDENTIALS, (String) p.getValue());
            } else if (JMSConstants.CONFAC_JNDI_NAME_PARAM.equals(p.getName())) {
                jmsConFactory.setJndiName((String) p.getValue());
            } else if (JMSConstants.CONFAC_JNDI_NAME_USER.equals(p.getName())) {
                jmsConFactory.setJndiUser((String) p.getValue());
            } else if (JMSConstants.CONFAC_JNDI_NAME_PASS.equals(p.getName())) {
                jmsConFactory.setJndiPass((String) p.getValue());
            } else if (JMSConstants.DEST_PARAM.equals(p.getName())) {
                StringTokenizer st = new StringTokenizer((String) p.getValue(), " ,");
                while (st.hasMoreTokens()) {
                    jmsConFactory.addDestination(st.nextToken(), null);
                }
            }
        }

        // connect to the actual connection factory
        try {
            jmsConFactory.connect();
            connectionFactories.put(jmsConFactory.getName(), jmsConFactory);
        } catch (NamingException e) {
            handleException("Error connecting to JMS connection factory : " + jmsConFactory.getJndiName(), e);
        }
    }
}

From source file:org.apache.nifi.processors.enrich.QueryDNS.java

protected void initializeResolver(final ProcessContext context) {

    final String dnsTimeout = context.getProperty(DNS_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).toString();
    final String dnsServer = context.getProperty(DNS_SERVER).getValue();
    final String dnsRetries = context.getProperty(DNS_RETRIES).getValue();

    String finalServer = "";
    Hashtable<String, String> env = new Hashtable<String, String>();
    env.put("java.naming.factory.initial", contextFactory);
    env.put("com.sun.jndi.dns.timeout.initial", dnsTimeout);
    env.put("com.sun.jndi.dns.timeout.retries", dnsRetries);
    if (StringUtils.isNotEmpty(dnsServer)) {
        for (String server : dnsServer.split(",")) {
            finalServer = finalServer + "dns://" + server + "/. ";
        }/*from  ww  w.  ja  v  a2s  .com*/
        env.put(Context.PROVIDER_URL, finalServer);
    }

    try {
        initializeContext(env);
        initialized.set(true);
    } catch (NamingException e) {
        getLogger().error("Could not initialize JNDI context", e);
    }
}

From source file:org.openadaptor.auxil.connector.jndi.JNDIConnection.java

protected Properties getConnectionProperties(Properties customProperties, String contextFactory,
        String providerUrl, String authentication, String principal, String credentials) {
    Properties env = new Properties();
    if (customProperties != null) {
        env.putAll(customProperties);//from  w  ww.j ava  2  s .  c  o  m
    }
    if (contextFactory != null) {
        env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
    }
    if (providerUrl != null) {
        env.put(Context.PROVIDER_URL, _providerUrl);
    }
    // Authentication details
    if (authentication != null) {
        env.put(Context.SECURITY_AUTHENTICATION, authentication);
    }
    if (principal != null) {
        env.put(Context.SECURITY_PRINCIPAL, principal);
    }
    if (credentials != null) {
        env.put(Context.SECURITY_CREDENTIALS, credentials);
    }
    return env;
}

From source file:org.rhq.enterprise.server.core.jaas.LdapLoginModule.java

/**
 * Load a default set of properties to use when connecting to the LDAP server. If basic authentication is needed,
 * the caller must set Context.SECURITY_PRINCIPAL, Context.SECURITY_CREDENTIALS and Context.SECURITY_AUTHENTICATION
 * appropriately.// ww w .  ja va2s  .  com
 *
 * @return properties that are to be used when connecting to LDAP server
 */
private Properties getProperties() {
    Properties env = new Properties();

    // Map all user options into into our environment
    Iterator iter = options.entrySet().iterator();
    while (iter.hasNext()) {
        Entry entry = (Entry) iter.next();
        if ((entry.getKey() != null) && (entry.getValue() != null)) {
            env.put(entry.getKey(), entry.getValue());
        }
    }

    // Set our default factory name if one is not given
    String factoryName = env.getProperty(Context.INITIAL_CONTEXT_FACTORY);
    if (factoryName == null) {
        env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    }

    // Setup SSL if requested
    String protocol = env.getProperty(Context.SECURITY_PROTOCOL);
    if ("ssl".equals(protocol)) {
        String ldapSocketFactory = env.getProperty("java.naming.ldap.factory.socket");
        if (ldapSocketFactory == null) {
            env.put("java.naming.ldap.factory.socket", UntrustedSSLSocketFactory.class.getName());
        }
        env.put(Context.SECURITY_PROTOCOL, "ssl");
    }

    // Set the LDAP url
    String providerUrl = env.getProperty(Context.PROVIDER_URL);
    if (providerUrl == null) {
        providerUrl = "ldap://localhost:" + (((protocol != null) && protocol.equals("ssl")) ? "636" : "389");
    }

    env.setProperty(Context.PROVIDER_URL, providerUrl);

    // Follow referrals automatically
    env.setProperty(Context.REFERRAL, "ignore");//BZ:582471- active directory query change

    return env;
}

From source file:org.sonar.plugins.activedirectory.server.ApacheDS.java

/**
 * This seems to be required for objectClass posixGroup.
 *///w ww .  ja va  2 s .  c o  m
private ApacheDS activateNis() throws Exception {
    Preconditions.checkState(ldapServer.isStarted());

    Attribute disabled = new BasicAttribute("m-disabled", "TRUE");
    Attribute disabled2 = new BasicAttribute("m-disabled", "FALSE");
    ModificationItem[] mods = new ModificationItem[] {
            new ModificationItem(DirContext.REMOVE_ATTRIBUTE, disabled),
            new ModificationItem(DirContext.ADD_ATTRIBUTE, disabled2) };

    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, getUrl());

    DirContext ctx = new InitialDirContext(env);
    ctx.modifyAttributes("cn=nis,ou=schema", mods);

    return this;
}

From source file:org.lsc.jndi.JndiServices.java

private void initConnection() throws NamingException, IOException {
    // log new connection with it's details
    logConnectingTo(connProps);/*from  ww  w. ja v a2 s.c o m*/

    /* should we negotiate TLS? */
    if (connProps.get(TLS_CONFIGURATION) != null && (Boolean) connProps.get(TLS_CONFIGURATION)) {
        /* if we're going to do TLS, we mustn't BIND before the STARTTLS operation
         * so we remove credentials from the properties to stop JNDI from binding */
        /* duplicate properties to avoid changing them (they are used as a cache key in getInstance() */
        Properties localConnProps = new Properties();
        localConnProps.putAll(connProps);
        String jndiContextAuthentication = localConnProps.getProperty(Context.SECURITY_AUTHENTICATION);
        String jndiContextPrincipal = localConnProps.getProperty(Context.SECURITY_PRINCIPAL);
        String jndiContextCredentials = localConnProps.getProperty(Context.SECURITY_CREDENTIALS);
        localConnProps.remove(Context.SECURITY_AUTHENTICATION);
        localConnProps.remove(Context.SECURITY_PRINCIPAL);
        localConnProps.remove(Context.SECURITY_CREDENTIALS);

        /* open the connection */
        ctx = new InitialLdapContext(localConnProps, null);

        /* initiate the STARTTLS extended operation */
        try {
            tlsResponse = (StartTlsResponse) ctx.extendedOperation(new StartTlsRequest());
            tlsResponse.negotiate();
        } catch (IOException e) {
            LOGGER.error("Error starting TLS encryption on connection to {}",
                    localConnProps.getProperty(Context.PROVIDER_URL));
            LOGGER.debug(e.toString(), e);
            throw e;
        } catch (NamingException e) {
            LOGGER.error("Error starting TLS encryption on connection to {}",
                    localConnProps.getProperty(Context.PROVIDER_URL));
            LOGGER.debug(e.toString(), e);
            throw e;
        }

        /* now we add the credentials back to the context, to BIND once TLS is started */
        ctx.addToEnvironment(Context.SECURITY_AUTHENTICATION, jndiContextAuthentication);
        ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, jndiContextPrincipal);
        ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, jndiContextCredentials);

    } else {
        /* don't start TLS, just connect normally (this can be on ldap:// or ldaps://) */
        ctx = new InitialLdapContext(connProps, null);
    }

    /* get LDAP naming context */
    try {
        namingContext = new LdapUrl((String) ctx.getEnvironment().get(Context.PROVIDER_URL));
    } catch (LdapURLEncodingException e) {
        LOGGER.error(e.toString());
        LOGGER.debug(e.toString(), e);
        throw new NamingException(e.getMessage());
    }

    /* handle options */
    contextDn = namingContext.getDn() != null ? namingContext.getDn() : null;

    String pageSizeStr = (String) ctx.getEnvironment().get("java.naming.ldap.pageSize");
    if (pageSizeStr != null) {
        pageSize = Integer.parseInt(pageSizeStr);
    } else {
        pageSize = -1;
    }

    sortedBy = (String) ctx.getEnvironment().get("java.naming.ldap.sortedBy");

    String recursiveDeleteStr = (String) ctx.getEnvironment().get("java.naming.recursivedelete");
    if (recursiveDeleteStr != null) {
        recursiveDelete = Boolean.parseBoolean(recursiveDeleteStr);
    } else {
        recursiveDelete = false;
    }

    /* Load SyncRepl response control */
    LdapApiService ldapApiService = LdapApiServiceFactory.getSingleton();
    ControlFactory<?> factory = new SyncStateValueFactory(ldapApiService);
    ldapApiService.registerControl(factory);
    /* Load Persistent Search response control */
    factory = new PersistentSearchFactory(ldapApiService);
    ldapApiService.registerControl(factory);
}

From source file:edu.umich.ctools.sectionsUtilityTool.SectionUtilityToolFilter.java

private boolean ldapAuthorizationVerification(String user) {
    M_log.debug("ldapAuthorizationVerification(): called");
    boolean isAuthorized = false;
    DirContext dirContext = null;
    NamingEnumeration listOfPeopleInAuthGroup = null;
    NamingEnumeration allSearchResultAttributes = null;
    NamingEnumeration simpleListOfPeople = null;
    Hashtable<String, String> env = new Hashtable<String, String>();
    if (!isEmpty(providerURL) && !isEmpty(mcommunityGroup)) {
        env.put(Context.INITIAL_CONTEXT_FACTORY, LDAP_CTX_FACTORY);
        env.put(Context.PROVIDER_URL, providerURL);
    } else {/*  w w w .j  ava2  s . c  o m*/
        M_log.error(
                " [ldap.server.url] or [mcomm.group] properties are not set, review the sectionsToolPropsLessSecure.properties file");
        return isAuthorized;
    }
    try {
        dirContext = new InitialDirContext(env);
        String[] attrIDs = { "member" };
        SearchControls searchControls = new SearchControls();
        searchControls.setReturningAttributes(attrIDs);
        searchControls.setReturningObjFlag(true);
        searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
        String searchBase = OU_GROUPS;
        String filter = "(&(cn=" + mcommunityGroup + ") (objectclass=rfc822MailGroup))";
        listOfPeopleInAuthGroup = dirContext.search(searchBase, filter, searchControls);
        String positiveMatch = "uid=" + user + ",";
        outerloop: while (listOfPeopleInAuthGroup.hasMore()) {
            SearchResult searchResults = (SearchResult) listOfPeopleInAuthGroup.next();
            allSearchResultAttributes = (searchResults.getAttributes()).getAll();
            while (allSearchResultAttributes.hasMoreElements()) {
                Attribute attr = (Attribute) allSearchResultAttributes.nextElement();
                simpleListOfPeople = attr.getAll();
                while (simpleListOfPeople.hasMoreElements()) {
                    String val = (String) simpleListOfPeople.nextElement();
                    if (val.indexOf(positiveMatch) != -1) {
                        isAuthorized = true;
                        break outerloop;
                    }
                }
            }
        }
        return isAuthorized;
    } catch (NamingException e) {
        M_log.error("Problem getting attribute:" + e);
        return isAuthorized;
    } finally {
        try {
            if (simpleListOfPeople != null) {
                simpleListOfPeople.close();
            }
        } catch (NamingException e) {
            M_log.error(
                    "Problem occurred while closing the NamingEnumeration list \"simpleListOfPeople\" list ",
                    e);
        }
        try {
            if (allSearchResultAttributes != null) {
                allSearchResultAttributes.close();
            }
        } catch (NamingException e) {
            M_log.error(
                    "Problem occurred while closing the NamingEnumeration \"allSearchResultAttributes\" list ",
                    e);
        }
        try {
            if (listOfPeopleInAuthGroup != null) {
                listOfPeopleInAuthGroup.close();
            }
        } catch (NamingException e) {
            M_log.error(
                    "Problem occurred while closing the NamingEnumeration \"listOfPeopleInAuthGroup\" list ",
                    e);
        }
        try {
            if (dirContext != null) {
                dirContext.close();
            }
        } catch (NamingException e) {
            M_log.error("Problem occurred while closing the  \"dirContext\"  object", e);
        }
    }

}

From source file:org.wso2.extension.siddhi.io.jms.source.client.JMSClient.java

public void sendJMSEvents(List<String> messageList, String topicName, String queueName, String format,
        String broker, String providerURL) {
    if (format == null || "map".equals(format)) {
        format = "csv";
    }/*from   w ww . j a  v  a  2s. c  om*/
    if ("".equalsIgnoreCase(broker)) {
        broker = "activemq";
    }
    Session session = null;
    Properties properties = new Properties();
    if (!"activemq".equalsIgnoreCase(broker) && !"mb".equalsIgnoreCase(broker)
            && !"qpid".equalsIgnoreCase(broker)) {
        log.error("Please enter a valid JMS message broker. (ex: activemq, mb, qpid");
        return;
    }
    try {
        if (topicName != null && !"".equalsIgnoreCase(topicName)) {
            TopicConnection topicConnection;
            TopicConnectionFactory connFactory = null;
            if ("activemq".equalsIgnoreCase(broker)) {
                properties.load(ClassLoader.getSystemClassLoader().getResourceAsStream("activemq.properties"));
                // to provide custom provider urls
                if (providerURL != null) {
                    properties.put(Context.PROVIDER_URL, providerURL);
                }
                Context context = new InitialContext(properties);
                connFactory = (TopicConnectionFactory) context.lookup("ConnectionFactory");
            } else if ("mb".equalsIgnoreCase(broker)) {
                properties.load(ClassLoader.getSystemClassLoader().getResourceAsStream("mb.properties"));
                Context context = new InitialContext(properties);
                connFactory = (TopicConnectionFactory) context.lookup("qpidConnectionFactory");
            } else if ("qpid".equalsIgnoreCase(broker)) {
                properties.load(ClassLoader.getSystemClassLoader().getResourceAsStream("qpid.properties"));
                Context context = new InitialContext(properties);
                connFactory = (TopicConnectionFactory) context.lookup("qpidConnectionFactory");
            }
            if (connFactory != null) {
                topicConnection = connFactory.createTopicConnection();
                topicConnection.start();
                session = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
                if (session != null) {
                    Topic topic = session.createTopic(topicName);
                    MessageProducer producer = session.createProducer(topic);
                    //List<String> messagesList = JMSClientUtil.readFile(filePath);
                    try {
                        if ("csv".equalsIgnoreCase(format)) {
                            log.info("Sending Map messages on '" + topicName + "' topic");
                            JMSClientUtil.publishMapMessage(producer, session, messageList);

                        } else {
                            log.info("Sending  " + format + " messages on '" + topicName + "' topic");
                            JMSClientUtil.publishTextMessage(producer, session, messageList);
                        }
                        log.info("All Order Messages sent");
                    } catch (JMSException e) {
                        log.error("Cannot subscribe." + e.getMessage(), e);
                    } catch (IOException e) {
                        log.error("Error when reading the data file." + e.getMessage(), e);
                    } finally {
                        producer.close();
                        session.close();
                        topicConnection.stop();
                    }
                }
            } else {
                log.error("Error when creating connection factory. Please check necessary jar files");
            }
        } else if (queueName != null && !queueName.equalsIgnoreCase("")) {
            QueueConnection queueConnection;
            QueueConnectionFactory connFactory = null;
            if ("activemq".equalsIgnoreCase(broker)) {
                properties.load(ClassLoader.getSystemClassLoader().getResourceAsStream("activemq.properties"));
                // to provide custom provider urls
                if (providerURL != null) {
                    properties.put(Context.PROVIDER_URL, providerURL);
                }
                Context context = new InitialContext(properties);
                connFactory = (QueueConnectionFactory) context.lookup("ConnectionFactory");
            } else if ("mb".equalsIgnoreCase(broker)) {
                properties.load(ClassLoader.getSystemClassLoader().getResourceAsStream("mb.properties"));
                Context context = new InitialContext(properties);
                connFactory = (QueueConnectionFactory) context.lookup("qpidConnectionFactory");
            } else if ("qpid".equalsIgnoreCase(broker)) {
                properties.load(ClassLoader.getSystemClassLoader().getResourceAsStream("qpid.properties"));
                Context context = new InitialContext(properties);
                connFactory = (QueueConnectionFactory) context.lookup("qpidConnectionFactory");
            }
            if (connFactory != null) {
                queueConnection = connFactory.createQueueConnection();
                queueConnection.start();
                session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
                if (session != null) {
                    Queue queue = session.createQueue(queueName);
                    MessageProducer producer = session.createProducer(queue);
                    //List<String> messagesList = JMSClientUtil.readFile(filePath);
                    try {
                        if ("csv".equalsIgnoreCase(format)) {
                            log.info("Sending Map messages on '" + queueName + "' queue");
                            JMSClientUtil.publishMapMessage(producer, session, messageList);

                        } else {
                            log.info("Sending  " + format + " messages on '" + queueName + "' queue");
                            JMSClientUtil.publishTextMessage(producer, session, messageList);
                        }
                    } catch (JMSException e) {
                        log.error("Cannot subscribe." + e.getMessage(), e);
                    } catch (IOException e) {
                        log.error("Error when reading the data file." + e.getMessage(), e);
                    } finally {
                        producer.close();
                        session.close();
                        queueConnection.stop();
                    }
                }
            } else {
                log.error("Error when creating connection factory. Please check necessary jar files");
            }
        } else {
            log.error("Enter queue name or topic name to be published!");
        }
    } catch (Exception e) {
        log.error("Error when publishing" + e.getMessage(), e);
    }
}

From source file:de.sub.goobi.helper.ldap.Ldap.java

/**
 * retrieve home directory of given user.
 *
 * @param inBenutzer//from ww  w.  jav  a2 s .c  o  m
 *            User object
 * @return path as string
 */
public String getUserHomeDirectory(User inBenutzer) {
    if (ConfigCore.getBooleanParameter("useLocalDirectory", false)) {
        return ConfigCore.getParameter("dir_Users") + inBenutzer.getLogin();
    }
    Hashtable<String, String> env = getLdapConnectionSettings();
    if (ConfigCore.getBooleanParameter("ldap_useTLS", false)) {

        env = new Hashtable<>();
        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
        env.put(Context.PROVIDER_URL, ConfigCore.getParameter("ldap_url"));
        env.put("java.naming.ldap.version", "3");
        LdapContext ctx = null;
        StartTlsResponse tls = null;
        try {
            ctx = new InitialLdapContext(env, null);

            // Authentication must be performed over a secure channel
            tls = (StartTlsResponse) ctx.extendedOperation(new StartTlsRequest());
            tls.negotiate();

            // Authenticate via SASL EXTERNAL mechanism using client X.509
            // certificate contained in JVM keystore
            ctx.addToEnvironment(Context.SECURITY_AUTHENTICATION, "simple");
            ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, ConfigCore.getParameter("ldap_adminLogin"));
            ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, ConfigCore.getParameter("ldap_adminPassword"));

            ctx.reconnect(null);

            Attributes attrs = ctx.getAttributes(getUserDN(inBenutzer));
            Attribute la = attrs.get("homeDirectory");
            return (String) la.get(0);

            // Perform search for privileged attributes under authenticated
            // context

        } catch (IOException e) {
            logger.error("TLS negotiation error:", e);

            return ConfigCore.getParameter("dir_Users") + inBenutzer.getLogin();
        } catch (NamingException e) {

            logger.error("JNDI error:", e);

            return ConfigCore.getParameter("dir_Users") + inBenutzer.getLogin();
        } finally {
            if (tls != null) {
                try {
                    // Tear down TLS connection
                    tls.close();
                } catch (IOException e) {
                    logger.error(e);
                }
            }
            if (ctx != null) {
                try {
                    // Close LDAP connection
                    ctx.close();
                } catch (NamingException e) {
                    logger.error(e);
                }
            }
        }
    } else if (ConfigCore.getBooleanParameter("useSimpleAuthentification", false)) {
        env.put(Context.SECURITY_AUTHENTICATION, "none");
    } else {
        env.put(Context.SECURITY_PRINCIPAL, ConfigCore.getParameter("ldap_adminLogin"));
        env.put(Context.SECURITY_CREDENTIALS, ConfigCore.getParameter("ldap_adminPassword"));

    }
    DirContext ctx;
    String rueckgabe = "";
    try {
        ctx = new InitialDirContext(env);
        Attributes attrs = ctx.getAttributes(getUserDN(inBenutzer));
        Attribute la = attrs.get("homeDirectory");
        rueckgabe = (String) la.get(0);
        ctx.close();
    } catch (NamingException e) {
        logger.error(e);
    }
    return rueckgabe;
}