1 Reply Latest reply on Jan 30, 2009 1:04 PM by Boleslaw Dawidowicz

    List of Users

    Anil Saldanha Master

      Tom asks:

      the actual question was: I'm trying to obtain a list of all users.
      
      I guess this method should do the trick:
      
       Collection<Identity> identities = identitySession
       .getPersistenceManager()
       .findIdentity((IdentitySearchControl[])null);
      
      I assume this gets me the users *and* groups, right ?
      
      I only found following search controls:
      
       if (control instanceof PageSearchControl)
       {
       pageSearchControl = (PageSearchControl)control;
       }
       else if (control instanceof SortByNameSearchControl)
       {
       sortSearchControl = (SortByNameSearchControl)control;
       }
       else if (control instanceof AttributeFilterSearchControl)
       {
       attributeFilterControl = (AttributeFilterSearchControl)control;
       }
       else if (control instanceof NameFilterSearchControl)
       {
       nameFilterSearchControl = (NameFilterSearchControl)control;
       }
      
      Should I be looking into the attributes to filter for the users ?
      


        • 1. Re: List of Users
          Boleslaw Dawidowicz Master

          I think the main confusion is a bit about naming:
          IdentityType - parent interface for Identity and Group
          Identity aka user
          Group aka group...

          This is covered in the "API" part of the design doc: http://www.jboss.org/community/docs/DOC-13261

          The decision to use the name "Identity" and not simply "User" was mainly because "Identity" in some authentication/authorization scenarios can be also machines... Now I'm a bit afraid that it will confuse people.

          So for the methods:

          identitySession.getPersistenceManager()
           .findIdentity(null);
          

          will return all Identity objects (so all users if you prefer such naming)

          identitySession.getPersistenceManager().
           findGroup(groupType, null)


          all Group objects for a given group type.

          Then controls only let to narrow or order/sort results.

          With RelationshipManager you can get all Group objects associated with a given Identity regardless of the GroupType.

          To follow some "real life" scenario with the API look at this API test case:
          http://anonsvn.jboss.org/repos/jbossidentity/idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java

          One of the tests map small part of the structure of jboss.org projects so should let to understand API concepts better.