How do you check if a full username exists in the IBM Rational ClearQuest Users list using the ClearQuest API?
You would like to implement a custom process where no two user full names should be the same.
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.
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:
- Navigate to the location where "CQperl.exe" is installed.
By default: C:\Program Files\IBM\RationalSDLC\ClearQuest\CQperl.exe
- 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.
# Make sure you have correct path for CQperl.exe
# Create a Rational ClearQuest admin session
# 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
- Run the script using the following command: