Creating a new user by copying an existing user
search cancel

Creating a new user by copying an existing user

book

Article ID: 106830

calendar_today

Updated On:

Products

CA Harvest Software Change Manager - OpenMake Meister CA Harvest Software Change Manager

Issue/Introduction

When creating a new user that will be replacing or joining an existing user and the existing user is a member of multiple ( 100+) user groups, it would be beneficial to be able to create a user based on another user's access.

To use the Administrator Tool to accomplish this would be time consuming and error-prone. It would help to have a more efficient way to accomplish this task.

Environment

CA Harvest SCM all versions and platforms

Resolution

The Harvest Administrator Tool does not include a "right-click" option that creates a new user using an existing user as a template.  However, this can be done using the Harvest command line utilites.

  1. The first step will be to use the Harvest Administrator Tool to create the new user.  Fill in all the relevant information about the user and click "OK".  For example:



  2. Next we will use the hsql command line utility to generate a tab-delimited text file containing the new user's userid and the list of groups to which to add them, in the format that the husrmgr command requires.  The following query will accomplish this:
    SELECT DISTINCT 'testuser2' AS USR,  /* <--- The new user's userid */
    '' AS PWD,
    '' AS FULLNAME,
    '' AS PHONE,
    '' AS EXT,
    '' AS FAX,
    '' AS EADDR,
    '' AS USRNOTE,
    HARUSERGROUP.USERGROUPNAME
    FROM HARUSER
    INNER JOIN HARUSERSINGROUP ON HARUSER.USROBJID = HARUSERSINGROUP.USROBJID
    INNER JOIN HARUSERGROUP ON HARUSERGROUP.USRGRPOBJID = HARUSERSINGROUP.USRGRPOBJID
    WHERE HARUSER.USERNAME = 'testuser1' /* <--- The userid assigned to the list of groups you want goes here */
    AND HARUSERGROUP.USERGROUPNAME != 'Public' /* all users belong to the Public group. No need to include it in the result */
    The important point about the above query is that you will want to change "testuser2" to the new user's userid on the first line of the query, and change "testuser1" to the previously existing userid whose groups you want to copy on the next to last line of the query.

    Copy the above query to a text file on your Harvest administrator or broker machine and make the above-recommended changes.  Then use the following command to execute the query:
    hsql -b <your brokername> -usr <your userid> -pw <your password> -t -nh -f <filename of the above query> > <output filename>
     
    For example:
    hsql -b example-broker -usr harvest -pw ******* -t -nh -f getgroups.sql > getgroups.out
     
    You will find the resulting file looks similar to this:


  3. Finally we will use the husrmgr command line utility to read the tab-delimited file generated in step 2 and use that information to add the new user to all the needed user groups.   Use the following command to process the list:
    husrmgr -b <your broker name> -usr <your userid> -pw <your password> -ow getgroups.out

    For example:
    husrmgr -b example-broker -usr harvest -pw ******* -ow getgroups.out

    The output of the command will look similar to this:


After executing the above steps, checking the new user's properties in the Administrator Tool, the new groups will be found.  For example: