LECTURE 4 ¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤Î¸¡º÷

¡û ¤Ï¤¸¤á¤Ë

LDAP ¥¯¥é¥¤¥¢¥ó¥È¤ÇºÇ¤â»ÈÍѤµ¤ì¤ëµ¡Ç½¤Ç¤¢¤ë(¤È¼«Ê¬¤Ç¤Ï»×¤Ã¤Æ¤ë¤Î¤Ç¤¹¤¬¡£¡£¡£)¸¡º÷½èÍý¤Ë¤Ä¤¤¤Æº£²ó¤ÏÀâÌÀ¤·¤Æ¤¤¤­¤Þ¤¹¡£Á°²óÅÐÏ¿¤·¤¿¥¨¥ó¥È¥ê¤Î¸¡º÷¤â¤Ç¤­¤Þ¤¹¤·¡¢¿È¶á¤Ë¸ø³«¤µ¤ì¤Æ¤¤¤ë LDAP ¥µ¡¼¥Ð¤Ê¤É¤¬¤¢¤ì¤Ð¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤Î¸¡º÷¤â»×¤¦¤¬¤Þ¤Þ¤Ç¤¹! ¤¼¤Ò³èÍѤ·¤Æ¤ß¤Æ²¼¤µ¤¤¡£

¡û ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à

LDAP ¥µ¡¼¥Ð¤ËÀܳ¤·¤Æ¡¢»ØÄê¾ò·ï¤Ë³ºÅö¤¹¤ë¥¨¥ó¥È¥ê¤ÎÁ´Â°À­¤òɽ¼¨¤¹¤ë¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à LDAPSearch.java ¤Ç¤¹¡£RFC 2254 ¤Ç»ØÄꤵ¤ì¤Æ¤¤¤ë¸¡º÷¥Õ¥£¥ë¥¿¤ò»ÈÍѤ¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹(¤È¤¤¤¦¤«¤³¤ì¤·¤«»È¤¨¤Ê¤¤¡£¡£¡£)¡£

¥³¥ó¥Ñ¥¤¥ë¤¬½ªÎ»¤·¤¿¤é

java LDAPSearch [LDAP¥µ¡¼¥Ð̾/IP¥¢¥É¥ì¥¹] \
                [bind¥æ¡¼¥¶¤ÎDN] \
                [bind¥æ¡¼¥¶¤Î¥Ñ¥¹¥ï¡¼¥É] \
                [¸¡º÷¥Ù¡¼¥¹] \
                [¸¡º÷¥Õ¥£¥ë¥¿]

¤Ç¼Â¹Ô¤Ç¤¹¡£Àµ¾ï¤Ë½èÍý¤¬½ªÎ»¤·¤¿¾ì¹ç¤Ï¡¢»ØÄꤷ¤¿¾ò·ï¤Ë³ºÅö¤¹¤ë¥¨¥ó¥È¥ê¤ÎÁ´Â°À­¤¬É½¼¨¤µ¤ì¤Þ¤¹(³ºÅö¥¨¥ó¥È¥ê¤¬Ìµ¤¤¾ì¹ç¤Ï²¿¤âɽ¼¨¤µ¤ì¤Þ¤»¤ó)¡£Îã³°¤¬È¯À¸¤·¤¿¤é¡¢¤½¤ÎÆâÍƤ¬É½¼¨¤µ¤ì¤Þ¤¹¡£

¤Ê¤ª¡¢¤Ï¤¸¤á¤Ë ¤Î¥Ú¡¼¥¸¤«¤éÁ´¤Æ¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ò¸Ç¤á¤¿ tar ¥Ü¡¼¥ë¤ò¥À¥¦¥ó¥í¡¼¥É¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£

