JNDI 1.2

javax.naming.ldap
Class InitialLdapContext

java.lang.Object
  |
  +--javax.naming.InitialContext
        |
        +--javax.naming.directory.InitialDirContext
              |
              +--javax.naming.ldap.InitialLdapContext

public class InitialLdapContext
extends InitialDirContext
implements LdapContext

This class is the starting context for performing LDAPv3-style extended operations and controls.

See javax.naming.InitialContext and javax.naming.InitialDirContext for details on synchronization, and the policy for how an initial context is created.

Request Controls

When you create an initial context (InitialLdapContext), you can specify a list of request controls. These controls will be used as the request controls for any implicit LDAP "bind" operation performed by the context or contexts derived from the context. These are called connection request controls. Use getConnectControls() to get a context's connection request controls.

The request controls supplied to the initial context constructor are not used as the context request controls for subsequent context operations such as searches and lookups. Context request controls are set and updated by using setRequestControls().

As shown, there can be two different sets of request controls associated with a context: connection request controls and context request controls. This is required for those applications needing to send critical controls that might not be applicable to both the context operation and any implicit LDAP "bind" operation. A typical user program would do the following:

 InitialLdapContext lctx = new InitialLdapContext(env, critConnCtls);
 lctx.setRequestControls(critModCtls);
 lctx.modifyAttributes(name, mods);
 Controls[] respCtls =  lctx.getResponseControls();
It specifies first the critical controls for creating the initial context (critConnCtls), and then sets the context's request controls (critModCtls) for the context operation. If for some reason lctx needs to reconnect to the server, it will use critConnCtls. See the LdapContext interface for more discussion about request controls.

Service provider implementors should read the "Service Provider" section in the LdapContext class description for implementation details.

Since:
JNDI 1.2 / Java 2 Platform, Standard Edition, v 1.3
See Also:
LdapContext, InitialContext, InitialDirContext, NamingManager.setInitialContextFactoryBuilder(javax.naming.spi.InitialContextFactoryBuilder)

Fields inherited from class javax.naming.InitialContext
defaultInitCtx, gotDefault, myProps
 
Constructor Summary
InitialLdapContext()
          Constructs an initial context using no environment properties or connection request controls.
InitialLdapContext(Hashtable environment, Control[] connCtls)
          Constructs an initial context using environment properties and connection request controls.
 
Method Summary
 ExtendedResponse extendedOperation(ExtendedRequest request)
          Performs an extended operation.
 Control[] getConnectControls()
          Retrieves the connection request controls in effect for this context.
 Control[] getRequestControls()
          Retrieves the request controls in effect for this context.
 Control[] getResponseControls()
          Retrieves the response controls produced as a result of the last method invoked on this context.
 LdapContext newInstance(Control[] reqCtls)
          Creates a new instance of the underlying initial context initialized using request controls.
 void reconnect(Control[] connCtls)
          Reconnects to the LDAP server using this connection request controls and the context's environment.
 void setRequestControls(Control[] requestControls)
          Sets the request controls for methods subsequently invoked on this context.
 
Methods inherited from class javax.naming.directory.InitialDirContext
bind, bind, createSubcontext, createSubcontext, getAttributes, getAttributes, getAttributes, getAttributes, getSchema, getSchema, getSchemaClassDefinition, getSchemaClassDefinition, modifyAttributes, modifyAttributes, modifyAttributes, modifyAttributes, rebind, rebind, search, search, search, search, search, search, search, search
 
Methods inherited from class javax.naming.InitialContext
addToEnvironment, bind, bind, close, composeName, composeName, createSubcontext, createSubcontext, destroySubcontext, destroySubcontext, getDefaultInitCtx, getEnvironment, getNameInNamespace, getNameParser, getNameParser, getURLOrDefaultInitCtx, getURLOrDefaultInitCtx, init, list, list, listBindings, listBindings, lookup, lookup, lookupLink, lookupLink, rebind, rebind, removeFromEnvironment, rename, rename, unbind, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InitialLdapContext

public InitialLdapContext()
                   throws NamingException
Constructs an initial context using no environment properties or connection request controls. Equivalent to new InitialLdapContext(null, null).
Throws:
NamingException - if a naming exception is encountered

InitialLdapContext

public InitialLdapContext(Hashtable environment,
                          Control[] connCtls)
                   throws NamingException
Constructs an initial context using environment properties and connection request controls. See javax.naming.InitialContext for a discussion of environment properties.

This constructor will not modify its parameters or save references to them, but may save a clone or copy.

connCtls is used as the underlying context instance's connection request controls. See the class description for details.

Parameters:
environment - environment used to create the initial DirContext. Null indicates an empty environment.
connCtls - connection request controls for the initial context. If null, no connection request controls are used.
Throws:
NamingException - if a naming exception is encountered
See Also:
reconnect(javax.naming.ldap.Control[]), LdapContext.reconnect(javax.naming.ldap.Control[])
Method Detail

extendedOperation

public ExtendedResponse extendedOperation(ExtendedRequest request)
                                   throws NamingException
Performs an extended operation.
Specified by:
extendedOperation in interface LdapContext

newInstance

public LdapContext newInstance(Control[] reqCtls)
                        throws NamingException
Creates a new instance of the underlying initial context initialized using request controls.
Specified by:
newInstance in interface LdapContext

reconnect

public void reconnect(Control[] connCtls)
               throws NamingException
Reconnects to the LDAP server using this connection request controls and the context's environment.
Specified by:
reconnect in interface LdapContext

getConnectControls

public Control[] getConnectControls()
                             throws NamingException
Retrieves the connection request controls in effect for this context.
Specified by:
getConnectControls in interface LdapContext

setRequestControls

public void setRequestControls(Control[] requestControls)
                        throws NamingException
Sets the request controls for methods subsequently invoked on this context.
Specified by:
setRequestControls in interface LdapContext

getRequestControls

public Control[] getRequestControls()
                             throws NamingException
Retrieves the request controls in effect for this context.
Specified by:
getRequestControls in interface LdapContext

getResponseControls

public Control[] getResponseControls()
                              throws NamingException
Retrieves the response controls produced as a result of the last method invoked on this context.
Specified by:
getResponseControls in interface LdapContext

JNDI 1.2

For more information on JNDI, please see http://java.sun.com/products/jndi