the basic principles of manager classes
under your belt, you’re ready to look at the
LDAPManager class. This chapter involves a rapid
run through some LDAP and JNDI concepts that you should already be
familiar with; if you get lost in the details of the code samples,
pick up Java Enterprise in a Nutshell, which spends a lot of time on JNDI. Once
you’ve got a handle on the basics, the code itself
should illustrate any tricky issues.
class belongs in a package structure that
com.forethought.ldap. There are a few constants
that can be defined right off the bat. First, the default port for
LDAP, 389, is stored, which allows clients to specify only a
hostname, and possibly authentication credentials, when connecting,
rather than also having to specify the default port when appropriate.
Additionally, some basic member variables are defined: one for the
hostname to connect to, and one for the port. These variables are
used when the manager needs to connect and reconnect to the directory
server, or authenticate users when a connection is already in place.
Finally, the manager needs to store a connection object itself, a
Using JNDI for directory server access will require a bit of a change
in thinking. Everything in JNDI revolves around the idea of a
Context; this should seem familiar, as I discussed
InitialContext object in