<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_by_API%2Fjavax.naming%2FContext</id>
		<title>Java by API/javax.naming/Context - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_by_API%2Fjavax.naming%2FContext"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_by_API/javax.naming/Context&amp;action=history"/>
		<updated>2026-04-24T23:39:31Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java_by_API/javax.naming/Context&amp;diff=2197&amp;oldid=prev</id>
		<title> в 17:43, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_by_API/javax.naming/Context&amp;diff=2197&amp;oldid=prev"/>
				<updated>2010-05-31T17:43:48Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 17:43, 31 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java_by_API/javax.naming/Context&amp;diff=2198&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_by_API/javax.naming/Context&amp;diff=2198&amp;oldid=prev"/>
				<updated>2010-05-31T14:43:30Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Context: addToEnvironment(String propName, Object propVal) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 1995 - 2008 Sun Microsystems, Inc.  All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 *&lt;br /&gt;
 *   - Redistributions of source code must retain the above copyright&lt;br /&gt;
 *     notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 *&lt;br /&gt;
 *   - Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *     notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *     documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 *   - Neither the name of Sun Microsystems nor the names of its&lt;br /&gt;
 *     contributors may be used to endorse or promote products derived&lt;br /&gt;
 *     from this software without specific prior written permission.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS&lt;br /&gt;
 * IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR&lt;br /&gt;
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,&lt;br /&gt;
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR&lt;br /&gt;
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF&lt;br /&gt;
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING&lt;br /&gt;
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS&lt;br /&gt;
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 */&lt;br /&gt;
import java.util.Hashtable;&lt;br /&gt;
import javax.naming.Context;&lt;br /&gt;
import javax.naming.NamingException;&lt;br /&gt;
import javax.naming.directory.DirContext;&lt;br /&gt;
import javax.naming.directory.InitialDirContext;&lt;br /&gt;
/**&lt;br /&gt;
 * Demonstrates how to use different authentication information for one context.&lt;br /&gt;
 * &lt;br /&gt;
 * usage: java UseDiff&lt;br /&gt;
 */&lt;br /&gt;
