1

我们正在尝试在 Jboss 5.1 上运行 LDAP java 程序,但身份验证失败。同样的应用程序可以在 Jboss 4.3 下运行,并通过 JVM 从命令行运行。

基本上,代码中填充了一个 cookie。而且它仅适用于 Jboss 5.1。

他们正在使用 JDK 1.6.0_27。

下面是用于 LDAP 的代码片段。

为什么 PagedResultsResponseControl getCookie 仅适用于 JBoss 5.x?那个部门有什么变化吗?

        do { 
            NamingEnumeration results = ctx.search("ou=people,ou=appname,dc=dept,dc=test,dc=com", 
                    "(&(objectclass=user)(CN=*))", new SearchControls()); 
            Control[] controls = ctx.getResponseControls(); 
            if (controls != null) 
            { 
                System.out.println("if (controls != null) controls.length=" + controls.length); 
                for (int i = 0; i < controls.length; i++) 
                { 
                    if (controls[i] instanceof PagedResultsResponseControl) 
                    { 
                        PagedResultsResponseControl prrc = (PagedResultsResponseControl)controls[i]; 
                        cookie = prrc.getCookie(); /// The cookie is returned as null when run on jboss 5.1. It returns a cookie containg details of next page to be retrieved. 
                                                   // This part of the code works perfectly fine with jboss 4.3 and command line. 
                    } 
                } 
            } 
            else 
            { 
                System.out.println("No controls were sent from the server"); 
            } 
            // Re-activate paged results 
            ctx.setRequestControls(new Control[]{ 
                    new PagedResultsControl(pageSize, cookie, Control.CRITICAL) }); 

            if(cookie==null) 
            { 
                System.out.println("cookie is null"); 
            } 
            else 
            { 
                System.out.println("cookie.length= " + cookie.length + "cookie= " + cookie.toString()); 
            } 

        } while (cookie != null); 
4

0 回答 0