You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Sandra kurt <sa...@hotmail.com> on 2003/03/17 18:15:37 UTC

select all users with no roles in groups


I wonder how I can realise the query of selecting all users, who have
no roles in any groups?!

help appreciated ;-)




_________________________________________________________________
MSN Hotmail  -  Absolut kostenfrei! Der weltweit größte E-Mail-Anbieter im 
Netz:  http://www.msn.de/hotmail


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: select all users with no roles in groups

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
Eric Emminger <er...@ericemminger.com> writes:

>Hi Sandra

>> I wonder how I can realise the query of selecting all users, who have
>> no roles in any groups?!

>Would the following SQL handle this?

>Select * From TURBINE_USER where USER_ID not in (select distinct USER_ID 
>from TURBINE_USER_GROUP_ROLE)

>Do the distinct query first and then pass the results as the NOT IN 
>argument.

This doesn't help you if you want to use the Security Service.

Ugh, that gets really ugly, because once you have the ACL you can't
find out which groups are used for the acl so you have to loop over
all groups to find roles in it.

How about:

List usersWithoutRoles = new ArrayList();
GroupSet allGroups = TurbineSecurity.getAllGroups();

Criteria c = new Criteria();
User[] users = TurbineSecurity.getUsers(c);

for (int i = 0; i < users.length; i++)
{
  AccessControlList acl = TurbineSecurity.getACL(users[i]);
  boolean gotRoles = false;
  for (Iterator it = allGroups.elements(); it.hasNext(); )
  {
    Group g = (Group) it.next();
    if(acl.getRoles(g).size() > 0)
    {
      gotRoles = true;
      break; // for(Iterator...
    }
  }
  if (gotRoles)
  {
    continue; // for(int i...
  }

  usersWithoutRoles.add(users[i]);
}

---> usersWithoutRoles should contain all users without roles.

	Regards
		Henning
-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

Java, perl, Solaris, Linux, xSP Consulting, Web Services 
freelance consultant -- Jakarta Turbine Development  -- hero for hire

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: select all users with no roles in groups

Posted by Eric Emminger <er...@ericemminger.com>.
Hi Sandra

> I wonder how I can realise the query of selecting all users, who have
> no roles in any groups?!

Would the following SQL handle this?

Select * From TURBINE_USER where USER_ID not in (select distinct USER_ID 
from TURBINE_USER_GROUP_ROLE)

Do the distinct query first and then pass the results as the NOT IN 
argument.

Eric


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org