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

  • SEARCH
  • Home
  • 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 9073211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:21:51+00:00 2026-06-16T18:21:51+00:00

I want to validate user entered ldap settings. On settings page user enters ldap

  • 0

I want to validate user entered ldap settings. On settings page user enters ldap url, manager dn and password. I have a ‘Test settings’ button on this page so that user can quickly verify the ldap connection. How to do this easily and quickly?

Our application using spring security and in the process of adding ldap authentication to it.
I am kind of new to java and ldap, so pointing me to right direction is greatly appreciated.

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-16T18:21:52+00:00Added an answer on June 16, 2026 at 6:21 pm

    Based on the information given it is hard to tell what you know and what you don’t know yet. So, I suggest you follow this helpful tutorial at java.net LdapTemplate: LDAP Programming in Java Made Simple and skip the chapters not relevant to you (it’s from 2006 but still ok). Spring LDAP referenced in the article is at version 1.3.1 by now.

    If you want to go without Spring LDAP for now you can use the following traditional code:

    Map<String, String> env = new HashMap<String, String>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "ldap://localhost:389/dc=jayway,dc=se");
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    env.put(Context.SECURITY_PRINCIPAL, "uid="+ username +",ou=system"); // replace with user DN
    env.put(Context.SECURITY_CREDENTIALS, password);
    
    DirContext ctx;
    try {
       ctx = new InitialDirContext(env);
    } catch (NamingException e) {
       // handle
    }
    try {
       SearchControls controls = new SearchControls();
       controls.setSearchScope( SearchControls.SUBTREE_SCOPE);
       ctx.search( "", "(objectclass=person)", controls);
       // no need to process the results
    } catch (NameNotFoundException e) {
       // The base context was not found.
       // Just clean up and exit.
    } catch (NamingException e) {
       // exception handling
    } finally {
       // close ctx or do Java 7 try-with-resources http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to validate a year in the form (XXXX) after the user enters
I have a monetary amount that is entered by a user and want to
I want to validate that the user has entered a comma separated list of
In my Android application I need to validate user entered data. So I have
I want to validate user-input. If the number user has entered is greater than
I want to validate that the value entered by a user in a textbox
I have a requirement to validate an email address entered when a user comes
I want to be able to validate a user's inputted regex, to check if
I have a int property in my class and want to validate if the
I want to validate and commit the value entered in the DataGridViewCell ONLY when

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.