IBM Support

How to check if a full username exists in the ClearQuest Users list using the ClearQuest API

Question & Answer


Question

How do you check if a full username exists in the IBM Rational ClearQuest Users list using the ClearQuest API?

Cause

You would like to implement a custom process where no two user full names should be the same.

Answer

The Perl Script below uses the ClearQuest API and can be run on Windows.
Note: The ClearQuest Native Client must be installed on this machine.

This script iterates through all the ClearQuest users to find, if a user with full name "Test User" already exists.
If the same user name exists; this script will print the existing user's Login ID as well the Full Name.
 
Disclaimer

All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.



Steps to run this script:
  1. Navigate to the location where "CQperl.exe" is installed.
    By default: C:\Program Files\IBM\RationalSDLC\ClearQuest\CQperl.exe
     
  2. Save the following Perl script text to notepad and save with a .pl extension.

    Note: Replace Test User in the script with the full name that you would like to check.

    *****************************
    !C:\Program Files\IBM\RationalSDLC\ClearQuest\CQperl.exe
    # Make sure you have correct path for CQperl.exe

    use CQPerlExt;

    # Create a Rational ClearQuest admin session
    $adminSession= CQAdminSession::Build();
    # Logon as admin
    # Provide correct values for admin password, Schema Repository name

    $adminSession->Logon( "admin", "adminpassword", "SchemaRepositoryName" );

    my $newuser = "
    Test User";

    $userList = $adminSession->GetUsers();
    $numUsers = $userList->Count();
    for ( $x=0; $x<$numUsers; $x++ )
    {
    $userObj = $userList->Item( $x );
    $username = $userObj->GetFullName();
    $loginname = $userObj->GetName();
    if ( $username eq $newuser )
    {
    print "There is already a user with the same full name - $username\n";
    print "$username Login ID is- $loginname\n";
    }
    }
    #Unbuild the Admin session
    CQAdminSession::Unbuild($adminSession);

    *******************************

     
  3. Run the script using the following command:

    cqperl <filename.pl>

[{"Product":{"code":"SSSH5A","label":"Rational ClearQuest"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"API","Platform":[{"code":"PF033","label":"Windows"}],"Version":"7.1.2;7.1.2.3;7.1.2.5;7.1.2.6","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
21 March 2021

UID

swg21641562