2016-10-18 19 views
0

VLVコントロールを動作させるのに問題があります。私はApacheDS 2.0.0を使用しており、Sunのldapbp-1.0.jarを使用してJava JNDIを使用して話しています。照会されると、サーバーはVLVコントロールをサポートしていると言います。エラーは出ませんが、検索を設定して、サブセットの代わりにすべての結果を戻します。私は新しいApacheDSインスタンスを設定し、そこに10人のユーザーがいます。私は常に結果に10点すべてを取得します。LDAP VirtualListViewを動作させることができません

また、私はSortResponseControlを返して、決してVirtualListViewResponseControlを取得しません。

私は多くの例を見てきましたが、私は本質的に彼らのことをやっています。このコード例では、そのままの状態で接続情報と検索条件を変更しましたが、同じ問題が発生します。私が何か間違ったことしなければならない

new VirtualListViewControl(1, 0, 0, 19, Control.CRITICAL); // original - gets all 
    new VirtualListViewControl(1, 10, 1, 2, Control.CRITICAL); // target offset -gets all 
    new VirtualListViewControl(20, 3, Control.CRITICAL); // target percentage - gets all 
    new VirtualListViewControl("Tryit4", 3, Control.CRITICAL); // target value, view size - gets all 
    new VirtualListViewControl("Tryit4", 2, 1, Control.CRITICAL); // target value, before count, after count 

が、私はそれが何であるかを見ることができない。 Post from LDAP Pro forum

私はVirtualListViewControlのために試したパラメータのいくつかはあります。どんな助けもありがとう。 ありがとうございました

申し訳ありませんリンクは機能しません。それは私のためにやった。以下は、私が使用しているコード例で、常にSortResponseControlとすべてのLDAPエントリを返します。

/** 
* 
* VLVJndiClient.java 
* Sample code to demostrate how Virtual List View (VLV) Control works. 
* Note: 
*  1) Note: JNDI Boost package is required for this example to run. 
*  2) VLV Control MUST be used in conjunction with Sort Control. 
*  Otherwise, you will be braced by: [LDAP: error code 60 - VLV Control] 
* 3) SunOne Directory Server supports VLV & Microsoft supports VLV since AD2003 
* 
*/ 

import java.util.Hashtable; 
import java.io.*; 

import javax.naming.*; 
import javax.naming.directory.*; 
import javax.naming.ldap.*; 

import com.sun.jndi.ldap.ctl.VirtualListViewControl; 
import com.sun.jndi.ldap.ctl.VirtualListViewResponseControl; 
import com.sun.jndi.ldap.ctl.SortControl; 

public class VLVJndiClientShort 
{ 

    static final String VLV_CONTROL_OID = "2.16.840.1.113730.3.4.9"; 

    public static void main(String[] args) throws IOException 
    { 
     Hashtable env = new Hashtable(); 

     env.put(Context.INITIAL_CONTEXT_FACTORY, 
        "com.sun.jndi.ldap.LdapCtxFactory"); 

     env.put(Context.PROVIDER_URL, "ldap://172.16.2.23:10389"); 
     env.put(Context.SECURITY_AUTHENTICATION, "simple"); 
     env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system"); 
     env.put(Context.SECURITY_CREDENTIALS, "test"); 

     try { 
      /* Create initial context with no connection request controls */ 
      LdapContext ctx = new InitialLdapContext(env, null); 

      /* Query the server to see if the VLV Control is supported */ 
      if (!isVLVControlSupported(ctx)){ 
       System.out.println(
      "The server does not support Virtual List View (VLV) Control."); 
       System.exit(1); 
      } 

      /* Sort Control is required for VLV to work */ 
      SortControl sctl = new SortControl(
       new String[]{"cn"}, // sort by cn 
       Control.CRITICAL 
      ); 

      /* VLV that returns the first 20 answers 0 to 19 changed 19 to 2 */ 
      VirtualListViewControl vctl = 
//    new VirtualListViewControl(1, 0, 0, 19, Control.CRITICAL); // original - gets all 
//    new VirtualListViewControl(1, 10, 1, 2, Control.CRITICAL); // target offset, list size, before count, after count, criticality - gets all 
//     new VirtualListViewControl(20, 3, Control.CRITICAL); // target percentage, view size, criticality - gets all 
//     new VirtualListViewControl("Tryit4", 3, Control.CRITICAL); // target value, view size, criticality - gets all 
        new VirtualListViewControl("Tryit4", 2, 1, Control.CRITICAL); // target value, before count, after count, criticality 

      /* Set context's request controls */ 
      ctx.setRequestControls(new Control[]{sctl, vctl}); // returns only a sorted control but no VLV control 

      /* Perform search */ 
      NamingEnumeration answer = 
        ctx.search("dc=mir3,dc=example,dc=com", "(objectclass=*)", null); 

      /* Enumerate search results */ 
      while (answer.hasMore()) { 
       SearchResult si = (SearchResult)answer.next(); 
       System.out.println(si.getName()); 
      } 

      /* examine the response controls (if any) */ 
      printControls(ctx.getResponseControls()); 

      ctx.close(); 

     } catch (NamingException e) { 
      e.printStackTrace(); 
     } 
    } 

    static void printControls(Control[] controls) 
    { 
     if(controls == null){ 
      System.out.println("No response controls"); 
      return; 
     } 

     for(int j = 0; j < controls.length; j++) { 
      if(controls[j] instanceof SortResponseControl){ 
       SortResponseControl src = (SortResponseControl)controls[j]; 
       if (src.isSorted()) { 
        System.out.println("Sorted-Search completed successfully"); 
       } else { 
        System.out.println(
         "Sorted-Search did not complete successfully: error (" + 
         src.getResultCode() + ") on attribute '" + 
         src.getAttributeID() + "'"); 
       } 
      }else if(controls[j] instanceof VirtualListViewResponseControl){ 
       VirtualListViewResponseControl vlv = 
         (VirtualListViewResponseControl)controls[j]; 
       if (vlv.getResultCode() == 0) { 
        System.out.println("Sorted-View completed successfully"); 
        System.out.println("TargetOffset: " + vlv.getTargetOffset()); 
        System.out.println("ListSize: " + vlv.getListSize()); 
       } else { 
        System.out.println("Sorted-View did not complete successfully: " 
           + vlv.getResultCode()); 
       } 
      } else { 
       System.out.println("Received control: "+ controls[j].getID()); 
      } 
     } 
    } 

    /** 
    * Is VLV Control supported? 
    * 
    * Query the rootDSE object to find out if VLV Control 
    * is supported. 
    */ 
    static boolean isVLVControlSupported(LdapContext ctx) 
    throws NamingException 
    { 
     SearchControls ctl = new SearchControls(); 
     ctl.setReturningAttributes(new String[]{"supportedControl"}); 
     ctl.setSearchScope(SearchControls.OBJECT_SCOPE); 

     /* search for the rootDSE object */ 
     NamingEnumeration results = ctx.search("", "(objectClass=*)", ctl); 

     while(results.hasMore()){ 
      SearchResult entry = (SearchResult)results.next(); 
      NamingEnumeration attrs = entry.getAttributes().getAll(); 
      while (attrs.hasMore()){ 
       Attribute attr = (Attribute)attrs.next(); 
       NamingEnumeration vals = attr.getAll(); 
       while (vals.hasMore()){ 
        String value = (String) vals.next(); 
        if (value.equals(VLV_CONTROL_OID)) 
         return true; 
       } 
      } 
     } 
     return false; 
    } 

} 
+0

リンクが機能せず、いずれの場合もコードをここに掲載する必要があります。 – EJP

+0

申し訳ありません。ちょうどコードを追加しました。 – eightmd

答えて

-1

誰もこの入力をしていないようですが、私が見つけたものは教えてください。上記のように、私はVLVをOpenLDAPとapacheDSで動かそうとしました。クエリが実行されると、サーバーはコントロールをサポートしていると言いますが、使用すると、要求されたサブセットではなく、すべてのエントリが返されます。

私の顧客がSunOne LDAPサーバーを使用していたので、私はそれを試してみました。 SunOneは、2000年代初頭にはわずか2年間しか使用されませんでしたが、2011年までOracle Directory Serviceとしてサポートされました。サイトのOracle site for downloadからダウンロードできます。 Oracle Directory Server Enterprise Edition(11.1.1.7.0)を探します。 Oracle Developerのログインが必要だと思います。インストール手順はこちらInstallation Documentationです。

Oracle Directory Serviceは、限定検索で見つかった唯一のLDAPサーバーで、文書化されている通りにVLVコントロールを正しくサポートしています。

サーバはVLVをサポートしていると言いますが、ページングされた検索もサポートすると、VLVは正しく実装されません。

これは私が見つけたことですが、私が間違っていると、他のLDAPサーバーがページングのためにVLVをどのようにサポートしているか聞いてみたいと思います。このポストを見た人のためにありがとう!

+0

VLVはOpenLDAPで正しく動作します。私はあなたが「ページングされた検索」をサポートしているときに、あなたが何を意味するのか分かりません。 'sssvlv'オーバーレイは、OpenLDAPでページされた結果のオーバーレイを置き換えます。 – EJP

+0

質問したときに使用しているOpenLDAPのバージョンではVLVをサポートしていると言われていますが、VLVコントロールに与えると、私が求めたエントリだけでなく、すべてのエントリが返されます。私はsssvlvオーバーレイについて知らない。私はそのようなものはインストールしなかったが、OpenLDAPはそれがページングされた結果をサポートし、正しく動作すると言った。 – eightmd

関連する問題