Package javax.naming.ldap

Examples of javax.naming.ldap.SortControl


  private void setStandardRequestControls() throws TranslatorException {
    Control[] sortCtrl = new Control[1];
    SortKey[] keys = searchDetails.getSortKeys();
    if (keys != null) {
      try {
        sortCtrl[0] = new SortControl(keys, Control.NONCRITICAL);
        this.ldapCtx.setRequestControls(sortCtrl);
        LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Sort ordering was requested, and sort control was created successfully."); //$NON-NLS-1$
      } catch (NamingException ne) {
              final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.setControlsError") //$NON-NLS-1$
              " : "+ne.getExplanation(); //$NON-NLS-1$
View Full Code Here


      String orderBy = query.getOrderBy();
      if(orderBy != null) {
        orderBy = orderBy.substring(0, orderBy.length()-4);
        if(UserQueryProperty.USER_ID.getName().equals(orderBy)) {
          controls.add(new SortControl(ldapConfiguration.getUserIdAttribute(), Control.CRITICAL));

        } else if(UserQueryProperty.EMAIL.getName().equals(orderBy)) {
          controls.add(new SortControl(ldapConfiguration.getUserEmailAttribute(), Control.CRITICAL));

        } else if(UserQueryProperty.FIRST_NAME.getName().equals(orderBy)) {
          controls.add(new SortControl(ldapConfiguration.getUserFirstnameAttribute(), Control.CRITICAL));

        } else if(UserQueryProperty.LAST_NAME.getName().equals(orderBy)) {
          controls.add(new SortControl(ldapConfiguration.getUserLastnameAttribute(), Control.CRITICAL));
        }
      }

      initialContext.setRequestControls(controls.toArray(new Control[0]));
View Full Code Here

         return users;
      NamingEnumeration<SearchResult> results = null;

      try
      {
         SortControl sctl = new SortControl(new String[]{ldapAttrMapping.userUsernameAttr}, Control.NONCRITICAL);
         ctx.setRequestControls(new Control[]{sctl});

         // returns only needed attributes for creation UserImpl in
         // LDAPAttributeMapping.attributesToUser() method
         String[] returnedAtts;
View Full Code Here

        LdapContext ctx = null;
        try {
            ctx = manager.getContext();
            // Sort on group name field.
            Control[] searchControl = new Control[]{
                new SortControl(new String[]{manager.getGroupNameField()}, Control.NONCRITICAL)
            };
            ctx.setRequestControls(searchControl);

            SearchControls searchControls = new SearchControls();
            // See if recursive searching is enabled. Otherwise, only search one level.
View Full Code Here

            // Sort on username field.
            Control[] searchControl;
            try {
                searchControl = new Control[]{
                        new SortControl(new String[]{manager.getUsernameField()}, Control.NONCRITICAL)
                };
            } catch (IOException e) {
                Log.error(e.getMessage(), e);
                return Collections.emptyList();
            }
View Full Code Here

        assertNotNull(controls);
        Control c = controls[0];
        assertTrue(c instanceof PagedResultsControl);
        assertEquals(Control.NONCRITICAL, ((PagedResultsControl) c).isCritical());

        context.reconnect(new Control[] { new SortControl("",
                Control.NONCRITICAL) });
       
        controls = context.getConnectControls();
        assertNotNull(controls);
        assertEquals(1, controls.length);
View Full Code Here

        Control[] reqCtls = initialContext.getRequestControls();
        assertEquals(1, reqCtls.length);
        assertEquals("2.16.840.1.113730.3.4.2", reqCtls[0].getID());
        assertEquals(Control.NONCRITICAL, reqCtls[0].isCritical());

        initialContext.setRequestControls(new Control[] { new SortControl("",
                Control.NONCRITICAL) });

        reqCtls = initialContext.getRequestControls();
        assertEquals(2, reqCtls.length);
        Control control = reqCtls[0];
        if (control instanceof SortControl) {
            assertEquals(Control.NONCRITICAL, reqCtls[0].isCritical());
            assertEquals("2.16.840.1.113730.3.4.2", reqCtls[1].getID());
            assertEquals(Control.NONCRITICAL, reqCtls[1].isCritical());
        } else {
            assertEquals("2.16.840.1.113730.3.4.2", control.getID());
            assertEquals(Control.NONCRITICAL, control.isCritical());
            assertTrue(reqCtls[1] instanceof SortControl);
            assertEquals(Control.NONCRITICAL, reqCtls[1].isCritical());
        }

        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
                LdapASN1Constant.OP_SEARCH_RESULT_DONE,
                new EncodableLdapResult(), null) });

        LdapContext context = (LdapContext) initialContext.lookup("");
        // request controls are not inherited
        reqCtls = context.getRequestControls();
        assertEquals(1, reqCtls.length);
        assertEquals("2.16.840.1.113730.3.4.2", reqCtls[0].getID());
        assertEquals(Control.NONCRITICAL, reqCtls[0].isCritical());

        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
                LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
        context = context.newInstance(new Control[] { new SortControl("",
                Control.NONCRITICAL) });
        reqCtls = context.getRequestControls();

        assertEquals(2, reqCtls.length);
        control = reqCtls[0];
View Full Code Here

        assertNull(context.getConnectControls());

        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
                LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
        context.reconnect(new Control[] { new SortControl("",
                Control.NONCRITICAL) });

        Control[] controls = context.getConnectControls();
        assertNotNull(controls);
        assertEquals(1, controls.length);
View Full Code Here

    }

    public void testConnectControls2() throws Exception {
        // set connect controls by property "java.naming.ldap.control.connect"
        env.put("java.naming.ldap.control.connect",
                new Control[] { new SortControl("", Control.NONCRITICAL) });

        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
                LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });

        InitialDirContext initialDirContext = new InitialDirContext(env);
View Full Code Here

    public void testConnectControls3() throws Exception {
        // set connect controls by InitialLdapContext
        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
                LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
        InitialLdapContext initialDirContext = new InitialLdapContext(env,
                new Control[] { new SortControl("", Control.NONCRITICAL) });

        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
                LdapASN1Constant.OP_SEARCH_RESULT_DONE,
                new EncodableLdapResult(), null) });
        LdapContext context = (LdapContext) initialDirContext.lookup("");
View Full Code Here

TOP

Related Classes of javax.naming.ldap.SortControl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.