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 6842887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:09:24+00:00 2026-05-27T00:09:24+00:00

What I need to do is connect to an LDAP, and then pass this

  • 0

What I need to do is connect to an LDAP, and then pass this connection to several classes, which do various steps of processing.

The problem I face is if I should pass the connection to these classes via the constructor, or if every class should manage his own connection.

The problem I see with the first approach is that the caller may not know that he is responsible for closing the stream by itself. The second approach also doesn’t seem appropriate because opening/closing/reopening the connection also makes no sense.

Any ideas on this?

  • 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-05-27T00:09:24+00:00Added an answer on May 27, 2026 at 12:09 am

    I don’t know why you’d have several classes dealing with an LDAP. Maybe you should consider combining those scattered operations into a single class that has all responsibility for LDAP operations.

    If that’s not possible, your instincts are correct. The class that opens the connection should close it in a finally block. That should be the interface-based POJO service class that knows about the unit of work for that use case. There should be no doubt about where the responsibility lies. If you don’t have such a service, create one.

    If the operations aren’t part of a single unit of work, then they should be managed by separate services. The comments from the previous paragraph still apply.

    Are you pooling your LDAP connections? I hope so.

    I’d recommend looking at the Spring LDAP module, especially if you’re already a Spring user. It makes dealing with LDAP resources easy, the same way it does JDBC.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to connect to a secure API which requires a certificate be attached
I am using ruby's net/ldap library for this problem but in reality the driver
I need to write some Java code to connect to an LDAP server to
I need to connect to an LDAP directory over SSL. In non-production environments, we
I need to implement Microsoft's LDAP server signing protocol to be able to connect
I need to connect to a mysql database across a network. The connection string
I have this script through which I can change my LDAP password but I
Need your help with authenticating an active directory user ID against LDAP. My problem
i need to connect for many databases the primary connection in the database.php and
I need to connect to an external LDAP server that is accessible to me

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.