GetAccessibleDatabases

Description

Returns a list of databases that are available for the specified user to log in to.

This method returns only the databases that the specified user is allowed to log in to. If the user_login_name parameter contains an empty String, this method returns a list of all of the databases associated with the specified schema repository (master database).

You can examine each DatabaseDesc object to get the corresponding database name, database set name and other information needed to log in to it.

Note: The GetAccessibleDatabases method does not require a user login; it can be called from a constructed Session object before a user login. If LDAP authentication is enabled, the user login name may not be the same as the HCL Compass user name. See Impact on Existing APIs for more information.

Syntax

VBScript


session.GetAccessibleDatabases (master_db_name, user_login_name, 
database_set) 

Perl


$session->GetAccessibleDatabases(master_db_name, user_login_name, 
database_set); 
Identifier
Description
session
The Session object that represents the current database-access session.
master_db_name
A String that specifies the HCL Compass logical database name of the schema repository. In most cases, this value is "MASTR".
user_login_name
A String that specifies the user login name. Using an empty string for this argument tells this function to return a list of all databases associated with this schema repository, not just those accessible to a specific user.
database_set
A String that specifies the database set in which to look for accessible databases. By default, this argument should contain the empty String. This causes the function to use the product-default database set name (that is, the product version number).
Return value
For VBScript, an Array of Variants each containing a DatabaseDesc Object.

For Perl, a DatabaseDescs Object collection.

Example

VBScript


set sessionObj = GetSession 

' Get the list of databases in the 
' master database set. 
databases = sessionObj.GetAccessibleDatabases("MASTR","admin","")
for each db in databases 
   ' Get the name of the database 
   dbName = db.GetDatabaseName 
   sessionObj.UserLogon "admin", "", dbName, AD_PRIVATE_SESSION, ""

   dbConnectString = db.GetDatabaseConnectString
Next



The following code provides a MsgBox indicating the connect vendor 
information and logical name for all the user databases in a specific dbset.

Sub Test()

Dim session 

Dim databases

Dim dbConnectString

Dim dbConnectName

Dim db

Set session = CreateObject("CLEARQUEST.SESSION")

databases = session.GetAccessibleDatabases("MASTR", "admin", "")

session.UserLogon "admin", "", "SAMPL", AD_PRIVATE_SESSION, ""

For Each db In databases

   dbConnectString = db.GetDatabaseConnectString

   dbConnectName = db.GetDatabaseName

   MsgBox dbConnectString

   MsgBox dbConnectName

Next

End Sub 

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();

#Foreach 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);