다음 예제에서는 UpgradeInfo 메소드(User 오브젝트의)를 사용하여 User 특성을 설정하고 사용자가 등록한 데이터베이스를 업데이트할 때 성능을 최적화합니다.
이들 예제는 사용자 프로파일을 업데이트하고 사용자가 신청한 모든 데이터베이스를 업그레이드합니다. 또한 액세스 가능한 데이터베이스에 대한 로그인을 시도하여 업데이트를 확인합니다.
자세한 정보는 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";
}
}