Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8891137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:39:43+00:00 2026-06-14T22:39:43+00:00

i am having to do a login page in java and it must login

  • 0

i am having to do a login page in java and it must login using the credentials from LDAP, does anyone have any tutorials or examples i could use as i have no idea where to start

Thanks !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:39:44+00:00Added an answer on June 14, 2026 at 10:39 pm

    You should use spring-security which has dozen of utilities and tutorial.

    Here is the link to the official documentation: http://forum.springsource.org/showthread.php?124263-Basic-LDAP-Example-For-Spring-Security-3-1

    BTW, here is the code to bind to an ldap server in pure JNDI:

    /**
     * Returns the ldap context.
     * 
     * @param user the user name
     * @param password the password
     * @return the prepared context
     * @throws NamingException in case of...
     */
    protected LdapContext buildContext(final String user, final String password) throws NamingException {
        String providerURL = new StringBuffer(getLdapScheme()) //
                .append("://") //
                .append(getLdapHost()) //
                .append(":") //
                .append(getLdapPort()) //
                .append("/") //
                .append(getLdapRootDN()).toString();
    
        Hashtable<String, String> properties = new Hashtable<>();
        properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    
        properties.put(Context.PROVIDER_URL, providerURL);
    
        if (!isEmpty(user)) {
            // basic authentication
            properties.put(Context.SECURITY_AUTHENTICATION, "simple");
            properties.put(Context.SECURITY_PRINCIPAL, user);
            properties.put(Context.SECURITY_CREDENTIALS, defaultIfEmpty(password, ""));
        } else {
            // anonymous connection
            properties.put(Context.SECURITY_AUTHENTICATION, "none");
        }
    
        Control[] controls = null;
    
        LOGGER.info("creating new ldap context [url:{}, user: {}]", providerURL, user);
    
        return new InitialLdapContext(properties, controls);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm having an weird problem, my project have a login page, that's working, but
Does anyone have experience writing a Facebook application using GWT with GAE? I'm new
I have having difficulties on this one page login.php. Because of the nature of
I have been looking at either coding from scratch a basic login page +
I have a simple login page but i am having trouble displaying the logged
I have a web application having three pages, one is login page, second is
I'm having a problem with a simple html login page I made, where when
I have been using the Learning Java 2nd Edtion book to try make my
i am having a login page when executed the page is stripped out of
I have a simple login page and the URL structure is like www.mydomain.com/admin/auth I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.