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

Technote (FAQ)


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>

Rate this page:

(0 users)Average rating

Document information


More support for:

Rational ClearQuest
API

Software version:

7.1.2, 7.1.2.3, 7.1.2.5, 7.1.2.6

Operating system(s):

Windows

Reference #:

1641562

Modified date:

2013-07-03

Translate my page

Machine Translation

Content navigation