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. HCL Compass creates the Session object for you, and logs the user in before calling any hooks.

Syntax

VBScript


session.UserLogon login_name, password, database_name, session_type, 
database_set 

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.)
session_type
(VBScript Only) A SessionType enumerated constant (use AD_PRIVATE_SESSION). Perl does not recognize SessionType constants.
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.

Examples

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","admin","")  
For Each db in databases   
   dbName = db.GetDatabaseName   
   sessionObj.UserLogon "admin", "", dbName, AD_PRIVATE_SESSION, ""  
' Access the database   
' ...  Next

Perl


use CQPerlExt;

#Start a HCL Compass 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);