• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to create external LDAP connection and create a partition  RSS feed

 
Sajal Khanna
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone provide me the code to connect to external LDAP (not in embedded mode) and then to create a partition usng LDAP connection. Thanks in advance.
 
Tim Holloway
Saloon Keeper
Posts: 18797
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Sajal!

I'm assuming that "connect to external LDAP/not embedded" means that you want to connect to an external LDAP server - as opposed to, for example, the embedded server that a webapp container such as Tomcat provides.

First and foremost, you obviously have to have an LDAP server to connect to. Also a network path to that server and firewall privileges that permit your client app to talk through to the LDAP server.

Then you may have to have access rights to that server, depending on how you connect to it. For example, a Microsoft Active Directory server doesn't allow anonymous queries - or at least I don't think it does.

In Java, LDAP is managed via the general-purpose Java Naming and Directory Interface (JNDI). JNDI is actually a generic means of accessing data organized by key and value. Sort of what you'd get if you extended the Java Map facility to support multi-layered maps of maps. The LDAP service provider conforms to this interface, although it's not the only mechanism that does. It is, however, one of the most common.

Actual sample code for retrieving LDAP data using an anonymous query is illustrated here: http://docs.oracle.com/javase/jndi/tutorial/getStarted/examples/directory.html

One thing that the example doesn't mention is that LDAP directories can be used to access things other than simple String values. For example, J2EE webapps often use the server's internal LDAP server to locate the Database Connection Pool in order to obtain externally-configured database connections.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!