class UseDiff {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    // Set up environment for creating initial context&lt;br /&gt;
    Hashtable&amp;lt;String, Object&amp;gt; env = new Hashtable&amp;lt;String, Object&amp;gt;(11);&lt;br /&gt;
    env&lt;br /&gt;
        .put(Context.INITIAL_CONTEXT_FACTORY,&lt;br /&gt;
            &amp;quot;com.sun.jndi.ldap.LdapCtxFactory&amp;quot;);&lt;br /&gt;
    env.put(Context.PROVIDER_URL, &amp;quot;ldap://localhost:389/o=JNDITutorial&amp;quot;);&lt;br /&gt;
    // Authenticate as S. User and password &amp;quot;mysecret&amp;quot;&lt;br /&gt;
    env.put(Context.SECURITY_AUTHENTICATION, &amp;quot;simple&amp;quot;);&lt;br /&gt;
    env.put(Context.SECURITY_PRINCIPAL,&lt;br /&gt;
        &amp;quot;cn=S. User, ou=NewHires, o=JNDITutorial&amp;quot;);&lt;br /&gt;
    env.put(Context.SECURITY_CREDENTIALS, &amp;quot;mysecret&amp;quot;);&lt;br /&gt;
    try {&lt;br /&gt;
      // Create initial context&lt;br /&gt;
      DirContext ctx = new InitialDirContext(env);&lt;br /&gt;
      // do something useful with ctx&lt;br /&gt;
      System.out.println(ctx.lookup(&amp;quot;ou=NewHires&amp;quot;));&lt;br /&gt;
      // Change to using no authentication&lt;br /&gt;
      ctx.addToEnvironment(Context.SECURITY_AUTHENTICATION, &amp;quot;none&amp;quot;);&lt;br /&gt;
      System.out.println(ctx.lookup(&amp;quot;ou=NewHires&amp;quot;));&lt;br /&gt;
      // do something useful with ctx&lt;br /&gt;
      // Close the context when we&amp;quot;re done&lt;br /&gt;
      ctx.close();&lt;br /&gt;
    } catch (NamingException e) {&lt;br /&gt;
      e.printStackTrace();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Context: close() ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 1995 - 2008 Sun Microsystems, Inc.  All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 *&lt;br /&gt;
 *   - Redistributions of source code must retain the above copyright&lt;br /&gt;
 *     notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 *&lt;br /&gt;
 *   - Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *     notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *     documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 *   - Neither the name of Sun Microsystems nor the names of its&lt;br /&gt;
 *     contributors may be used to endorse or promote products derived&lt;br /&gt;
 *     from this software without specific prior written permission.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS&lt;br /&gt;
 * IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR&lt;br /&gt;
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,&lt;br /&gt;
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR&lt;br /&gt;
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF&lt;br /&gt;
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING&lt;br /&gt;
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS&lt;br /&gt;
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 */&lt;br /&gt;
import java.util.Hashtable;&lt;br /&gt;
import javax.naming.Context;&lt;br /&gt;
import javax.naming.NamingException;&lt;br /&gt;
import javax.naming.directory.DirContext;&lt;br /&gt;
import javax.naming.directory.InitialDirContext;&lt;br /&gt;
/**&lt;br /&gt;
 * Demonstrates how to enable connection pooling. Use debug option to observe&lt;br /&gt;
 * connection usage.&lt;br /&gt;
 * &lt;br /&gt;
 * usage: java -Dcom.sun.jndi.ldap.connect.pool.debug=fine UsePool&lt;br /&gt;
 */&lt;br /&gt;
class UsePool {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    // Set up environment for creating initial context&lt;br /&gt;
    Hashtable&amp;lt;String, Object&amp;gt; env = new Hashtable&amp;lt;String, Object&amp;gt;(11);&lt;br /&gt;
    env&lt;br /&gt;
        .put(Context.INITIAL_CONTEXT_FACTORY,&lt;br /&gt;
            &amp;quot;com.sun.jndi.ldap.LdapCtxFactory&amp;quot;);&lt;br /&gt;
    env.put(Context.PROVIDER_URL, &amp;quot;ldap://localhost:389/o=JNDITutorial&amp;quot;);&lt;br /&gt;
    // Enable connection pooling&lt;br /&gt;
    env.put(&amp;quot;com.sun.jndi.ldap.connect.pool&amp;quot;, &amp;quot;true&amp;quot;);&lt;br /&gt;
    try {&lt;br /&gt;
      // Create one initial context (Get connection from pool)&lt;br /&gt;
      DirContext ctx = new InitialDirContext(env);&lt;br /&gt;
      System.out.println(ctx.getAttributes(&amp;quot;ou=NewHires&amp;quot;));&lt;br /&gt;
      // do something useful with ctx&lt;br /&gt;
      // Close the context when we&amp;quot;re done&lt;br /&gt;
      ctx.close(); // Return connection to pool&lt;br /&gt;
      // Create another initial context (Get connection from pool)&lt;br /&gt;
      DirContext ctx2 = new InitialDirContext(env);&lt;br /&gt;
      System.out.println(ctx2.getAttributes(&amp;quot;ou=People&amp;quot;));&lt;br /&gt;
      // do something useful with ctx2&lt;br /&gt;
      // Close the context when we&amp;quot;re done&lt;br /&gt;
      ctx2.close(); // Return connection to pool&lt;br /&gt;
    } catch (NamingException e) {&lt;br /&gt;
      e.printStackTrace();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Context: createSubcontext(String name) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
import java.util.Hashtable;&lt;br /&gt;
import javax.naming.Context;&lt;br /&gt;
import javax.naming.InitialContext;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    String url = &amp;quot;iiop://localhost/&amp;quot;;&lt;br /&gt;
    Hashtable&amp;lt;String, String&amp;gt; env = new Hashtable&amp;lt;String, String&amp;gt;();&lt;br /&gt;
    env.put(Context.INITIAL_CONTEXT_FACTORY, &amp;quot;com.sun.jndi.cosnaming.CNCtxFactory&amp;quot;);&lt;br /&gt;
    env.put(Context.PROVIDER_URL, url);&lt;br /&gt;
    Context ctx = new InitialContext(env);&lt;br /&gt;
    // Create a subcontext.&lt;br /&gt;
    Context childCtx = ctx.createSubcontext(&amp;quot;child&amp;quot;);&lt;br /&gt;
    // Destroy the subcontext.&lt;br /&gt;
    ctx.destroySubcontext(&amp;quot;child&amp;quot;);&lt;br /&gt;
    Context obj = (Context) childCtx.lookup(&amp;quot;grandChild&amp;quot;);&lt;br /&gt;
    String fullname = obj.getNameInNamespace();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Context: destroySubcontext(String name) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
import java.util.Hashtable;&lt;br /&gt;
import javax.naming.Context;&lt;br /&gt;
import javax.naming.InitialContext;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    String url = &amp;quot;iiop://localhost/&amp;quot;;&lt;br /&gt;
    Hashtable&amp;lt;String, String&amp;gt; env = new Hashtable&amp;lt;String, String&amp;gt;();&lt;br /&gt;
    env.put(Context.INITIAL_CONTEXT_FACTORY, &amp;quot;com.sun.jndi.cosnaming.CNCtxFactory&amp;quot;);&lt;br /&gt;
    env.put(Context.PROVIDER_URL, url);&lt;br /&gt;
    Context ctx = new InitialContext(env);&lt;br /&gt;
    // Create a subcontext.&lt;br /&gt;
    Context childCtx = ctx.createSubcontext(&amp;quot;child&amp;quot;);&lt;br /&gt;
    // Destroy the subcontext.&lt;br /&gt;
    ctx.destroySubcontext(&amp;quot;child&amp;quot;);&lt;br /&gt;
    Context obj = (Context) childCtx.lookup(&amp;quot;grandChild&amp;quot;);&lt;br /&gt;
    String fullname = obj.getNameInNamespace();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Context: getNameInNamespace() ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
import java.util.Hashtable;&lt;br /&gt;
import javax.naming.Context;&lt;br /&gt;
import javax.naming.InitialContext;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    String url = &amp;quot;iiop://localhost/&amp;quot;;&lt;br /&gt;
    Hashtable&amp;lt;String, String&amp;gt; env = new Hashtable&amp;lt;String, String&amp;gt;();&lt;br /&gt;
    env.put(Context.INITIAL_CONTEXT_FACTORY, &amp;quot;com.sun.jndi.cosnaming.CNCtxFactory&amp;quot;);&lt;br /&gt;
    env.put(Context.PROVIDER_URL, url);&lt;br /&gt;
    Context ctx = new InitialContext(env);&lt;br /&gt;
    // Create a subcontext.&lt;br /&gt;
    Context childCtx = ctx.createSubcontext(&amp;quot;child&amp;quot;);&lt;br /&gt;
    // Destroy the subcontext.&lt;br /&gt;
    ctx.destroySubcontext(&amp;quot;child&amp;quot;);&lt;br /&gt;
    Context obj = (Context) childCtx.lookup(&amp;quot;grandChild&amp;quot;);&lt;br /&gt;
    String fullname = obj.getNameInNamespace();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Context: getNameParser(String name) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
import java.util.Hashtable;&lt;br /&gt;
import javax.naming.Context;&lt;br /&gt;
import javax.naming.InitialContext;&lt;br /&gt;
import javax.naming.Name;&lt;br /&gt;
import javax.naming.NameParser;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    String url = &amp;quot;iiop://localhost/&amp;quot;;&lt;br /&gt;
    Hashtable&amp;lt;String, String&amp;gt; env = new Hashtable&amp;lt;String, String&amp;gt;();&lt;br /&gt;
    env.put(Context.INITIAL_CONTEXT_FACTORY, &amp;quot;com.sun.jndi.cosnaming.CNCtxFactory&amp;quot;);&lt;br /&gt;
    env.put(Context.PROVIDER_URL, url);&lt;br /&gt;
    Context ctx = new InitialContext(env);&lt;br /&gt;
    NameParser parser = ctx.getNameParser(&amp;quot;&amp;quot;);&lt;br /&gt;
    Name dn = parser.parse(&amp;quot;cn=John, ou=People, o=JNDITutorial&amp;quot;);&lt;br /&gt;
    dn.remove(1); &lt;br /&gt;
    dn.add(0, &amp;quot;c=us&amp;quot;); &lt;br /&gt;
    dn.add(&amp;quot;cn=fs&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Context.INITIAL_CONTEXT_FACTORY ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
import java.sql.Connection;&lt;br /&gt;
import java.sql.ResultSet;&lt;br /&gt;
import java.sql.SQLException;&lt;br /&gt;
import java.sql.Statement;&lt;br /&gt;
import java.util.Properties;&lt;br /&gt;
import javax.naming.Context;&lt;br /&gt;
import javax.naming.InitialContext;&lt;br /&gt;
import javax.naming.NamingException;&lt;br /&gt;
import javax.sql.ConnectionPoolDataSource;&lt;br /&gt;
import javax.sql.PooledConnection;&lt;br /&gt;
public class PooledConnectionExample {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Connection connection = null;&lt;br /&gt;
    Statement statement = null;&lt;br /&gt;
    ResultSet resultSet = null;&lt;br /&gt;
    try {&lt;br /&gt;
      connection = getConnection();&lt;br /&gt;
      statement = connection.createStatement();&lt;br /&gt;
      String selectEmployeesSQL = &amp;quot;SELECT * FROM employees&amp;quot;;&lt;br /&gt;
      resultSet = statement.executeQuery(selectEmployeesSQL);&lt;br /&gt;
      while (resultSet.next()) {&lt;br /&gt;
        printEmployee(resultSet);&lt;br /&gt;
      }&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      e.printStackTrace();&lt;br /&gt;
    } finally {&lt;br /&gt;
      closeAll(resultSet, statement, connection);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
//Obtain connection from pool&lt;br /&gt;
  private static Connection getConnection() throws NamingException, SQLException {&lt;br /&gt;
    InitialContext initCtx = createContext();&lt;br /&gt;
    String jndiName = &amp;quot;HrDS&amp;quot;;&lt;br /&gt;
    ConnectionPoolDataSource dataSource = (ConnectionPoolDataSource) initCtx.lookup(jndiName);&lt;br /&gt;
    PooledConnection pooledConnection = dataSource.getPooledConnection();&lt;br /&gt;
    return pooledConnection.getConnection(); &lt;br /&gt;
  }&lt;br /&gt;
  private static InitialContext createContext() throws NamingException {&lt;br /&gt;
    Properties env = new Properties();&lt;br /&gt;
    env.put(Context.INITIAL_CONTEXT_FACTORY, &amp;quot;com.sun.jndi.rmi.registry.RegistryContextFactory&amp;quot;);&lt;br /&gt;
    env.put(Context.PROVIDER_URL, &amp;quot;rmi://localhost:1099&amp;quot;);&lt;br /&gt;
    InitialContext context = new InitialContext(env);&lt;br /&gt;
    return context;&lt;br /&gt;
  }&lt;br /&gt;
  private static void printEmployee(ResultSet resultSet) throws SQLException {&lt;br /&gt;
    System.out.print(resultSet.getInt(&amp;quot;employee_id&amp;quot;));&lt;br /&gt;
    System.out.print(&amp;quot;, &amp;quot;);&lt;br /&gt;
    System.out.print(resultSet.getString(&amp;quot;last_name&amp;quot;));&lt;br /&gt;
    System.out.print(&amp;quot;, &amp;quot;);&lt;br /&gt;
    System.out.print(resultSet.getString(&amp;quot;first_name&amp;quot;));&lt;br /&gt;
    System.out.print(&amp;quot;, &amp;quot;);&lt;br /&gt;
    System.out.println(resultSet.getString(&amp;quot;email&amp;quot;));&lt;br /&gt;
  }&lt;br /&gt;
  private static void closeAll(ResultSet resultSet, Statement statement, Connection connection) {&lt;br /&gt;
    if (resultSet != null) {&lt;br /&gt;
      try {&lt;br /&gt;
        resultSet.close();&lt;br /&gt;
      } catch (SQLException e) {&lt;br /&gt;
      } // nothing we can do&lt;br /&gt;
    }&lt;br /&gt;
    if (statement != null) {&lt;br /&gt;
      try {&lt;br /&gt;
        statement.close();&lt;br /&gt;
      } catch (SQLException e) {&lt;br /&gt;
      } // nothing we can do&lt;br /&gt;
    }&lt;br /&gt;
    if (connection != null) {&lt;br /&gt;
      try {&lt;br /&gt;
        connection.close();&lt;br /&gt;
      } catch (SQLException e) {&lt;br /&gt;
      } // nothing we can do&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Context: listBindings(String name) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.PrintWriter;&lt;br /&gt;
import javax.naming.Binding;&lt;br /&gt;
import javax.naming.Context;&lt;br /&gt;
import javax.naming.InitialContext;&lt;br /&gt;
import javax.naming.NamingEnumeration;&lt;br /&gt;
import javax.naming.NamingException;&lt;br /&gt;
import javax.servlet.ServletException;&lt;br /&gt;
import javax.servlet.http.HttpServlet;&lt;br /&gt;
import javax.servlet.http.HttpServletRequest;&lt;br /&gt;
import javax.servlet.http.HttpServletResponse;&lt;br /&gt;
public class EnvEntry extends HttpServlet {&lt;br /&gt;
  public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,&lt;br /&gt;
      IOException {&lt;br /&gt;
    res.setContentType(&amp;quot;text/plain&amp;quot;);&lt;br /&gt;
    PrintWriter out = res.getWriter();&lt;br /&gt;
    try {&lt;br /&gt;
      Context initCtx = new InitialContext();&lt;br /&gt;
      NamingEnumeration e = initCtx.listBindings(&amp;quot;java:comp/env&amp;quot;);&lt;br /&gt;
      while (e.hasMore()) {&lt;br /&gt;
        Binding binding = (Binding) e.next();&lt;br /&gt;
        out.println(&amp;quot;Name: &amp;quot; + binding.getName());&lt;br /&gt;
        out.println(&amp;quot;Type: &amp;quot; + binding.getClassName());&lt;br /&gt;
        out.println(&amp;quot;Value: &amp;quot; + binding.getObject());&lt;br /&gt;
        out.println();&lt;br /&gt;
      }&lt;br /&gt;
    } catch (NamingException e) {&lt;br /&gt;
      e.printStackTrace(out);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Context: lookup(String name) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
import java.util.Hashtable;&lt;br /&gt;
import javax.naming.Context;&lt;br /&gt;
import javax.naming.InitialContext;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    String url = &amp;quot;iiop://localhost/&amp;quot;;&lt;br /&gt;
    Hashtable&amp;lt;String, String&amp;gt; env = new Hashtable&amp;lt;String, String&amp;gt;();&lt;br /&gt;
    env.put(Context.INITIAL_CONTEXT_FACTORY, &amp;quot;com.sun.jndi.cosnaming.CNCtxFactory&amp;quot;);&lt;br /&gt;
    env.put(Context.PROVIDER_URL, url);&lt;br /&gt;
    Context ctx = new InitialContext(env);&lt;br /&gt;
    // Create a subcontext.&lt;br /&gt;
    Context childCtx = ctx.createSubcontext(&amp;quot;child&amp;quot;);&lt;br /&gt;
    // Destroy the subcontext.&lt;br /&gt;
    ctx.destroySubcontext(&amp;quot;child&amp;quot;);&lt;br /&gt;
    Context obj = (Context) childCtx.lookup(&amp;quot;grandChild&amp;quot;);&lt;br /&gt;
    String fullname = obj.getNameInNamespace();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Context.PROVIDER_URL ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
import java.sql.Connection;&lt;br /&gt;
import java.sql.ResultSet;&lt;br /&gt;
import java.sql.SQLException;&lt;br /&gt;
import java.sql.Statement;&lt;br /&gt;
import java.util.Properties;&lt;br /&gt;
import javax.naming.Context;&lt;br /&gt;
import javax.naming.InitialContext;&lt;br /&gt;
import javax.naming.NamingException;&lt;br /&gt;
import javax.sql.ConnectionPoolDataSource;&lt;br /&gt;
import javax.sql.PooledConnection;&lt;br /&gt;
public class PooledConnectionExample {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Connection connection = null;&lt;br /&gt;
    Statement statement = null;&lt;br /&gt;
    ResultSet resultSet = null;&lt;br /&gt;
    try {&lt;br /&gt;
      connection = getConnection();&lt;br /&gt;
      statement = connection.createStatement();&lt;br /&gt;
      String selectEmployeesSQL = &amp;quot;SELECT * FROM employees&amp;quot;;&lt;br /&gt;
      resultSet = statement.executeQuery(selectEmployeesSQL);&lt;br /&gt;
      while (resultSet.next()) {&lt;br /&gt;
        printEmployee(resultSet);&lt;br /&gt;
      }&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      e.printStackTrace();&lt;br /&gt;
    } finally {&lt;br /&gt;
      closeAll(resultSet, statement, connection);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
//Obtain connection from pool&lt;br /&gt;
  private static Connection getConnection() throws NamingException, SQLException {&lt;br /&gt;
    InitialContext initCtx = createContext();&lt;br /&gt;
    String jndiName = &amp;quot;HrDS&amp;quot;;&lt;br /&gt;
    ConnectionPoolDataSource dataSource = (ConnectionPoolDataSource) initCtx.lookup(jndiName);&lt;br /&gt;
    PooledConnection pooledConnection = dataSource.getPooledConnection();&lt;br /&gt;
    return pooledConnection.getConnection(); &lt;br /&gt;
  }&lt;br /&gt;
  private static InitialContext createContext() throws NamingException {&lt;br /&gt;
    Properties env = new Properties();&lt;br /&gt;
    env.put(Context.INITIAL_CONTEXT_FACTORY, &amp;quot;com.sun.jndi.rmi.registry.RegistryContextFactory&amp;quot;);&lt;br /&gt;
    env.put(Context.PROVIDER_URL, &amp;quot;rmi://localhost:1099&amp;quot;);&lt;br /&gt;
    InitialContext context = new InitialContext(env);&lt;br /&gt;
    return context;&lt;br /&gt;
  }&lt;br /&gt;
  private static void printEmployee(ResultSet resultSet) throws SQLException {&lt;br /&gt;
    System.out.print(resultSet.getInt(&amp;quot;employee_id&amp;quot;));&lt;br /&gt;
    System.out.print(&amp;quot;, &amp;quot;);&lt;br /&gt;
    System.out.print(resultSet.getString(&amp;quot;last_name&amp;quot;));&lt;br /&gt;
    System.out.print(&amp;quot;, &amp;quot;);&lt;br /&gt;
    System.out.print(resultSet.getString(&amp;quot;first_name&amp;quot;));&lt;br /&gt;
    System.out.print(&amp;quot;, &amp;quot;);&lt;br /&gt;
    System.out.println(resultSet.getString(&amp;quot;email&amp;quot;));&lt;br /&gt;
  }&lt;br /&gt;
  private static void closeAll(ResultSet resultSet, Statement statement, Connection connection) {&lt;br /&gt;
    if (resultSet != null) {&lt;br /&gt;
      try {&lt;br /&gt;
        resultSet.close();&lt;br /&gt;
      } catch (SQLException e) {&lt;br /&gt;
      } // nothing we can do&lt;br /&gt;
    }&lt;br /&gt;
    if (statement != null) {&lt;br /&gt;
      try {&lt;br /&gt;
        statement.close();&lt;br /&gt;
      } catch (SQLException e) {&lt;br /&gt;
      } // nothing we can do&lt;br /&gt;
    }&lt;br /&gt;
    if (connection != null) {&lt;br /&gt;
      try {&lt;br /&gt;
        connection.close();&lt;br /&gt;
      } catch (SQLException e) {&lt;br /&gt;
      } // nothing we can do&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Context: rename(String oldName, String newName) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 1995 - 2008 Sun Microsystems, Inc.  All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 *&lt;br /&gt;
 *   - Redistributions of source code must retain the above copyright&lt;br /&gt;
 *     notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 *&lt;br /&gt;
 *   - Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *     notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *     documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 *   - Neither the name of Sun Microsystems nor the names of its&lt;br /&gt;
 *     contributors may be used to endorse or promote products derived&lt;br /&gt;
 *     from this software without specific prior written permission.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS&lt;br /&gt;
 * IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR&lt;br /&gt;
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,&lt;br /&gt;
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR&lt;br /&gt;
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF&lt;br /&gt;
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING&lt;br /&gt;
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS&lt;br /&gt;
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 */&lt;br /&gt;
import java.util.Hashtable;&lt;br /&gt;
import javax.naming.Context;&lt;br /&gt;
import javax.naming.NamingException;&lt;br /&gt;
import javax.naming.directory.DirContext;&lt;br /&gt;
import javax.naming.directory.InitialDirContext;&lt;br /&gt;
/**&lt;br /&gt;
 * Demonstrates how to rename an entry to another part of the namespace.&lt;br /&gt;
 * &lt;br /&gt;
 * usage: java RenameDiffParent&lt;br /&gt;
 */&lt;br /&gt;
class RenameDiffParent {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    // Set up environment for creating initial context&lt;br /&gt;
    Hashtable&amp;lt;String, Object&amp;gt; env = new Hashtable&amp;lt;String, Object&amp;gt;(11);&lt;br /&gt;
    env&lt;br /&gt;
        .put(Context.INITIAL_CONTEXT_FACTORY,&lt;br /&gt;
            &amp;quot;com.sun.jndi.ldap.LdapCtxFactory&amp;quot;);&lt;br /&gt;
    env.put(Context.PROVIDER_URL, &amp;quot;ldap://localhost:389/o=JNDITutorial&amp;quot;);&lt;br /&gt;
    try {&lt;br /&gt;
      // Create initial context&lt;br /&gt;
      DirContext ctx = new InitialDirContext(env);&lt;br /&gt;
      // Perform rename&lt;br /&gt;
      ctx.rename(&amp;quot;cn=C. User, ou=NewHires&amp;quot;, &amp;quot;cn=C. User, ou=People&amp;quot;);&lt;br /&gt;
      // Check that it worked&lt;br /&gt;
      System.out.println(ctx.lookup(&amp;quot;cn=C. User, ou=People&amp;quot;));&lt;br /&gt;
      // Revert change&lt;br /&gt;
      ctx.rename(&amp;quot;cn=C. User, ou=People&amp;quot;, &amp;quot;cn=C. User, ou=NewHires&amp;quot;);&lt;br /&gt;
      // Check that we are back at our original setup&lt;br /&gt;
      System.out.println(ctx.lookup(&amp;quot;cn=C. User, ou=NewHires&amp;quot;));&lt;br /&gt;
      // Close the context when we&amp;quot;re done&lt;br /&gt;
      ctx.close();&lt;br /&gt;
    } catch (NamingException e) {&lt;br /&gt;
      e.printStackTrace();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Context.SECURITY_AUTHENTICATION ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 1995 - 2008 Sun Microsystems, Inc.  All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 *&lt;br /&gt;
 *   - Redistributions of source code must retain the above copyright&lt;br /&gt;
 *     notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 *&lt;br /&gt;
 *   - Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *     notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *     documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 *   - Neither the name of Sun Microsystems nor the names of its&lt;br /&gt;
 *     contributors may be used to endorse or promote products derived&lt;br /&gt;
 *     from this software without specific prior written permission.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS&lt;br /&gt;
 * IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR&lt;br /&gt;
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,&lt;br /&gt;
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR&lt;br /&gt;
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF&lt;br /&gt;
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING&lt;br /&gt;
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS&lt;br /&gt;
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 */&lt;br /&gt;
import java.util.Hashtable;&lt;br /&gt;
import javax.naming.Context;&lt;br /&gt;
import javax.naming.NamingException;&lt;br /&gt;
import javax.naming.directory.DirContext;&lt;br /&gt;
import javax.naming.directory.InitialDirContext;&lt;br /&gt;
/**&lt;br /&gt;
 * Demonstrates how failure to supply correct authentication information fails.&lt;br /&gt;
 * &lt;br /&gt;
 * usage: java BadPasswd&lt;br /&gt;
 */&lt;br /&gt;
class BadPasswd {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    // Set up environment for creating initial context&lt;br /&gt;
    Hashtable&amp;lt;String, Object&amp;gt; env = new Hashtable&amp;lt;String, Object&amp;gt;(11);&lt;br /&gt;
    env&lt;br /&gt;
        .put(Context.INITIAL_CONTEXT_FACTORY,&lt;br /&gt;
            &amp;quot;com.sun.jndi.ldap.LdapCtxFactory&amp;quot;);&lt;br /&gt;
    env.put(Context.PROVIDER_URL, &amp;quot;ldap://localhost:389/o=JNDITutorial&amp;quot;);&lt;br /&gt;
    // Authenticate as S. User and give incorrect password&lt;br /&gt;
    env.put(Context.SECURITY_AUTHENTICATION, &amp;quot;simple&amp;quot;);&lt;br /&gt;
    env.put(Context.SECURITY_PRINCIPAL,&lt;br /&gt;
        &amp;quot;cn=S. User, ou=NewHires, o=JNDITutorial&amp;quot;);&lt;br /&gt;
    env.put(Context.SECURITY_CREDENTIALS, &amp;quot;notmysecret&amp;quot;);&lt;br /&gt;
    try {&lt;br /&gt;
      // Create initial context&lt;br /&gt;
      DirContext ctx = new InitialDirContext(env);&lt;br /&gt;
      System.out.println(ctx.lookup(&amp;quot;ou=NewHires&amp;quot;));&lt;br /&gt;
      // do something useful with ctx&lt;br /&gt;
      // Close the context when we&amp;quot;re done&lt;br /&gt;
      ctx.close();&lt;br /&gt;
    } catch (NamingException e) {&lt;br /&gt;
      e.printStackTrace();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Context.SECURITY_CREDENTIALS ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 1995 - 2008 Sun Microsystems, Inc.  All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 *&lt;br /&gt;
 *   - Redistributions of source code must retain the above copyright&lt;br /&gt;
 *     notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 *&lt;br /&gt;
 *   - Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *     notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *     documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 *   - Neither the name of Sun Microsystems nor the names of its&lt;br /&gt;
 *     contributors may be used to endorse or promote products derived&lt;br /&gt;
 *     from this software without specific prior written permission.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS&lt;br /&gt;
 * IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR&lt;br /&gt;
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,&lt;br /&gt;
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR&lt;br /&gt;
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF&lt;br /&gt;
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING&lt;br /&gt;
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS&lt;br /&gt;
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 */&lt;br /&gt;
import java.util.Hashtable;&lt;br /&gt;
import javax.naming.Context;&lt;br /&gt;
import javax.naming.NamingException;&lt;br /&gt;
import javax.naming.directory.DirContext;&lt;br /&gt;
import javax.naming.directory.InitialDirContext;&lt;br /&gt;
/**&lt;br /&gt;
 * Demonstrates how failure to supply correct authentication information fails.&lt;br /&gt;
 * &lt;br /&gt;
 * usage: java BadPasswd&lt;br /&gt;
 */&lt;br /&gt;
class BadPasswd {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    // Set up environment for creating initial context&lt;br /&gt;
    Hashtable&amp;lt;String, Object&amp;gt; env = new Hashtable&amp;lt;String, Object&amp;gt;(11);&lt;br /&gt;
    env&lt;br /&gt;
        .put(Context.INITIAL_CONTEXT_FACTORY,&lt;br /&gt;
            &amp;quot;com.sun.jndi.ldap.LdapCtxFactory&amp;quot;);&lt;br /&gt;
    env.put(Context.PROVIDER_URL, &amp;quot;ldap://localhost:389/o=JNDITutorial&amp;quot;);&lt;br /&gt;
    // Authenticate as S. User and give incorrect password&lt;br /&gt;
    env.put(Context.SECURITY_AUTHENTICATION, &amp;quot;simple&amp;quot;);&lt;br /&gt;
    env.put(Context.SECURITY_PRINCIPAL,&lt;br /&gt;
        &amp;quot;cn=S. User, ou=NewHires, o=JNDITutorial&amp;quot;);&lt;br /&gt;
    env.put(Context.SECURITY_CREDENTIALS, &amp;quot;notmysecret&amp;quot;);&lt;br /&gt;
    try {&lt;br /&gt;
      // Create initial context&lt;br /&gt;
      DirContext ctx = new InitialDirContext(env);&lt;br /&gt;
      System.out.println(ctx.lookup(&amp;quot;ou=NewHires&amp;quot;));&lt;br /&gt;
      // do something useful with ctx&lt;br /&gt;
      // Close the context when we&amp;quot;re done&lt;br /&gt;
      ctx.close();&lt;br /&gt;
    } catch (NamingException e) {&lt;br /&gt;
      e.printStackTrace();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Context.SECURITY_PRINCIPAL ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 1995 - 2008 Sun Microsystems, Inc.  All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 *&lt;br /&gt;
 *   - Redistributions of source code must retain the above copyright&lt;br /&gt;
 *     notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 *&lt;br /&gt;
 *   - Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *     notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *     documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 *   - Neither the name of Sun Microsystems nor the names of its&lt;br /&gt;
 *     contributors may be used to endorse or promote products derived&lt;br /&gt;
 *     from this software without specific prior written permission.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS&lt;br /&gt;
 * IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR&lt;br /&gt;
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,&lt;br /&gt;
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR&lt;br /&gt;
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF&lt;br /&gt;
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING&lt;br /&gt;
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS&lt;br /&gt;
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 */&lt;br /&gt;
import java.util.Hashtable;&lt;br /&gt;
import javax.naming.Context;&lt;br /&gt;
import javax.naming.NamingException;&lt;br /&gt;
import javax.naming.directory.DirContext;&lt;br /&gt;
import javax.naming.directory.InitialDirContext;&lt;br /&gt;
/**&lt;br /&gt;
 * Demonstrates how failure to supply correct authentication information fails.&lt;br /&gt;
 * &lt;br /&gt;
 * usage: java BadPasswd&lt;br /&gt;
 */&lt;br /&gt;
class BadPasswd {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    // Set up environment for creating initial context&lt;br /&gt;
    Hashtable&amp;lt;String, Object&amp;gt; env = new Hashtable&amp;lt;String, Object&amp;gt;(11);&lt;br /&gt;
    env&lt;br /&gt;
        .put(Context.INITIAL_CONTEXT_FACTORY,&lt;br /&gt;
            &amp;quot;com.sun.jndi.ldap.LdapCtxFactory&amp;quot;);&lt;br /&gt;
    env.put(Context.PROVIDER_URL, &amp;quot;ldap://localhost:389/o=JNDITutorial&amp;quot;);&lt;br /&gt;
    // Authenticate as S. User and give incorrect password&lt;br /&gt;
    env.put(Context.SECURITY_AUTHENTICATION, &amp;quot;simple&amp;quot;);&lt;br /&gt;
    env.put(Context.SECURITY_PRINCIPAL,&lt;br /&gt;
        &amp;quot;cn=S. User, ou=NewHires, o=JNDITutorial&amp;quot;);&lt;br /&gt;
    env.put(Context.SECURITY_CREDENTIALS, &amp;quot;notmysecret&amp;quot;);&lt;br /&gt;
    try {&lt;br /&gt;
      // Create initial context&lt;br /&gt;
      DirContext ctx = new InitialDirContext(env);&lt;br /&gt;
      System.out.println(ctx.lookup(&amp;quot;ou=NewHires&amp;quot;));&lt;br /&gt;
      // do something useful with ctx&lt;br /&gt;
      // Close the context when we&amp;quot;re done&lt;br /&gt;
      ctx.close();&lt;br /&gt;
    } catch (NamingException e) {&lt;br /&gt;
      e.printStackTrace();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Context: unbind(String name) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
import java.util.Hashtable;&lt;br /&gt;
import javax.naming.Context;&lt;br /&gt;
import javax.naming.InitialContext;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    String url = &amp;quot;iiop://localhost/&amp;quot;;&lt;br /&gt;
    Hashtable&amp;lt;String, String&amp;gt; env = new Hashtable&amp;lt;String, String&amp;gt;();&lt;br /&gt;
    env.put(Context.INITIAL_CONTEXT_FACTORY, &amp;quot;com.sun.jndi.cosnaming.CNCtxFactory&amp;quot;);&lt;br /&gt;
    env.put(Context.PROVIDER_URL, url);&lt;br /&gt;
    Context ctx = new InitialContext(env);&lt;br /&gt;
    // Add a binding.&lt;br /&gt;
    ctx.bind(&amp;quot;Name&amp;quot;, null);&lt;br /&gt;
    // Replace a binding.&lt;br /&gt;
    ctx.rebind(&amp;quot;Name&amp;quot;, null);&lt;br /&gt;
    // Remove a binding.&lt;br /&gt;
    ctx.unbind(&amp;quot;Name&amp;quot;);&lt;br /&gt;
    // Rename a binding.&lt;br /&gt;
    ctx.rename(&amp;quot;Name&amp;quot;, &amp;quot;NewSample&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>