<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FJNDI_LDAP%2FLdapName</id>
		<title>Java/JNDI LDAP/LdapName - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FJNDI_LDAP%2FLdapName"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/JNDI_LDAP/LdapName&amp;action=history"/>
		<updated>2026-04-07T13:16:48Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/JNDI_LDAP/LdapName&amp;diff=6873&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/JNDI_LDAP/LdapName&amp;diff=6873&amp;oldid=prev"/>
				<updated>2010-06-01T06:33:25Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&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;Версия 06:33, 1 июня 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>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/JNDI_LDAP/LdapName&amp;diff=6872&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/JNDI_LDAP/LdapName&amp;diff=6872&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:44Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Creates an LdapName and prints its components ==&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;
 * 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 javax.naming.InvalidNameException;&lt;br /&gt;
import javax.naming.ldap.LdapName;&lt;br /&gt;
/*&lt;br /&gt;
 * Creates an LdapName and prints its components&lt;br /&gt;
 * &lt;br /&gt;
 */&lt;br /&gt;
public class ConstructLdapName {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    String name = &amp;quot;cn=Mango, ou=Fruits, o=Food&amp;quot;;&lt;br /&gt;
    try {&lt;br /&gt;
      LdapName dn = new LdapName(name);&lt;br /&gt;
      System.out.println(dn + &amp;quot; has &amp;quot; + dn.size() + &amp;quot; RDNs: &amp;quot;);&lt;br /&gt;
      for (int i = 0; i &amp;lt; dn.size(); i++) {&lt;br /&gt;
        System.out.println(dn.get(i));&lt;br /&gt;
      }&lt;br /&gt;
    } catch (InvalidNameException e) {&lt;br /&gt;
      System.out.println(&amp;quot;Cannot parse name: &amp;quot; + name);&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;
== how an LdapName can be obtained from the search results ==&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;
 * 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.NamingEnumeration;&lt;br /&gt;
import javax.naming.directory.DirContext;&lt;br /&gt;
import javax.naming.directory.InitialDirContext;&lt;br /&gt;
import javax.naming.directory.SearchResult;&lt;br /&gt;
import javax.naming.ldap.LdapName;&lt;br /&gt;
/**&lt;br /&gt;
 * Shows how an LdapName can be obtained from the search results.&lt;br /&gt;
 */&lt;br /&gt;
class RetrievingLdapName {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    // Set up the environment for creating the 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;
      NamingEnumeration answer = ctx.search(&amp;quot;ou=People&amp;quot;, null);&lt;br /&gt;
      // Print the answer&lt;br /&gt;
      while (answer.hasMore()) {&lt;br /&gt;
        SearchResult sr = (SearchResult) answer.next();&lt;br /&gt;
        String name = sr.getNameInNamespace();&lt;br /&gt;
        System.out.println(name);&lt;br /&gt;
        LdapName dn = new LdapName(name);&lt;br /&gt;
        // do something with the dn&lt;br /&gt;
      }&lt;br /&gt;
      // Close the context when we&amp;quot;re done&lt;br /&gt;
      ctx.close();&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      e.printStackTrace();&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;
== how to pass LDAP name to the context methods ==&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;
 * 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.InitialContext;&lt;br /&gt;
import javax.naming.NamingException;&lt;br /&gt;
import javax.naming.ldap.LdapName;&lt;br /&gt;
/**&lt;br /&gt;
 * Demonstrates how to pass LDAP name to the context methods.&lt;br /&gt;
 */&lt;br /&gt;
class LookupLdapName {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    // Set up the environment for creating the 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/&amp;quot;);&lt;br /&gt;
    try {&lt;br /&gt;
      // Create the initial context&lt;br /&gt;
      Context ctx = new InitialContext(env);&lt;br /&gt;
      // A string representation of an LDAP name&lt;br /&gt;
      LdapName dn = new LdapName(&amp;quot;ou=People,o=JNDITutorial&amp;quot;);&lt;br /&gt;
      // Perform the lookup using the dn&lt;br /&gt;
      Object obj = ctx.lookup(dn);&lt;br /&gt;
      System.out.println(obj);&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;
      System.out.println(&amp;quot;Lookup failed: &amp;quot; + e);&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;
== Retrieve&amp;quot;s an LdapName&amp;quot;s suffix and prefix ==&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;
 * 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 javax.naming.InvalidNameException;&lt;br /&gt;
import javax.naming.Name;&lt;br /&gt;
import javax.naming.ldap.LdapName;&lt;br /&gt;
/*&lt;br /&gt;
 * Retrieve&amp;quot;s an LdapName&amp;quot;s suffix and prefix&lt;br /&gt;
 */&lt;br /&gt;
public class LdapNameSuffixPrefix {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    String name = &amp;quot;cn=Mango, ou=Fruits, o=Food&amp;quot;;&lt;br /&gt;
    try {&lt;br /&gt;
      LdapName dn = new LdapName(name);&lt;br /&gt;
      Name suffix = dn.getSuffix(1); // 1 &amp;lt;= index &amp;lt; cn.size()&lt;br /&gt;
      Name prefix = dn.getPrefix(1); // 0 &amp;lt;= index &amp;lt; 1&lt;br /&gt;
      System.out.println(suffix);&lt;br /&gt;
      System.out.println(prefix);&lt;br /&gt;
    } catch (InvalidNameException e) {&lt;br /&gt;
      System.out.println(&amp;quot;Cannot parse name: &amp;quot; + name);&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;
== Shows how LdapName to String conversion works ==&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;
 * 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 javax.naming.InvalidNameException;&lt;br /&gt;
import javax.naming.ldap.LdapName;&lt;br /&gt;
/*&lt;br /&gt;
 * Shows how LdapName to String conversion works&lt;br /&gt;
 */&lt;br /&gt;
public class LdapNametoString {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    String name = &amp;quot;cn=JuicyFruit, ou=Fruits&amp;quot;;&lt;br /&gt;
    try {&lt;br /&gt;
      LdapName dn = new LdapName(name);&lt;br /&gt;
      String str = dn.toString();&lt;br /&gt;
      System.out.println(str);&lt;br /&gt;
      LdapName dn2 = new LdapName(str);&lt;br /&gt;
      System.out.println(dn.equals(dn2));&lt;br /&gt;
    } catch (InvalidNameException e) {&lt;br /&gt;
      e.printStackTrace();&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;
== Shows ways of comparing LDAP names ==&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;
 * 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 javax.naming.InvalidNameException;&lt;br /&gt;
import javax.naming.ldap.LdapName;&lt;br /&gt;
/*&lt;br /&gt;
 * Shows ways of comparing LDAP names&lt;br /&gt;
 */&lt;br /&gt;
public class CompareLdapNames {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    try {&lt;br /&gt;
      LdapName one = new LdapName(&amp;quot;cn=Vincent Ryan, ou=People, o=JNDITutorial&amp;quot;);&lt;br /&gt;
      LdapName two = new LdapName(&amp;quot;cn=Vincent Ryan&amp;quot;);&lt;br /&gt;
      LdapName three = new LdapName(&amp;quot;o=JNDITutorial&amp;quot;);&lt;br /&gt;
      LdapName four = new LdapName(&amp;quot;&amp;quot;);&lt;br /&gt;
      System.out.println(one.equals(two)); // false&lt;br /&gt;
      System.out.println(one.startsWith(three)); // true&lt;br /&gt;
      System.out.println(one.endsWith(two)); // true&lt;br /&gt;
      System.out.println(one.startsWith(four)); // true&lt;br /&gt;
      System.out.println(one.endsWith(four)); // true&lt;br /&gt;
      System.out.println(one.endsWith(three)); // false&lt;br /&gt;
      System.out.println(one.isEmpty()); // false&lt;br /&gt;
      System.out.println(four.isEmpty()); // true&lt;br /&gt;
      System.out.println(four.size() == 0); // true&lt;br /&gt;
    } catch (InvalidNameException e) {&lt;br /&gt;
      e.printStackTrace();&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;
== Shows ways of modifying an Ldap 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;
 * 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 javax.naming.InvalidNameException;&lt;br /&gt;
import javax.naming.ldap.LdapName;&lt;br /&gt;
/*&lt;br /&gt;
 * Shows ways of modifying an Ldap Name&lt;br /&gt;
 * &lt;br /&gt;
 */&lt;br /&gt;
public class ModifyLdapName {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    try {&lt;br /&gt;
      LdapName dn = new LdapName(&amp;quot;ou=Fruits,o=Food&amp;quot;);&lt;br /&gt;
      LdapName dn2 = new LdapName(&amp;quot;ou=Summer&amp;quot;);&lt;br /&gt;
      System.out.println(dn.addAll(dn2)); // ou=Summer,ou=Fruits,o=Food&lt;br /&gt;
      System.out.println(dn.add(0, &amp;quot;o=Resources&amp;quot;)); // ou=Summer,ou=Fruits,o=Food,o=Resources&lt;br /&gt;
      System.out.println(dn.add(&amp;quot;cn=WaterMelon&amp;quot;)); // cn=WaterMelon,ou=Summer,ou=Fruits,o=Food,o=Resources&lt;br /&gt;
      System.out.println(dn.remove(1)); // o=Food&lt;br /&gt;
      System.out.println(dn); // cn=WaterMelon,ou=Summer,ou=Fruits,o=Resources&lt;br /&gt;
    } catch (InvalidNameException e) {&lt;br /&gt;
      e.printStackTrace();&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>
			</entry>

	</feed>