The following examples use the UpgradeInfo method (of the User object) to optimize peformance when setting User properties and updating the databases to which a user is subscribed.
These examples update a user profile and upgrade all the databases that the User is subscribed to. They also verify the update by attempting to log into each accessible database.
For more information, see UpgradeInfo.
Dim dbset Dim adminUser Dim adminPasswd Dim userName Dim passwd Dim adminSession Dim userList Dim userObj Dim email Dim phone Dim fullname Dim failed_dbs Dim session Dim dbdescs Dim db Dim dbname dbset = "2003.06.00" adminUser = "admin" adminPasswd = "" ' Create a Rational ClearQuest admin session set adminSession = CreateObject("CLEARQUEST.ADMINSESSION") If (adminSession.Logon (adminUser, adminPasswd, dbset)) Then MsgBox "Could not get Admin session login" End If ' the user who you want to change user profile for userName = "QE1" passwd = "secret" 'Get the User set userObj = adminSession.GetUser(userName) If userObj is Nothing Then 'Do NOT use MsgBox if you are using a ClearQuest Web server MsgBox "Error: Failed lookup for user" & userName End If email = "qe@example.com" phone = "123456789" fullname = "Best Quality Engineer" userObj.Password(passwd) userObj.EMail(email) userObj.Phone(phone) userObj.FullName(fullname) ' Upgrade all the databases that the user is subscribed to MsgBox "Upgrade user profile for userName" failed_dbs = userObj.UpgradeInfo if (failed_dbs > 0) then MsgBox "Set password failed in database(s)" & failed_dbs end if ' verify the new password by logging into databases set session = CreateObject("ClearQuest.Session") dbdescs = session.GetAccessibleDatabases("MASTR", userName, dbset) for each db in dbdescs dbname = db.GetDatabaseName session.UserLogon userName, passwd, dbname, AD_PRIVATE_SESSION, dbset If session is Nothing then MsgBox "Could not get session login to db" & dbname End If MsgBox "Checking user info in db" & dbname & ":" ' verify the new phone, fullname, and email if (email <> session.GetUserEmail) then MsgBox "Email is not upgraded in" & dbname end if if (fullname <> session.GetUserFullName) then MsgBox "Full name is not upgraded in" & dbname end if if (phone <> session.GetUserPhone) then MsgBox "Phone is not upgraded in" & dbname end if next
use CQPerlExt; use Time::Local; $dbset = "2003.06.00"; $adminUser = "admin"; $adminPasswd = ""; # Create a Rational ClearQuest admin session my $adminSession= CQAdminSession::Build(); if ($adminSession->Logon( $adminUser, $adminPasswd, $dbset )) { print "Could not get Admin session login\n"; exit 1; } # the user who you want to change user profile for my ($userName, $passwd) = ("testuser", "password"); # Get the user object for the user we want to upgrade. my $userObj = $adminSession->GetUser($userName); unless ($userObj) { print "$0: Error: Failed lookup for user \"$userName\"\n"; exit 1; } $email="qe\@example.com"; $phone="123456789"; $fullname="Best Engineer"; $userObj->SetPassword($passwd); $userObj->SetEmail($email); $userObj->SetPhone($phone); $userObj->SetFullName($fullname); # Upgrade all the databases that the user is subscribed to print "Upgrade user profile for $userName\n"; $failed_dbs = $userObj->UpgradeInfo(); @temp = @$failed_dbs; if ($#temp > -1) { printf "fail dbs: %s.\n", join(',', @temp); } # verify the new password by logging into databases $session = CQSession::Build(); $dbdescs = $session->GetAccessibleDatabases("MASTR", $userName, $dbset); foreach $i (0 .. $dbdescs->Count()-1) { $dbname = $dbdescs->Item($i)->GetDatabaseName(); $session->UserLogon($userName, $passwd, $dbname, $dbset); unless (defined $session) { print LOG "Could not get session login to db $dbname\n"; exit 1; } print "Checking user info in db $dbname:\n"; # verify the new phone, fullname, and email if ($email ne $session->GetUserEmail()) { print "Email is not upgraded in $dbname\n"; } if ($fullname ne $session->GetUserFullName()) { print "Full name is not upgraded in $dbname\n"; } if ($phone ne $session->GetUserPhone()) { print "Phone is not upgraded in $dbname\n"; } else { print "User information verified.\n"; } }