Eric Emminger <[EMAIL PROTECTED]> 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
[EMAIL PROTECTED] +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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]