- java.lang.Object
- 
- javax.naming.InitialContext
- 
- javax.naming.directory.InitialDirContext
- 
- javax.naming.ldap.InitialLdapContext
 
 
 
- 
- All Implemented Interfaces:
- Context,- DirContext,- LdapContext
 
 
 public class InitialLdapContext extends InitialDirContext implements LdapContext This class is the starting context for performing LDAPv3-style extended operations and controls.See javax.naming.InitialContextandjavax.naming.InitialDirContextfor details on synchronization, and the policy for how an initial context is created.Request ControlsWhen 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. UsegetConnectControls()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 reasonlctxneeds to reconnect to the server, it will usecritConnCtls. See theLdapContextinterface for more discussion about request controls.Service provider implementors should read the "Service Provider" section in the LdapContextclass description for implementation details.
- 
- 
Field Summary- 
Fields inherited from interface javax.naming.ContextAPPLET, AUTHORITATIVE, BATCHSIZE, DNS_URL, INITIAL_CONTEXT_FACTORY, LANGUAGE, OBJECT_FACTORIES, PROVIDER_URL, REFERRAL, SECURITY_AUTHENTICATION, SECURITY_CREDENTIALS, SECURITY_PRINCIPAL, SECURITY_PROTOCOL, STATE_FACTORIES, URL_PKG_PREFIXES
 - 
Fields inherited from interface javax.naming.directory.DirContextADD_ATTRIBUTE, REMOVE_ATTRIBUTE, REPLACE_ATTRIBUTE
 - 
Fields inherited from class javax.naming.InitialContextdefaultInitCtx, gotDefault, myProps
 - 
Fields inherited from interface javax.naming.ldap.LdapContextCONTROL_FACTORIES
 
- 
 - 
Constructor SummaryConstructors Constructor Description 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 SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description ExtendedResponseextendedOperation(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.LdapContextnewInstance(Control[] reqCtls)Creates a new instance of this context initialized using request controls.voidreconnect(Control[] connCtls)Reconnects to the LDAP server using the supplied controls and this context's environment.voidsetRequestControls(Control[] requestControls)Sets the request controls for methods subsequently invoked on this context.- 
Methods inherited from interface javax.naming.ContextaddToEnvironment, bind, bind, close, composeName, composeName, createSubcontext, createSubcontext, destroySubcontext, destroySubcontext, getEnvironment, getNameInNamespace, getNameParser, getNameParser, list, list, listBindings, listBindings, lookup, lookup, lookupLink, lookupLink, rebind, rebind, removeFromEnvironment, rename, rename, unbind, unbind
 - 
Methods inherited from interface javax.naming.directory.DirContextbind, 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.InitialContextaddToEnvironment, bind, bind, close, composeName, composeName, createSubcontext, createSubcontext, destroySubcontext, destroySubcontext, doLookup, doLookup, 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 javax.naming.directory.InitialDirContextbind, 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
 
- 
 
- 
- 
- 
Constructor Detail- 
InitialLdapContextpublic InitialLdapContext() throws NamingExceptionConstructs an initial context using no environment properties or connection request controls. Equivalent tonew InitialLdapContext(null, null).- Throws:
- NamingException- if a naming exception is encountered
 
 - 
InitialLdapContextpublic InitialLdapContext(Hashtable<?,?> environment, Control[] connCtls) throws NamingException Constructs an initial context using environment properties and connection request controls. Seejavax.naming.InitialContextfor a discussion of environment properties.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 environmentafter it has been passed to the constructor.connCtlsis 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- 
extendedOperationpublic ExtendedResponse extendedOperation(ExtendedRequest request) throws NamingException Description copied from interface:LdapContextPerforms an extended operation. This method is used to support LDAPv3 extended operations.- Specified by:
- extendedOperationin interface- LdapContext
- Parameters:
- request- The non-null request to be performed.
- Returns:
- The possibly null response of the operation. null means the operation did not generate any response.
- Throws:
- NamingException- If an error occurred while performing the extended operation.
 
 - 
newInstancepublic LdapContext newInstance(Control[] reqCtls) throws NamingException Description copied from interface:LdapContextCreates 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. - Specified by:
- newInstancein interface- LdapContext
- Parameters:
- reqCtls- The possibly null request controls to use for the new context. If null, the context is initialized with no request controls.
- Returns:
- A non-null LdapContextinstance.
- Throws:
- NamingException- If an error occurred while creating the new instance.
- See Also:
- InitialLdapContext
 
 - 
reconnectpublic void reconnect(Control[] connCtls) throws NamingException Description copied from interface:LdapContextReconnects 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 connCtlsto be its new connection request controls. This context's context request controls are not affected. After this method has been invoked, any subsequent implicit reconnections will be done usingconnCtls.connCtlsare also used as connection request controls for new context instances derived from this context. These connection request controls are not affected bysetRequestControls().Service provider implementors should read the "Service Provider" section in the class description for implementation details. - Specified by:
- reconnectin interface- LdapContext
- Parameters:
- connCtls- The possibly null controls to use. If null, no controls are used.
- Throws:
- NamingException- If an error occurred while reconnecting.
- See Also:
- LdapContext.getConnectControls(),- LdapContext.newInstance(javax.naming.ldap.Control[])
 
 - 
getConnectControlspublic Control[] getConnectControls() throws NamingException Description copied from interface:LdapContextRetrieves 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.- Specified by:
- getConnectControlsin interface- LdapContext
- Returns:
- A possibly-null array of controls. null means no connect controls have been set for this context.
- Throws:
- NamingException- If an error occurred while getting the request controls.
 
 - 
setRequestControlspublic void setRequestControls(Control[] requestControls) throws NamingException Description copied from interface:LdapContextSets 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 requestControlsfor use by subsequent methods invoked on this context. This method does not affect this context's connection request controls.Note that requestControlswill be in effect until the next invocation ofsetRequestControls(). You need to explicitly invokesetRequestControls()withnullor an empty array to clear the controls if you don't want them to affect the context methods any more. To check what request controls are in effect for this context, usegetRequestControls().- Specified by:
- setRequestControlsin interface- LdapContext
- Parameters:
- requestControls- The possibly null controls to use. If null, no controls are used.
- Throws:
- NamingException- If an error occurred while setting the request controls.
- See Also:
- LdapContext.getRequestControls()
 
 - 
getRequestControlspublic Control[] getRequestControls() throws NamingException Description copied from interface:LdapContextRetrieves 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.- Specified by:
- getRequestControlsin interface- LdapContext
- Returns:
- A possibly-null array of controls. null means no request controls have been set for this context.
- Throws:
- NamingException- If an error occurred while getting the request controls.
- See Also:
- LdapContext.setRequestControls(javax.naming.ldap.Control[])
 
 - 
getResponseControlspublic Control[] getResponseControls() throws NamingException Description copied from interface:LdapContextRetrieves 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. getResponseControls()returns all of the response controls generated by LDAP operations used by the context method in the order received from the LDAP server. InvokinggetResponseControls()does not clear the response controls. You can call it many times (and get back the same controls) until the next context method that may return controls is invoked.- Specified by:
- getResponseControlsin interface- LdapContext
- Returns:
- A possibly null array of controls. If null, the previous method invoked on this context did not produce any controls.
- Throws:
- NamingException- If an error occurred while getting the response controls.
 
 
- 
 
-