--- LDAPSearch.java ---

    1	import java.util.Enumeration;
    2	import org.ietf.ldap.LDAPAttribute;
    3	import org.ietf.ldap.LDAPAttributeSet;
    4	import org.ietf.ldap.LDAPConnection;
    5	import org.ietf.ldap.LDAPEntry;
    6	import org.ietf.ldap.LDAPException;
    7	import org.ietf.ldap.LDAPSearchResults;
    8	
    9	
   10	/**
   11	 * »ØÄꤵ¤ì¤¿ LDAP ¥µ¡¼¥Ð¤ËÀܳ¤·¡¢¾ò·ï¤Ë±þ¤¸¤¿¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤ò¸¡º÷¤·¡¢
   12	 * »ØÄꤵ¤ì¤¿Â°À­¤òɽ¼¨¤¹¤ë¡£
   13	 *
   14	 * @version 19 May 2002
   15	 * @author  Ryo Ichinose
   16	 */
   17	public class LDAPSearch
   18	{
   19		/**
   20		 * LDAP Protocol Version 3
   21		 */
   22		public static final int LDAP_V3 = 3; // LDAPv3
   23	
   24	
   25		/**
   26		 * »ØÄꤵ¤ì¤¿ LDAP ¥µ¡¼¥Ð¤ËÀܳ¤·¡¢¾ò·ï¤Ë±þ¤¸¤¿¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê
   27		 * ¤ò¸¡º÷¤·¡¢¤½¤Î¥¨¥ó¥È¥ê¤Î°À­¤òɽ¼¨¤¹¤ë¡£»ØÄ긡º÷¥Ù¡¼¥¹°Ê²¼Á´¤Æ¤Î
   28		 * ¥¨¥ó¥È¥ê¤ò¸¡º÷¤¹¤ë¡£
   29		 *
   30		 * @param host    ¥Û¥¹¥È̾¤â¤·¤¯¤Ï IP¥¢¥É¥ì¥¹
   31		 * @param binddn  bind ¥æ¡¼¥¶¤Î DN
   32		 * @param bindpw  bind ¥æ¡¼¥¶¤Î¥Ñ¥¹¥ï¡¼¥É
   33		 * @param base    ¸¡º÷¥Ù¡¼¥¹
   34		 * @param filter  ¸¡º÷¥Õ¥£¥ë¥¿
   35		 */
   36		public void search( String host, String binddn, String bindpw,
   37				    String base, String filter )
   38		{
   39			// ¸¡º÷°À­¥ê¥¹¥È(Á´Â°À­»ØÄê)
   40			String attrs[] = { LDAPConnection.ALL_USER_ATTRS };
   41	
   42			LDAPConnection lc = new LDAPConnection();
   43	
   44			try {
   45				// LDAP ¥µ¡¼¥Ð¤ËÀܳ¤¹¤ë¡£¥Ý¡¼¥È¤Ï¥Ç¥Õ¥©¥ë¥È(389ÈÖ)¤ò»È¤¦¡£
   46				lc.connect( host, LDAPConnection.DEFAULT_PORT );
   47				System.out.println( "Connected to " + host );
   48				System.out.println();
   49	
   50	
   51				// »ØÄꤵ¤ì¤¿ DN ¤ª¤è¤Ó¥Ñ¥¹¥ï¡¼¥É¤Ç¥Ð¥¤¥ó¥É(ǧ¾Ú)¤¹¤ë¡£
   52				// ¤³¤ì¤ò¼Â¹Ô¤·¤Ê¤¤¾ì¹ç¡¢anonymous ¾õÂÖ¤ÇÁàºî¤¹¤ë¤³¤È¤Ë¤Ê¤ë¡£
   53				lc.bind( LDAPSearch.LDAP_V3, binddn, bindpw );
   54	
   55	
   56				// »ØÄê¾ò·ï¤Ç¤Î¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤Î¸¡º÷¤ò¹Ô¤¦¡£
   57				LDAPSearchResults results =	lc.search( 
   58					base,                     // ¸¡º÷¥Ù¡¼¥¹
   59					LDAPConnection.SCOPE_SUB, // ¸¡º÷¥¹¥³¡¼¥×
   60					filter,                   // ¸¡º÷¥Õ¥£¥ë¥¿
   61					attrs,                    // ¸¡º÷°À­¥ê¥¹¥È
   62					false                     // °À­Ì¾¤ª¤è¤Ó°À­ÃͤμèÆÀ
   63				);
   64	
   65				// ÆÀ¤é¤ì¤¿¥¨¥ó¥È¥ê¤òÁ´¤Æɽ¼¨¤¹¤ë¡£
   66				while( results.hasMoreElements() ) {
   67					showLDAPEntry( results.next() );
   68				}
   69	
   70				// Àܳ¤òÀÚÃǤ¹¤ë¡£
   71				lc.disconnect();
   72				System.out.println();		
   73				System.out.println( "Disconnected" );
   74			}
   75			catch( LDAPException e ) {
   76				System.out.println( "LDAPException occured : " + 
   77						    e.toString() );
   78			}
   79		}
   80	
   81	
   82		private void showLDAPEntry( LDAPEntry entry )
   83		{
   84			System.out.println( "Listing attributes of " + entry.getDN() + " :" );
   85			Enumeration items = entry.getAttributeSet().getAttributes();
   86	
   87			while( items.hasMoreElements() ) {
   88				// ³Æ°À­¤ËÂФ·¤ÆÊ£¿ô¤Î°À­Ãͤ¬ÀßÄꤵ¤ì¤Æ¤¤¤ë²ÄǽÀ­¤¬¤¢¤ë¤¬¡¢
   89				// ¤³¤³¤Ç¤ÏºÇ½é¤Î°À­ÃͤΤßɽ¼¨¤¹¤ë¤³¤È¤Ë¤¹¤ë¡£
   90				LDAPAttribute attr = ( LDAPAttribute )items.nextElement();
   91				Enumeration vals = attr.getStringValues();
   92				String val  = ( String )vals.nextElement();
   93				System.out.println( "  " + attr.getName() + ": " + val );
   94			}
   95	
   96			System.out.println();		
   97		}
   98	
   99	
  100		/**
  101		 * ¥¨¥ó¥È¥ê¥Ý¥¤¥ó¥È
  102		 *
  103		 * @param args 
  104		 *    <ul>
  105		 *      <li>args[0] --- ¥Û¥¹¥È̾¤â¤·¤¯¤Ï IP ¥¢¥É¥ì¥¹
  106		 *      <li>args[1] --- bind ¥æ¡¼¥¶¤Î DN
  107		 *      <li>args[2] --- bind ¥æ¡¼¥¶¤Î¥Ñ¥¹¥ï¡¼¥É
  108		 *      <li>args[3] --- ¸¡º÷¥Ù¡¼¥¹
  109		 *      <li>args[4] --- ¸¡º÷¥Õ¥£¥ë¥¿
  110		 *    </ul>
  111		 */
  112		public static void main( String[] args )
  113		{
  114			LDAPSearch obj = new LDAPSearch();
  115			obj.search( args[0], args[1], args[2], args[3], args[4] );
  116		}
  117	}


