See javax.naming.InitialContext and
javax.naming.InitialDirContext for details on synchronization,
and the policy for how an initial context is created.
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:
It specifies first the critical controls for creating the initial context (InitialLdapContext lctx = new InitialLdapContext(env, critConnCtls); lctx.setRequestControls(critModCtls); lctx.modifyAttributes(name, mods); Controls[] respCtls = lctx.getResponseControls();
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.
LdapContext, javax.naming.InitialContext , javax.naming.directory.InitialDirContext , javax.naming.spi.NamingManager#setInitialContextFactoryBuilder
| Modifier and Type | Field and Description |
|---|---|
| private static final String |
| Access | Constructor and Description |
|---|---|
| public | InitialLdapContext()
Constructs an initial context using no environment properties or connection request controls. |
| public | InitialLdapContext(Hashtable<?, ?>
environment used to create the initial DirContext.
Null indicates an empty environment. environment, Control[] connection request controls for the initial context.
If null, no connection request controls are used. connCtls)Constructs an initial context using environment properties and connection request controls. |
| Modifier and Type | Method and Description |
|---|---|
| public ExtendedResponse | extendedOperation(ExtendedRequest request)
Implements javax. Performs an extended operation. |
| public Control[] | getConnectControls()
Implements javax. Retrieves the connection request controls in effect for this context. |
| private LdapContext | Returns: The non-null cached initial context.Retrieves the initial LDAP context. |
| public Control[] | getRequestControls()
Implements javax. Retrieves the request controls in effect for this context. |
| public Control[] | getResponseControls()
Implements javax. Retrieves the response controls produced as a result of the last method invoked on this context. |
| public LdapContext | newInstance(Control[] reqCtls)
Implements javax. Creates a new instance of this context initialized using request controls. |
| public void | reconnect(Control[] connCtls)
Implements javax. Reconnects to the LDAP server using the supplied controls and this context's environment. |
| public void | setRequestControls(Control[] requestControls)
Implements javax. Sets the request controls for methods subsequently invoked on this context. |
| BIND_CONTROLS_PROPERTY | back to summary |
|---|---|
| private static final String BIND_CONTROLS_PROPERTY | |
| InitialLdapContext | back to summary |
|---|---|
| public InitialLdapContext() throws NamingException Constructs an initial context using no environment properties or
connection request controls.
Equivalent to
| |
| InitialLdapContext | back to summary |
|---|---|
| public InitialLdapContext(Hashtable<?, ?> environment, Control[] connCtls) throws NamingException Constructs an initial context
using environment properties and connection request controls.
See This constructor will not modify its parameters or
save references to them, but may save a clone or copy.
Caller should not modify mutable keys and values in
| |
| extendedOperation | back to summary |
|---|---|
| public ExtendedResponse extendedOperation(ExtendedRequest request) throws NamingException Implements javax. Doc from javax. Performs an extended operation. This method is used to support LDAPv3 extended operations.
| |
| getConnectControls | back to summary |
|---|---|
| public Control[] getConnectControls() throws NamingException Implements javax. Doc from javax. Retrieves the connection request controls in effect for this context. The controls are owned by the JNDI implementation and are immutable. Neither the array nor the controls may be modified by the caller.
| |
| getDefaultLdapInitCtx | back to summary |
|---|---|
| private LdapContext getDefaultLdapInitCtx() throws NamingException Retrieves the initial LDAP context.
| |
| getRequestControls | back to summary |
|---|---|
| public Control[] getRequestControls() throws NamingException Implements javax. Doc from javax. Retrieves the request controls in effect for this context. The request controls are owned by the JNDI implementation and are immutable. Neither the array nor the controls may be modified by the caller.
| |
| getResponseControls | back to summary |
|---|---|
| public Control[] getResponseControls() throws NamingException Implements javax. Doc from javax. Retrieves the response controls produced as a result of the last method invoked on this context. The response controls are owned by the JNDI implementation and are immutable. Neither the array nor the controls may be modified by the caller. These response controls might have been generated by a successful or failed operation.
When a context method that may return response controls is invoked,
response controls from the previous method invocation are cleared.
| |
| newInstance | back to summary |
|---|---|
| public LdapContext newInstance(Control[] reqCtls) throws NamingException Implements javax. Doc from javax. Creates a new instance of this context initialized using request controls. This method is a convenience method for creating a new instance of this context for the purposes of multithreaded access. For example, if multiple threads want to use different context request controls, each thread may use this method to get its own copy of this context and set/get context request controls without having to synchronize with other threads. The new context has the same environment properties and connection request controls as this context. See the class description for details. Implementations might also allow this context and the new context to share the same network connection or other resources if doing so does not impede the independence of either context.
| |
| reconnect | back to summary |
|---|---|
| public void reconnect(Control[] connCtls) throws NamingException Implements javax. Doc from javax. Reconnects to the LDAP server using the supplied controls and this context's environment. This method is a way to explicitly initiate an LDAP "bind" operation. For example, you can use this method to set request controls for the LDAP "bind" operation, or to explicitly connect to the server to get response controls returned by the LDAP "bind" operation.
This method sets this context's Service provider implementors should read the "Service Provider" section in the class description for implementation details.
| |
| setRequestControls | back to summary |
|---|---|
| public void setRequestControls(Control[] requestControls) throws NamingException Implements javax. Doc from javax. Sets the request controls for methods subsequently invoked on this context. The request controls are owned by the JNDI implementation and are immutable. Neither the array nor the controls may be modified by the caller.
This removes any previous request controls and adds
Note that
| |