GetLogin

Description

Returns the database login associated with the current user.

Syntaxe

VBScript

dbDesc.GetLogin

Perl

$dbDesc->GetLogin();
Identificateur
Description
dbDesc
A DatabaseDesc object containing information about one of the installed databases.
Return value
A String containing the database login associated with the current user.

The database login is not the same as the user's Rational ClearQuest login. The database login refers to the account name Rational ClearQuest uses when initiating transactions with the database. This value is set up in advance by the database administrator.

The user must be logged in to a database for this method to return an appropriate value. For hook code writers, Rational ClearQuest logs the user in to the database automatically. If you are writing a stand-alone application, you must manually create a Session object and call the UserLogon method before calling this method.

For most users, this method returns the Read/Write login associated with the database. However, if the user associated with the current session is the Rational ClearQuest administrator, this method returns the database-owner login instead. Similarly, if the user has a read-only account, this method returns the read-only login.

If you have access to the schema repository, you can retrieve information about this user database by accessing the properties of the corresponding Database object.

Exemples

VBScript

The following example shows you how to log on to the database from a Visual Basic application.

set sessionObj = CreateObject("CLEARQUEST.SESSION")

' Login to each database successively.
databases = sessionObj.GetAccessibleDatabases("MASTR", "", "")
For Each db in databases
   If Not db.GetIsMaster Then
      ' Logon to the database.
      sessionObj.UserLogon "tom", "gh36ak3", dbName,
         AD_PRIVATE_SESSION, dbSetName
      ' Get the database login and password for "tom"
      dbLogin = db.GetLogin
      dbPassword = db.GetPassword

       ' ...
   End If
Next

Perl

use CQPerlExt;

#Start a Rational ClearQuest session
$sessionObj = CQSession::Build();

#Get a list of accessible database description objects

$databases = $sessionObj->GetAccessibleDatabases("MASTR", "", "");

#Obtenez le nombre de bases de données

$count = $databases->Count();

#Foreach accessible database that is not the master database

for($x=0;$x<$count;$x++){

   $db = $databases->Item($x);

   if ( ! $db->GetIsMaster() ) {

      $dbName = $db->GetDatabaseName();

      #Logon to the database as "tom" with password "gh36ak3"

      $sessionObj->UserLogon( "tom", "gh36ak3", $dbName, $dbSetName );

      #Get the database login and password for "tom"

      $dbLogin = $db->GetLogin();

      $dbPassword = $db->GetPassword();

      #...

   }

}

CQSession::Unbuild($sessionObj);

Commentaires