How to handle duplicate users?

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 27, 2012

I have various directores associated with JIRA and some user names are duplicated.

UserUtil.getUserObject(String) returns a single user object and there are no overridden methods to send more details like email etc which are distinguishable.

How to handle correct user in this case?

6 answers

1 accepted

1 vote
Answer accepted
Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 29, 2012

If the email addresses are unique, then why don't you configure the LDAP directory so that the username attribute is pulled from the email address? People can then just login using their email address as the username.

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 29, 2012

email addresses are unique because they are from different domains

3 votes
Naren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2012

Hi Spatruni,

As email is one of your distinguishable detail. You can retrive your Jira user by overriding a method getUserByEmail(String email) of class UserUtils.

May be you should try this-

String email = "abc@test.com";

User user = UserUtils.getUserByEmail(email);

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2012

Hi Naren,

If i am not wrong, there is no getUserByEmail method in the api. Can you please confirm?

Naren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2012

Hi Spatruni,

See UserUtils api. Plz correct me if I am wrong.

Thanks.

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2012

ComponentManager.getInstance().getUserUtil() method returns com.atlassian.jira.user.util. UserUtil object which is not having the above method. Appreciate if you could let me know the way to get the com.atlassian.jira.user.UserUtils object.

Naren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2012

There are two classes in Jira. I am using UserUtils api for this, not the UserUtil. The getUserByEmail(String email) is a static method.

Try following code

import com.atlassian.core.user.UserUtils;

import com.atlassian.crowd.embedded.api.User;

User user = null;

String email = "abc@test.com"

try {

user = UserUtils.getUsersByEmail(email);

}

catch(Exception e) {

e.getStackTrace();

}

Hope this answers your query.

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2012

Thanks for sharing the information. I will try in the above way and check in case of any issues.

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2012

Hi Naren, I tried with the above approach, but unfortunately the class and methods are deprecated.

- The type UserUtils is deprecated

- The method getUserByEmail(String) from the type UserUtils is deprecated

1 vote
Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 28, 2012

Atlassian products don't support duplicate user names.

If you have multiple directories configured for your application, the first directory that contains the referenced username will be considered the canonical account for that username.

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2012

Appreciate if you could shower some more information about your answer. I also need the way to handle such usernames likes for example, if i want to move a user from one group to another, i am facing issues.

Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 28, 2012

What kind of issues are you facing?

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2012

Using the method UserUtil.getUserObject(String), i accessed a user and updated the group. When i searched that user, i found all the users with the same name from other directories vanished.

Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 28, 2012

That's because JIRA isn't designed to support multiple users with the same username. How did the duplicate users get created in the first place?

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2012

Leaving the passwords blank, providing username, full name and email information since the authentication needs against LDAP.

0 votes
tousifs
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2012

Hi,

Jira User Name may be duplicated no probs. may be LDAP or Jira User but when user is created for each user we have unique Email ID.

IF we are retriving user by Email id it should fetch only unique users.

jira dont allow same user id for both user names.

user = UserUtils.getUsersByEmail(email);

it should work.

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2012

I tried with the above approach, but unfortunately the class and methods are deprecated.

- The type UserUtils is deprecated

- The method getUserByEmail(String) from the type UserUtils is deprecated

0 votes
Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2012

Even i need to know how this can be done . i have to merge multiple Jira instances with some common users .. how to deal with duplicate users ? Thank you :)

0 votes
srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2012

Hi Atlassians,

Any ideas please...

Suggest an answer

Log in or Sign up to answer