Hi,
I'm trying to get a list of all users in my JIRA instance (local and LDAP users), but when I use the following query :
SELECT cu.user_name AS username, cu.display_name AS displayname, cm.lower_parent_name AS group, cu.email_address AS email
FROM cwd_user AS cu
INNER JOIN cwd_membership AS cm
ON cu.directory_id=cm.directory_id
AND cu.lower_user_name=cm.lower_child_name
AND cm.membership_type='GROUP_USER'
WHERE cm.lower_parent_name LIKE 'zz%'
ORDER BY cu.user_name;I have duplicate users because one exists as a local JIRA user (first one) and the second one is my LDAP user (which JIRA merged)
username | displayname | group | email |
-------------------------------------------------------------------------------------------
firstname.lastname | Firstname Lastname | zz group | f.l@a.com |
Firstname.Lastname | Firstname Lastname | zz group | F.L@a.com |
(I do hope my formatting stays alive after posting this).
I just want one of these users (preferably the first one), so I tried the following SQL query:
SELECT t.user_name, cu.display_name, cm.lower_parent_name, cu.email_address
FROM (
SELECT cu.user_name
FROM cwd_user AS cu
INNER JOIN cwd_membership AS cm ON cu.directory_id=cm.directory_id
AND cu.lower_user_name=cm.lower_child_name
AND cm.membership_type='GROUP_USER'
WHERE cm.lower_parent_name LIKE 'zz%'
GROUP BY LOWER(cu.user_name)
) u JOIN cwd_user t ON t.user_name = u.user_name ORDER BY t.user_name;
but with no luck. My SQL isn't that great, so i'm stuck here.
Any thoughts?