UserLogon

Description

Log in as the specified user for a database session.

Before calling this method, you should have already created and initialized a new Session object.

Note: You must log in with superuser privilege to prevent the DatabaseDesc object's GetDatabaseConnectString method from generating an error.

If you are writing hook code, this method is typically not needed. DevOps Plan creates the Session object for you, and logs the user in before calling any hooks.

Syntax

Perl


$session->UserLogon(login_name, password, database_name, database_set); 
Identifier
Description
session
The Session object that represents the current database-access session.
login_name
A String that specifies the login name of the user.
password
A String that specifies the user's password.
database_name
A String that specifies the name of the desired user database. (You must not login to the schema repository using this method.)
database_set
A String that specifies the name of the database set or connection string.
Note: You can use an empty string ("") if you have only one database set or to refer to the default database set. The default database set name is the one that matches the product version number, 7.0. for example.
Note: 0).
Return value
None.

Example

Perl


use CQPerlExt;

#Start a DevOps Plan session

$sessionObj = CQSession::Build();

#Get a list of accessible databases

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

$count = $databases->Count();

#For each accessible database, login as joe with password gh36ak3

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

   $db = $databases->Item($x);
   $dbName = $db->GetDatabaseName();
   # Logon to the database 
   $sessionObj->UserLogon( "joe", "gh36ak3", $dbName, "" );
   #...
   }

CQSession::Unbuild($sessionObj);