Package javax.naming.directory

Examples of javax.naming.directory.SearchResult


        {
            try
            {
                while ( answer.hasMore() )
                {
                    SearchResult searchResult = ( SearchResult ) answer.next();

                    // Getting the 'cn' Attribute
                    Attribute cnAttribute = searchResult.getAttributes().get( "cn" );

                    // Looping on the values
                    NamingEnumeration<?> ne = null;
                    ne = cnAttribute.getAll();
                    if ( ne != null )
View Full Code Here


        {
            try
            {
                if ( answer.hasMore() )
                {
                    SearchResult searchResult = ( SearchResult ) answer.next();

                    Attribute vendorNameAttribute = searchResult.getAttributes().get( "vendorName" );
                    if ( vendorNameAttribute == null )
                    {
                        return false;
                    }
View Full Code Here

        {
            try
            {
                while ( answer.hasMore() )
                {
                    SearchResult searchResult = ( SearchResult ) answer.next();
                    switch ( getNodeType( searchResult ) )
                    {
                        case ATTRIBUTE_TYPE:
                            AttributeTypeImpl at = createAttributeType( searchResult );
                            at.setSchema( name );
View Full Code Here

            if (results == null || !results.hasMore()) {
                return false;
            }

            SearchResult result = (SearchResult) results.next();

            if (results.hasMore()) {
                //ignore for now
            }
            NameParser parser = context.getNameParser("");
            Name contextName = parser.parse(context.getNameInNamespace());
            Name baseName = parser.parse(userBase);
            Name entryName = parser.parse(result.getName());
            Name name = contextName.addAll(baseName);
            name = name.addAll(entryName);
            String dn = name.toString();

            Attributes attrs = result.getAttributes();
            if (attrs == null) {
                return false;
            }
            ArrayList roles = null;
            if (userRoleName != null) {
View Full Code Here

            constraints.setSearchScope(SearchControls.ONELEVEL_SCOPE);
        }
        NamingEnumeration results =
                context.search(roleBase, filter, constraints);
        while (results.hasMore()) {
            SearchResult result = (SearchResult) results.next();
            Attributes attrs = result.getAttributes();
            if (attrs == null) {
                continue;
            }
            list = addAttributeValues(roleName, attrs, list);
        }
View Full Code Here

          if (results.hasMoreElements()) {
            logger.info("has returned results..\n");
              user = new JSONObject();
              // Since UID is unique across the entire directory,
              // the search results should contain only one entry.
              SearchResult sr = (SearchResult) results.next();
              // we need the DN to authenticate the user
              NameParser parser = ctx.getNameParser(BASE);
          Name userDN = parser.parse(BASE);

          if (userDN == (Name) null)
          // This should not happen in theory
          throw new NameNotFoundException();
          else
          userDN.addAll(parser.parse(sr.getName()));
          user.put("userDN", userDN.toString());
                   
              // Get all available attribute types and their associated values.
          // we can build a user object to return.
              Attributes attributes = sr.getAttributes();

              Attribute attr;
              NamingEnumeration<?> ne;

              // Iterate through the attributes.
View Full Code Here

         if (sr.size() > 1)
         {
            throw new IdentityException("Found more than one user with id: " + userName + "" +
               "Posible data inconsistency");
         }
         SearchResult res = (SearchResult)sr.iterator().next();
         ctx = (Context)res.getObject();
         String dn = ctx.getNameInNamespace();
         User user = createUserInstance(res.getAttributes(), dn);
         ctx.close();
         return user;

      }
      catch (NoSuchElementException e)
View Full Code Here

   protected Set processUsers(Collection users) throws Exception
   {
      Set ui = new HashSet();
      for (Iterator iterator = users.iterator(); iterator.hasNext();)
      {
         SearchResult res = (SearchResult)iterator.next();
         Context ctx = (Context)res.getObject();
         String dn = ctx.getNameInNamespace();
         ui.add(createUserInstance(res.getAttributes(), dn));
      }
      return ui;
   }
View Full Code Here

      public int compare(Object o1, Object o2)
      {
         try
         {
            SearchResult u1 = (SearchResult)o1;
            SearchResult u2 = (SearchResult)o2;

            Attribute uida1 = u1.getAttributes().get(getUidAttributeID());
            Attribute uida2 = u2.getAttributes().get(getUidAttributeID());

            String name1 = uida1.get().toString();
            String name2 = uida2.get().toString();

            return name1.compareToIgnoreCase(name2);
View Full Code Here

            constraints.setReturningAttributes(attrs);
            NamingEnumeration results = ctx.search(params.getBaseDN(), filter3,
                constraints);
            while (results.hasMoreElements())
            {
                SearchResult sr = (SearchResult)results.next();
                NamingEnumeration enumeration = ((Attribute)(sr
                    .getAttributes().getAll().next())).getAll();
                while (enumeration.hasMore())
                {
                    list.add(enumeration.next());
                }
View Full Code Here

TOP

Related Classes of javax.naming.directory.SearchResult

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.