¡û ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ÎÀâÌÀ

¤Ç¤Ï¡¢¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Æ¤¤¤­¤Þ¤¹¡£

  • 1 ¡Á 7 ¹ÔÌÜ

    »ÈÍѤ¹¤ë¥¯¥é¥¹¥é¥¤¥Ö¥é¥ê¤Î¥Ñ¥Ã¥±¡¼¥¸»ØÄê¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£LDAPSearch.java ¤Ç¤Ï¿·¤¿¤Ë LDAPSearchResults ¥¯¥é¥¹¤ò»ÈÍѤ·¤Æ¤¤¤Þ¤¹¡£

  • 25 ¡Á 79 ¹ÔÌÜ ( LDAPSearch#search() )

    LDAPSearch#search() ¥á¥½¥Ã¥É¤Ç¡¢¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤Î¸¡º÷½èÍý¤ò¹Ô¤¤¤Þ¤¹¡£³Æ¥ö½ê¤Ë ¤Ä¤¤¤Æ°Ê¹ß¤ÇÀâÌÀ¤·¤Þ¤¹¡£

    • 39 ¡Á 40 ¹ÔÌÜ

      LDAPConnection#search() ¥á¥½¥Ã¥É¤Ë»ØÄꤹ¤ë¸¡º÷°À­¥ê¥¹¥È¤òÇÛÎó¤È¤·¤ÆºîÀ®¤·¤Æ¤¤¤Þ¤¹¡£ ¤³¤ÎÇÛÎó¤Ë¸¡º÷¤·¤¿¤¤Â°À­Ì¾¤òÎóµó¤·¤Æ¤ª¤¯¤È¡¢¤½¤ì¤é¤ÎÃͤΤߤò¼èÆÀ¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹ (ex. String attrs[] = { "objectclass", "cn", "uid" }; )¡£

      ¤³¤³¤Ç¤Ï LDAPConnection.ALL_USER_ATTRS ¤ò»ØÄꤷ¤Æ¤¤¤Þ¤¹¤¬¡¢¤³¤ì¤ÏÁ´¤Æ¤Î°À­¾ðÊó¤ò¼èÆÀ ¤¹¤ë¤³¤È¤ò»ØÄꤹ¤ë¤¿¤á¤Î¤â¤Î¤Ç¤¹¡£¤Á¤Ê¤ß¤Ë LDAPConnection.NO_ATTRS ¤ò»ØÄꤹ¤ë¤È¡¢³Æ °À­¤Ë¤Ä¤¤¤Æ¤Î¾ðÊó¤Ï¼èÆÀ¤»¤º¾ò·ï¤Ë³ºÅö¤¹¤ë¥¨¥ó¥È¥ê¤Î̾¾Î¤Î¤ß¤ò¼èÆÀ¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£

    • 56 ¡Á 63 ¹ÔÌÜ

      LDAPConnection#search() ¥á¥½¥Ã¥É¤ò»È¤Ã¤Æ¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤Î¸¡º÷¤ò¼Â¹Ô¤·¤Æ¤¤¤Þ¤¹¡£

          public LDAPSearchResults LDAPConnection#search( 
                                           String   base,
                                           int      scope,
                                           String   filter,
                                           String[] attrs,
                                           boolean  typesOnly )
             throws LDAPException
      
          base      : ¸¡º÷¥Ù¡¼¥¹
          scope     : ¸¡º÷¥¹¥³¡¼¥× 
                       ( LDAPConnection.SCOPE_BASE /
                         LDAPConnection.SCOPE_ONE  /
                         LDAPConnection.SCOPE_SUB )
      
          filter    : ¸¡º÷¥Õ¥£¥ë¥¿
          attrs     : ¾ðÊó¤ò¼èÆÀ¤¹¤ë°À­Ì¾¤òÎóµó¤·¤¿ÇÛÎó
          typesOnly : °À­Ì¾¤Î¤ß¤ò¼èÆÀ¤¹¤ë¤«(true)¡¢ÃͤȤÎÁȤǼèÆÀ¤¹¤ë¤«(false)¤ò»ØÄê
      
      

      ¸¡º÷¥Ù¡¼¥¹¤Ë¤Ï¸¡º÷Âоݥĥ꡼¤Î¥È¥Ã¥×¤È¤Ê¤ë DN ¤ò»ØÄꤷ¤Þ¤¹¡£

      ¸¡º÷¥¹¥³¡¼¥×¤Ë¤Ï

      • LDAPConnection.SCOPE_BASE
      • LDAPConnection.SCOPE_ONE
      • LDAPConnection.SCOPE_SUB

      ¤Î¤¤¤º¤ì¤«¤ò»ØÄꤷ¤Þ¤¹¡£SCOPE_BASE ¤Ï»ØÄê DN ¤Î¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤Î¤ß¤ò¸¡º÷¡¢SCOPE_ONE ¤Ï¹¹¤Ë»Ò¤Î¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤â¸¡º÷¡¢SCOPE_SUB ¤Ï¹¹¤Ë¹°Ê²¼¤Î¥¨¥ó¥È¥ê¤â¸¡º÷ ( ¤Ä¤Þ¤ê¸¡º÷¥Ù¡¼¥¹°Ê²¼Á´¤Æ¤Î¥¨¥ó¥È¥ê¤Î¸¡º÷ )¤·¤Þ¤¹¡£

      ¸¡º÷¥Õ¥£¥ë¥¿¤Ë¤Ï¡¢RFC 2254 ¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë½ñ¼°¤Ç¥Õ¥£¥ë¥¿¤ò»ØÄꤷ¤Þ¤¹¡£¶ñÂÎŪ¤Ë¤Ï°Ê²¼¤Î Íͤʥե£¥ë¥¿¤ò»ØÄê¤Ç¤­¤Þ¤¹(°ìÎã)¡£

      ½ñ¼°ÆâÍÆ
      uid=abc º¸ÊդΰÀ­Ì¾¤ËÂбþ¤¹¤ëÃͤ¬±¦ÊդǤ¢¤ë¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤ò¸¡º÷¤¹¤ë¡£Â°À­ÃͤΰìÉô¤ò * »ØÄꤹ¤ë¤È¡¢¤½¤ÎÉôʬ¤Ï²¿¤Ç¤âÎɤ¤¤¬ÌÀ¼¨Åª¤Ë»ØÄꤷ¤¿Ê¸»úÎó¤ÎÉôʬ¤ò´Þ¤à¥Ç¥£¥ì¥¯¥È¥ê ¥¨¥ó¥È¥ê¤ò¸¡º÷¤¹¤ë¡£Â°À­Ãͤò´°Á´¤Ë * ¤È¤¹¤ë¤È¡¢Ã±¤Ëº¸ÊդΰÀ­¤ò»ý¤Ã¤Æ¤¤¤ë ¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤Î¸¡º÷¤Ë¤Ê¤ë¡£
      objectclass=* °À­Ì¾¤ò objectclass ¤È¤¹¤ë¤È¡¢Á´¤Æ¤Î¥¨¥ó¥È¥ê¤¬¤³¤Î°À­¤ò»ý¤Ä¤¿¤áÁ´¤Æ¤Î¥¨¥ó¥È¥ê¤Î ¸¡º÷¤Ë¤Ê¤ë¡£
      uid~=abc ±¦Êդ˻÷¤Æ¤¤¤ëʸ»úÎó¤òº¸ÊդΰÀ­¤ÎÃͤ˴ޤà¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤ò¸¡º÷¤¹¤ë¡£
      uidNumber>=500 º¸ÊդΰÀ­Ì¾¤Î°À­Ãͤȱ¦ÊÕ¤ÎÈæ³Ó¼°¤¬À®¤êΩ¤Ä¥¨¥ó¥È¥ê¤Î¸¡º÷¤ò¹Ô¤¦¡£>=¡¢<= ¤Ï»È¤¨¤ë¤¬¡¢ >¡¢< ¤Ï»È¤¨¤Ê¤¤(¤é¤·¤¤)¡£Ì¤Ëþ¡¢¤è¤êÂ礭¤¤¤È¤¤¤¦É½¸½¤Ï¡¢¤³¤ì¤ÈÈÝÄê( ! )¤òÁȤ߹ç¤ï¤»¤ë ɬÍפ¬¤¢¤ë(¤è¤¦¤Ç¤¹)¡£
      (!(¸¡º÷¥Õ¥£¥ë¥¿)) ¸¡º÷¥Õ¥£¥ë¥¿¤Ë³ºÅö¤·¤Ê¤¤(¸¡º÷¥Õ¥£¥ë¥¿¤ÎÈÝÄê)¥¨¥ó¥È¥ê¤Î¸¡º÷¤ò°ÕÌ£¤¹¤ë¡£
      (&(¸¡º÷¥Õ¥£¥ë¥¿1)(¸¡º÷¥Õ¥£¥ë¥¿2)) ¸¡º÷¥Õ¥£¥ë¥¿ 1 ¤ª¤è¤Ó¸¡º÷¥Õ¥£¥ë¥¿ 2 ¤ÎξÊý¤Ë³ºÅö¤¹¤ë¥¨¥ó¥È¥ê¤ò¸¡º÷¤¹¤ë¡£¸¡º÷¥Õ¥£¥ë¥¿ ¤Ï 2 ¤Ä¤À¤±¤Ç¤Ê¤¯¤É¤ó¤É¤ó¤Ä¤Ê¤²¤Æ¤¤¤¯¤³¤È¤¬¤Ç¤­¤ë¡£
      (|(¸¡º÷¥Õ¥£¥ë¥¿1)(¸¡º÷¥Õ¥£¥ë¥¿2)) ¸¡º÷¥Õ¥£¥ë¥¿ 1 ¤â¤·¤¯¤Ï¸¡º÷¥Õ¥£¥ë¥¿ 2 ¤Î¤¤¤º¤ì¤«¤Ë³ºÅö¤¹¤ë¥¨¥ó¥È¥ê¤ò¸¡º÷¤¹¤ë¡£& ƱÍÍ ¸¡º÷¥Õ¥£¥ë¥¿¤Ï¤É¤ó¤É¤ó¤Ä¤Ê¤²¤Æ¤¤¤¯¤³¤È¤¬¤Ç¤­¤ë¡£

      ²¿¤é¤«¤ÎÍýͳ¤Ç¸¡º÷¤Ë¼ºÇÔ(¸«ÉÕ¤±¤é¤ì¤Ê¤«¤Ã¤¿¤Î¤Ç¤Ï¤Ê¤¯¡¢°Û¾ïȯÀ¸)¤·¤¿¾ì¹ç¤Ï¡¢LDAPException ¤¬ throw ¤µ¤ì¤Þ¤¹¡£Îã³°¤ÎÆâÍƤˤĤ¤¤Æ¤Ï¸å½Ò¤·¤Þ¤¹¡£

      search() ¥á¥½¥Ã¥É¤Ï¾å¤Î·Á¼°°Ê³°¤Î·Á¤Ç¤¤¤¯¤Ä¤«¥ª¡¼¥Ð¡¼¥í¡¼¥É¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¤½¤ì¤¾¤ì¤Î¾ÜºÙ¤Ë¤Ä ¤¤¤Æ¤Ï JLDAP ¤Î API ¥É¥­¥å¥á¥ó¥È¤ò»²¾È¤·¤Æ²¼¤µ¤¤¡£

    • 65 ¡Á 68 ¹ÔÌÜ

      LDAPConnection#search() ¤Ë¤è¤Ã¤ÆÆÀ¤é¤ì¤¿¸¡º÷·ë²Ì¤Îɽ¼¨½èÍý¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£LDAPSearch.java ¤Ç¤Ï¡¢LDAPSearchResults ¥¯¥é¥¹¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤ò¸¡º÷·ë²Ì¤È¤·¤ÆÊÖ¤¹ LDAPConnection#search() ¥á¥½¥Ã¥É¤ò»ÈÍѤ·¤Æ¤¤¤Þ¤¹¡£¤³¤Î LDAPSearchResults ¤Ï java.util.Enumeration ¥¤¥ó¥¿¥Õ¥§¡¼¥¹ ¤ò¼ÂÁõ¤·¤Æ¤¤¤ë¤Î¤Ç¡¢Ä̾ï¤Î Enumeration ¤ò°·¤¦¤Î¤ÈƱÍͤ˽èÍý¤·¤Æ¤¤¤­¤Þ¤¹¡£

      ¸¡º÷¤Î·ë²ÌÆÀ¤é¤ì¤¿³Æ¥¨¥ó¥È¥ê¤Ï¡¢¤½¤ì¤¾¤ì LDAPEntry ¥¯¥é¥¹¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤È¤·¤Æ LDAPSearchResults ¤Ë³ÊǼ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£³Æ LDAPEntry ¤Î½èÍý¤Ï¡¢¸å½Ò¤¹¤ë showLDAPEntry() ¤Ç¹Ô¤¤¤Þ¤¹¡£

    • 75 ¡Á 78 ¹ÔÌÜ

      ¤³¤³¤Þ¤Ç¤Î½èÍý¤ÇȯÀ¸¤¹¤ë²ÄǽÀ­¤Î¤¢¤ë LDAPException ¤ò catch ¤·¤Æ¤¤¤Þ¤¹¡£º£²ó½Ð¤ÆÍ褿 ¿·¤¿¤Ê½èÍý¤Ë¤è¤Ã¤ÆȯÀ¸¤¹¤ë²ÄǽÀ­¤Î¤¢¤ëÎã³°ÆâÍƤˤĤ¤¤Æ¡¢¼«Ê¬¤¬³Îǧ¤Ç¤­¤¿ÈϰϤǰʲ¼¤Ë ¤Þ¤È¤á¤Æ¤ª¤­¤Þ¤¹¡£¤³¤ì¤ÇÁ´¤Æ¤È¤¤¤¦°ÕÌ£¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£

      ÈÖ¹æ ¥¨¥é¡¼¥³¡¼¥É¤ÎÄê¿ô̾(LDAPException.XXX ¤Î·Á¤Ç»²¾È²Ä) ÆâÍÆ
      2 PROTOCOL_ERROR LDAP ¥µ¡¼¥Ð¤¬¥¯¥é¥¤¥¢¥ó¥È¤«¤éÉÔÀµ¤ÊÍ×µá¤ò¼õ¤±¼è¤Ã¤¿¡£LDAPSearch.java ¤Î¾ì¹ç¡¢ ¸¡º÷¥¹¥³¡¼¥×¤ËÉÔÀµ¤ÊÃͤò»ØÄꤹ¤ë¤ÈȯÀ¸¤¹¤ë¡£
      32 NO_SUCH_OBJECT LDAPConnection#search() ¤Ë¡¢ÉÔÀµ¤Ê(¹½Ê¸¤ÏÀµ¤·¤¤)¸¡º÷¥Ù¡¼¥¹¤ò»ØÄꤷ¤¿¾ì¹ç¤ËȯÀ¸¤¹¤ë¡£
      34 INVALID_DN_SYNTAX »ØÄꤷ¤¿ DN ¤Î¹½Ê¸¤¬Àµ¤·¤¯¤Ê¤¤¡£
      87 FILTER_ERROR LDAPConnection#search() ¤Ë»ØÄꤷ¤¿¸¡º÷¥Õ¥£¥ë¥¿¤¬ÉÔÀµ¤Ç¤¢¤ë¾ì¹ç¤ËȯÀ¸¤¹¤ë¡£

    • 82 ¡Á 97 ¹ÔÌÜ( LDAPSearch#showLDAPEntry() )

      LDAPEntry ¤ÎÆâÍƤòɽ¼¨¤·¤Þ¤¹¡£

      ³Æ¥¨¥ó¥È¥ê¤¬ÊÝ»ý¤·¤Æ¤¤¤ë°À­¾ðÊó¤Ë¤Ä¤¤¤Æ¤Ï¡¢Á°²ó¤Î¥¨¥ó¥È¥ê¤ÎÅÐÏ¿/ºï½ü ¤Î½ê¤ÇÀâÌÀ¤·¤¿¤è¤¦¤Ë¡¢1 ¤Ä¤Î°À­Ì¾¤È°À­ÃͤÎÁȤ¬ LDAPAttribute ¥¯¥é¥¹¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤ËÀßÄê ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¤½¤·¤Æ LDAPAttributeSet ¥¯¥é¥¹¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤ËÊ£¿ô¤Î LDAPAttribute ¥¯¥é¥¹¤Î ¥¤¥ó¥¹¥¿¥ó¥¹¤¬³ÊǼ¤µ¤ì¤ë¤³¤È¤ÇÊ£¿ô°À­¤Î¾ðÊó¤¬ÊÝ»ý¤µ¤ì¤Æ¤¤¤Þ¤¹¡£

      ½èÍý½ç½ø¤ò´Êñ¤Ë½ñ¤¯¤È°Ê²¼¤ÎÄ̤ê¤Ë¤Ê¤Ã¤Æ¤Þ¤¹(µ­½Ò¤â´Êά²½)

      1. LDAPEntry ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë DN ¤òɽ¼¨¤¹¤ë
      2. LDAPEntry ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë LDAPAttributeSet ¤«¤é¡¢ÀßÄꤵ¤ì¤Æ¤¤¤ëÊ£¿ô¤Î LDAPAttribute ¤ò Enumeration ¤È¤·¤Æ¼è¤ê¤À¤¹
      3. ¢¬¤Ç¼è¤ê¤À¤·¤¿ Enumeration ¤«¤é½ç¼¡ LDAPAttribute ¤ò¼è¤ê¤À¤¹
      4. LDAPAttribute ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë°À­¤Î°À­Ì¾¤ÈÃͤòɽ¼¨¤¹¤ë

      2 ¤Ë¤ª¤¤¤Æ¡¢LDAPAttributeSet#getAttributes() ¤ò»È¤Ã¤ÆÊ£¿ô°À­¤ò Enumeration ¤È¤·¤Æ½èÍý¤·¤Æ ¤¤¤Þ¤¹¤¬¡¢LDAPAttributeSet#size() ¤È LDAPAttributeSet#elementAt() ¤ò»È¤Ã¤Æ½èÍý¤¹¤ë¤³¤È¤â ²Äǽ¤Ç¤¹¡£¤ª¹¥¤­¤ÊÊýË¡¤Ç¤É¤¦¤¾¡£

      4 ¤Ç¤Ï¡¢LDAPAttribute#getStringValues() ¤ò»È¤Ã¤Æ³Æ°À­¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë°À­Ãͤò Enumeration ¤È¤·¤Æ¼è¤ê¤À¤·¤Æ¤¤¤Þ¤¹¡£LDAP ¤Ç¤Ï³Æ°À­¤ËÊ£¿ô¤Î°À­Ãͤ¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢ ¤³¤ÎÍÍ¤Ë Enumeration ¤È¤·¤Æ°·¤¦¤«¡¢ LDAPAttribute#getStringValueArray() ¤ò»È¤Ã¤ÆÇÛÎó¤È¤·¤Æ ½èÍý¤¹¤ë¤«¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£

      ¤³¤³¤Ç»ÈÍѤ·¤Æ¤¤¤ë LDAPEntry¡¢LDAPAttributeSet¡¢LDAPAttribute ¥¯¥é¥¹¤Î ÍÍ¡¹¤Ê¥á¥½¥Ã¥É¤Î¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢JLDAP ¤Î API ¥É¥­¥å¥á¥ó¥È¤ò»²¾È¤·¤Æ²¼¤µ¤¤¡£

°Ê¾å¤Ç LDAPSearch.java ¤Ë¤Ä¤¤¤Æ¤ÎÀâÌÀ¤Ï½ª¤ï¤ê¤Ç¤¹¡£

¡û 1000 ·ï°Ê¾å¤Î¸¡º÷·ë²Ì¤Î¼èÆÀ

¼Â¤Ï¡¢¤³¤Î¤Þ¤Þ¤À¤È LDAP ¥µ¡¼¥Ð¦¤Ë³ºÅö¥¨¥ó¥È¥ê¤¬²¿·ï¤¢¤í¤¦¤È¤â¡¢1000 ·ï°Ê¾å¤Î¸¡º÷·ë²Ì¤òÆÀ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¡£¤³¤ì¤Ï¡¢ÉÔÍפʸ¡º÷½èÍý¤ò¹Ô¤ï¤Ê¤¤¤Ê¤É¤Î»Þ´¢¤ê¾ò·ï¤Î¤è¤¦¤Ê¤â¤Î¤À¤È»×¤¤¤Þ¤¹¤¬¡¢¤â¤·¤½¤ì°Ê¾å¤Î¿ô¤Î¸¡º÷·ë²Ì¤ò¼èÆÀ¤·¤¿¤¤¾ì¹ç¤Ï¡¢LDAPSearchConstraints ¥¯¥é¥¹¤ò»È¤Ã¤ÆºÇÂç¼èÆÀ·ë²Ì¿ô¤òÀßÄꤹ¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£

¶ñÂÎŪ¤Ë¤Ï¡¢¤Þ¤º LDAPSearchConstraints ¥¯¥é¥¹¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤òºîÀ®¤·¤Æ LDAPSearchConstraints#setMaxResults() ¤ÇºÇÂç¼èÆÀ¿ô¤òÀßÄꤷ¤Þ¤¹¡£¤Á¤Ê¤ß¤Ë setMaxResults() ¤Ë 0 ¤òÀßÄꤹ¤ë¤È¡¢¾å¸Â̵¤·¤Ë¤Ê¤ê¤Þ¤¹¡£

LDAPSearchConstraints cs = new LDAPSearchConstraints();
cs.setMaxResults( 0 ); // ¸¡º÷·ï¿ôÀ©¸Â²ò½ü

¤½¤·¤Æ¡¢¸¡º÷¤ò¼Â¹Ô¤¹¤ëÁ°¤Ë¤³¤Î LDAPSearchConstraints ¥¯¥é¥¹¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤ò LDAPConnection#setConstraints() ¤ò»È¤Ã¤Æ LDAPConnection ¥¯¥é¥¹¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤ËÀßÄꤹ¤ë¤«¡¢LDAPSearchConstraints ¥¯¥é¥¹¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤ò°ú¿ô¤Ë¼è¤ë LDAPConnection#search() ¤ò»È¤Ã¤Æ¸¡º÷¤ò¼Â¹Ô¤¹¤ë¤«¤Î¤¤¤º¤ì¤«¤Ç¡¢1000 ·ï°Ê¾å¤Î¸¡º÷·ë²Ì¤ò¼èÆÀ¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£

public LDAPSearchResults LDAPConnection#search( 
                                 String                base,
                                 int                   scope,
                                 String                filter,
                                 String[]              attrs,
                                 boolean               typesOnly,
                                 LDAPSearchConstraints cons )
   throws LDAPException

# LDAPSearchConstraints ¤ò°ú¿ô¤È¤¹¤ë search() ¥á¥½¥Ã¥É¤Ï¡¢¢¬¤Î¾¤Ë
# ¤â¤¢¤ë¤Î¤Ç¡¢JLDAP ¤Î API ¥É¥­¥å¥á¥ó¥È¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£

public void LDAPConnection#setConstraints( LDAPConstraints cons )

# LDAPSearchConstraints ¤Ï LDAPConstraints ¤Î¥µ¥Ö¥¯¥é¥¹¤Ê¤Î¤Ç¡¢ÌäÂê̵¤·