How to deactivate N number of ClearQuest users using Rational ClearQuest APIs

Technote (FAQ)


Question

How do you deactivate N number of ClearQuest users using IBM Rational ClearQuest APIs?

Cause

This is required to have a quick solution to deactivate N number of ClearQuest users without logging into IBM Rational ClearQuest User Administration Tool.

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.

User's login name can be written in a text file.
Each user's login name should be written in a separate line.

This script reads this file line by line and deactivates these users.

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.


Procedure:
  1. Navigate to the location where CQperl.exe is installed.
    By default: C:\Program Files\IBM\RationalSDLC\ClearQuest\CQperl.exe

  2. Save the below mentioned Perl script text to notepad and save with a .pl extension.

  3. Run the script using the following command:
    cqperl <filename.pl>


    Pearl Script


    *******************************
    #!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", "<AdminPasswd>", "<SchemaRepository>" );

    # Provide the file path where you have saved user's login names (to be deactivated)
    $file = 'C:\temp\users.txt';
    open(INFO, $file);
    @users = <INFO>;
    close(INFO);

    print "@users\n";

    foreach my $user (@users)
    {
    chomp $user;
    my $usertodeactivate = $user;
    $userList = $adminSession->GetUsers();
    $numUsers = $userList->Count();
    for ( $x=0; $x<$numUsers; $x++ )
    {
    $userObj = $userList->Item( $x );
    $useractive = $userObj->GetActive();
    $loginname = $userObj->GetName();

    if ($useractive)
    {
    if ( $usertodeactivate eq $loginname )
    {
    print "The User $loginname is being deactivated now\n";
    $userObj->SetActive(FALSE);
    }
    }
    }
    }
    CQAdminSession::Unbuild($adminSession);
    *******************************

Rate this page:

(0 users)Average rating

Add comments

Document information


More support for:

Rational ClearQuest
API

Software version:

7.1.2.3, 7.1.2.9, 8.0.0.4

Operating system(s):

Windows

Reference #:

1655157

Modified date:

2013-11-06

Translate my page

Machine Translation

Content navigation