📄 ldapcontext.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Apr 27 23:37:39 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Interface LdapContext</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/LdapContext.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../javax/naming/ldap/HasControls.html"><B>PREV CLASS</B></A> <A HREF="../../../javax/naming/ldap/UnsolicitedNotification.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="LdapContext.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.naming.ldap</FONT><BR>Interface LdapContext</H2><DL><DT><B>All Superinterfaces:</B> <DD><A HREF="../../../javax/naming/Context.html">Context</A>, <A HREF="../../../javax/naming/directory/DirContext.html">DirContext</A></DD></DL><DL><DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../../javax/naming/ldap/InitialLdapContext.html">InitialLdapContext</A></DD></DL><HR><DL><DT>public interface <B>LdapContext</B><DT>extends <A HREF="../../../javax/naming/directory/DirContext.html">DirContext</A></DL><P>This interface represents a context in which you can perform operations with LDAPv3-style controls and perform LDAPv3-style extended operations. For applications that do not require such controls or extended operations, the more generic <tt>javax.naming.directory.DirContext</tt> should be used instead. <h3>Usage Details About Controls</h3> This interface provides support for LDAP v3 controls. At a high level, this support allows a user program to set request controls for LDAP operations that are executed in the course of the user program's invocation of <tt>Context</tt>/<tt>DirContext</tt> methods, and read response controls resulting from LDAP operations. At the implementation level, there are some details that developers of both the user program and service providers need to understand in order to correctly use request and response controls. <h3>Request Controls</h3> <p> There are two types of request controls: <ul> <li>Request controls that affect how a connection is created <li>Request controls that affect context methods </ul> The former is used whenever a connection needs to be established or re-established with an LDAP server. The latter is used when all other LDAP operations are sent to the LDAP server. The reason why a distinction between these two types of request controls is necessary is because JNDI is a high-level API that does not deal directly with connections. It is the job of service providers to do any necessary connection management. Consequently, a single connection may be shared by multiple context instances, and a service provider is free to use its own algorithms to conserve connection and network usage. Thus, when a method is invoked on the context instance, the service provider might need to do some connection management in addition to performing the corresponding LDAP operations. For connection management, it uses the <em>connection request controls</em>, while for the normal LDAP operations, it uses the <em>context request controls</em>.<p>Unless explicitly qualified, the term "request controls" refers to context request controls. <h4>Context Request Controls</h4> There are two ways in which a context instance gets its request controls: <ol> <tt> <li>ldapContext.newInstance(<strong>reqCtls</strong>) <li>ldapContext.setRequestControls(<strong>reqCtls</strong>) </tt> </ol> where <tt>ldapContext</tt> is an instance of <tt>LdapContext</tt>. Specifying <tt>null</tt> or an empty array for <tt>reqCtls</tt> means no request controls. <tt>newInstance()</tt> creates a new instance of a context using <tt>reqCtls</tt>, while <tt>setRequestControls()</tt> updates an existing context instance's request controls to <tt>reqCtls</tt>. <p> Unlike environment properties, request controls of a context instance <em>are not inherited</em> by context instances that are derived from it. Derived context instances have <tt>null</tt> as their context request controls. You must set the request controls of a derived context instance explicitly using <tt>setRequestControls()</tt>. <p> A context instance's request controls are retrieved using the method <tt>getRequestControls()</tt>. <h4>Connection Request Controls</h4> There are three ways in which connection request controls are set: <ol> <tt> <li> new InitialLdapContext(env, <strong>connCtls</strong>) <li>refException.getReferralContext(env, <strong>connCtls</strong>) <li>ldapContext.reconnect(<strong>connCtls</strong>); </tt> </ol> where <tt>referralException</tt> is an instance of <tt>LdapReferralException</tt>, and <tt>ldapContext</tt> is an instance of <tt>LdapContext</tt>. Specifying <tt>null</tt> or an empty array for <tt>connCtls</tt> means no connection request controls. <p> Like environment properties, connection request controls of a context <em>are inherited</em> by contexts that are derived from it. Typically, you initialize the connection request controls using the <tt>InitialLdapContext</tt> constructor or <tt>LdapReferralContext.getReferralContext()</tt>. These connection request controls are inherited by contexts that share the same connection--that is, contexts derived from the initial or referral contexts. <p> Use <tt>reconnect()</tt> to change the connection request controls of a context. Invoking <tt>ldapContext.reconnect()</tt> affects only the connection used by <tt>ldapContext</tt> and any new contexts instances that are derived form <tt>ldapContext</tt>. Contexts that previously shared the connection with <tt>ldapContext</tt> remain unchanged. That is, a context's connection request controls must be explicitly changed and is not affected by changes to another context's connection request controls. <p> A context instance's connection request controls are retrieved using the method <tt>getConnectControls()</tt>. <h4>Service Provider Requirements</h4> A service provider supports connection and context request controls in the following ways. Context request controls must be associated on a per context instance basis while connection request controls must be associated on a per connection instance basis. The service provider must look for the connection request controls in the environment property "java.naming.ldap.control.connect" and pass this environment property on to context instances that it creates. <h3>Response Controls</h3> The method <tt>LdapContext.getResponseControls()</tt> is used to retrieve the response controls generated by LDAP operations executed as the result of invoking a <tt>Context</tt>/<tt>DirContext</tt> operation. The result is all of the responses controls generated by the underlying LDAP operations, including any implicit reconnection. To get only the reconnection response controls, use <tt>reconnect()</tt> followed by <tt>getResponseControls()</tt>. <h3>Parameters</h3> A <tt>Control[]</tt> array passed as a parameter to any method is owned by the caller. The service provider will not modify the array or keep a reference to it, although it may keep references to the individual <tt>Control</tt> objects in the array. A <tt>Control[]</tt> array returned by any method is immutable, and may not subsequently be modified by either the caller or the service provider.<P><DL><DT><B>Since: </B><DD>1.3</DD><DT><B>See Also: </B><DD><A HREF="../../../javax/naming/ldap/InitialLdapContext.html"><CODE>InitialLdapContext</CODE></A>, <A HREF="../../../javax/naming/ldap/LdapReferralException.html#getReferralContext(java.util.Hashtable, javax.naming.ldap.Control[])"><CODE>LdapReferralException.getReferralContext(java.util.Hashtable,javax.naming.ldap.Control[])</CODE></A></DL>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -