GetLogin
Description
Returns the database login associated with the current user.
Syntax
Perl
$dbDesc->GetLogin();
- Identifier
- 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 DevOps Plan login. The database login refers to the account name DevOps Plan 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, DevOps Plan 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 DevOps Plan 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.
Example
Perl
use CQPerlExt;
#Start a DevOps Plan session
$sessionObj = CQSession::Build();
#Get a list of accessible database description objects
$databases = $sessionObj->GetAccessibleDatabases("MASTR", "", "");
#Get the number of databases
$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);