It's all about the answers!

Ask a question

How to remove duplicate users in RTC


Venkatesh Nadamuni (137) | asked Aug 16 '12, 8:10 p.m.
edited Aug 17 '12, 2:39 a.m. by Ralph Schoon (63.1k33645)

Recently the LDAP team renamed all the upper case users to lower case, but forgot to tell us.  RTC LDAP synch picked up the lower case users without removing or archivng the uppercase.  Now when a user tries to login they get a message that there is a duplicate user and the system locks them out.  I have few hundred users with this issue. 

System should not have allowed these users to be uploaded, if it prevents the user from loggin-in.

I have been able to manually rename the users names and archive them.  But this will take me a few weeks. 

Any idea on how I can make this happen in bulk?

One answer



permanent link
Ralph Schoon (63.1k33645) | answered Aug 17 '12, 2:38 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Aug 17 '12, 2:40 a.m.
The following code is based on https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation and would archive (or delete) a user given its ID. If you wrap it into reading a file with the user ID's you should be able to do this. I'd suggest to archive the users first and if needed run a second pass later if no one has any issues making sure the users are archived before deleting them. You might want to test this on a test server.

    private static boolean run(String[] args) throws TeamRepositoryException {

        if (args.length != 4) {
            System.out
                    .println("Usage: ArchiveUser <repositoryURI> <userId> <password> <userToArchive>");
            return false;
        }

        String repositoryURI = args[0];
        final String userId = args[1];
        final String password = args[2];
        String archiveID = args[3];

        ITeamRepository teamRepository = TeamPlatform
                .getTeamRepositoryService().getTeamRepository(repositoryURI);
        teamRepository
        .registerLoginHandler(new ITeamRepository.ILoginHandler() {
            public ILoginInfo challenge(ITeamRepository repository) {
                return new ILoginInfo() {
                    public String getUserId() {
                        return userId;
                    }

                    public String getPassword() {
                        return password;
                    }
                };
            }

        });
        teamRepository.login(null);

        IContributor user = teamRepository.contributorManager().fetchContributorByUserId(archiveID, null);
        IContributor archiveIDWorkingCopy = (IContributor) user.getWorkingCopy();
        archiveIDWorkingCopy.setArchived(true);
        teamRepository.contributorManager().saveContributor(archiveIDWorkingCopy, null);

        /**
         * Delete User!!
         *
         * teamRepository.contributorManager().deleteContributor(archiveIDWorkingCopy, null);
         */
       

        System.out.println("Archived user: " + archiveID + ".");

        teamRepository.logout();

        return true;
    }

Your answer


Register or to post your answer.