Cisco CNS Access Registrar User's Guide, 3.0
Using Open Database Connectivity

Table Of Contents

Using Open Database Connectivity

Oracle Software Requirements

Configuring ODBC

Configuring the ODBC Service

Configuring an ODBC RemoteServer

ODBC Data Source

SQL Definitions

SQL Syntax Restrictions

Specifying More Than One Search Key

ODBCToRadiusMappings

ODBCToEnvironmentMappings

Configuring an ODBC DataSource

Setting ODBC As Authentication and Authorization Service

Saving Your Configuration


Using Open Database Connectivity


Cisco AR supports Open Database Connectivity (ODBC), an open specification that provides application developers a vendor-independent API with which to access data sources. Cisco AR provides a new type of RemoteServer object and a new service to support ODBC. You can use Cisco AR to authenticate and authorize access requests by querying user information through ODBC.

ODBC is an application program interface (API). Real data exchange between an application and data store is still carried out by SQL through ODBC. To achieve the most flexibility, you are required to define your own SQL using aregcmd. Cisco AR will register the SQL statements and send them to the data store through ODBC when required. Because you can define your own SQL, Cisco AR supports sites that have their own data stores.

ODBC is configured using .ini files, specifically odbc.ini and odbcinst.ini. However, you cannot create or modify these files directly. Cisco AR creates the .ini files after you use aregcmd to configure the ODBC connection. The SQL is stored in the local database (MCD). During execution, the Cisco AR server reads the local database, prepares the SQL statements, and sends the SQL to the data source.


Note Cisco AR uses its own ODBC driver manager and does not share existing ODBC drivers (if you already have ODBC installed). If you are already using ODBC, you will have to maintain two separate ODBC installations.


The ODBC memory requirement depends on your configuration. The more datasources you configure, the more memory is required. Packet processing time might increase if you configure a large number of SQL statements under SQLDefinition.

The Cisco Access Registrar 3.0 package includes some ODBC Drivers, and you should use the included driver whenever possible. If a data store's ODBC driver is not included with Cisco AR, you are required to install it. You configure the driver library using aregcmd to modify the associated ini file.

Oracle Software Requirements

The Cisco Access Registrar 3.0 ODBC feature requires that you have Oracle 8.1.6 or 8.1.7 client software installed. All Oracle client software library files are expected under $ORACLE_HOME/lib.

When you install Cisco Access Registrar 3.0 software, the installation process prompts you for ORACLE_HOME variable and sets it in the Cisco AR start-up script, /etc/init.d/arserver. Two other environment variables (ODBCINI and ODBCSYSINI) are also set in the arserver script. To change any of these variables, modify the /etc/init.d/arserver script and restart the Cisco AR server.

Configuring ODBC

You use aregcmd to define your ODBC configuration and SQL statements. The Cisco AR server automatically creates the ODBC.ini file for your driver manager and driver based on how you configure ODBC.

To use ODBC in Cisco AR, you must do the following:

1. Configure an ODBC Service

2. Configure an ODBC RemoteServer object

3. Configure an ODBC DataSource

4. Set ODBC service as the default AA service

5. Save your configuration

After you save and validate your configuration, it is saved in the MCD database. If you have configured an ODBC service, Cisco AR will query the MCD database and create or modify the odbc.ini file before it builds a connection to the database. When you reload your configuration, Cisco AR shuts down any existing ODBC connections, then querys the MCD database to create or modify the odbc.ini file and build a new connection for any configured ODBC Data Sources.

Configuring the ODBC Service

You configure an ODBC service under /Radius/Services. When you define an ODBC service under /Radius/Services, you must set its type to ODBC and provide the following configuration options:


Note We will use ODBC as the ODBC service name in the following examples.


[ //localhost/Radius/Services/ODBC ]
    Name = ODBC
    Description = 
    Type = odbc
    IncomingScript~ = 
    OutgoingScript~ = 
    OutagePolicy~ = RejectAll
    OutageScript~ = 
    MultipleServersPolicy = Failover
    RemoteServers/

Table 13-1 describes the ODBC service parameters.

Table 13-1 ODBC Service Parameters

Parameter
Description

Name

Mandatory; inherited from the upper directory

Description

An optional description of the service

Type

Must be set to ODBC for ODBC service

IncomingScript

Optional

OutgoingScript

Optional

OutagePolicy

Mandatory; must be set to AcceptAll or Drop Packet, or defaults to RejectAll

OutageScript

Optional

MultipleServersPolicy

Mandatory; must be set to RoundRobin or defaults to Failover.

When set to Failover, Cisco AR directs requests to the first server in the list until it determines the server is off-line. If so, Cisco AR redirects all requests to the next server in the list until it finds an on-line server.

When set to RoundRobin, Cisco AR directs each request to the next server in the RemoteServers list in order to share the resource load across all servers in the RemoteServers list.

RemoteServers

Mandatory list of remote servers defined under /Radius/Services/ODBC/RemoteServers such as ODBC-Primary and ODBC-Secondary


Configuring an ODBC RemoteServer

You must configure an ODBC RemoteServer object for each RemoteServer object you list under /Radius/Services/ODBC/RemoteServers. Use the aregcmd command add to add ODBC servers under /Radius/RemoteServers.

Table 13-2 describes the ODBC service parameters.

Table 13-2 ODBC Remote Server Parameters 

Parameter
Description

Name

Mandatory; inherited from the upper directory

Description

An optional description of the server

Protocol

Mandatory and must be set to ODBC; no default value

ReactivateTimerInterval

Mandatory; default is 300000 (ms)

Timeout

Mandatory; default is 15 (seconds)

DataSourceConnections

Mandatory; number of concurrent connections to data source (default is 8)

ODBCDataSource

Mandatory; no default value

SQLDefinition

SQLDefinition/ (mandatory, no default);
UserPasswordAttribute = (mandatory, no default; data store field for user password)

SQLStatements/

SQLStatement1/

SQLStatement2/

ODBCToRadiusMappings

(optional)

ODBCToEnvironmentMappings

(optional)

ODBCToCheckItemMappings

(optional)


ODBC Data Source

ODBCDataSource is the name of the datasource to be used by the remote server. An ODBCDataSource name can be reused by multiple remote servers. You configure ODBCDataSources under /Radius/Advanced/ODBCDataSources. Refer to Configuring an ODBC DataSource, for more information.

SQL Definitions

SQLDefinitions lists the UserPasswordAttribute and one or more SQL statements, listed numerically in the order to be run. The UserPasswordAttribute represents a column in the database that contains users' password information. Individual SQLStatements are numbered SQL1 through SQLn under SQLStatements, as shown in the following example:

SQLDefinition/ 
UserPasswordAttribute = asdfjkl
SQLStatements/ 
SQL1/
SQL2/
SQL3
...

The following example is an SQL statement used for Authentication and Authorization:

SQLStatements/ 
SQL1
Name = SQL1
Type = query (mandatory, no default; must be query)
SQL = SQL statement (mandatory, no default)
ExecutionSequenceNumber = Sequence number for SQLStatement execution.(mandatory, 
no default and must be greater than zero).
MarkerList = UserName/SQL_DATA_TYPE ...... (mandatory, UserName must be defined)

Table 13-3 describes the SQL Statement parameters.

Table 13-3 SQL Statement Parameters 

Parameter
Description

Name

Name/number of SQL statement

Type

Query (mandatory, no default value)

SQL

SQL query statement

ExecutionSequenceNumber

Sequence number for SQLStatement execution, must be greater than zero (mandatory, no default)

MarkerList

Defines all markers for the query. MarkerList uses the format UserName/SQL_DATA_TYPE.


SQL Syntax Restrictions

You must observe the following SQL syntax restrictions in SQL queries for Cisco Access Registrar 3.0.

1. The SQL statement must be in the format of SELECT ... FROM ... WHERE ..." (Statements might be in lower-case.)


Note 'WHERE' is compulsory in the SQL statement.


2. Any arguments to Oracle functions like distinct, count must be given within braces, as shown in the following example:

select distinct(attribute),password from profiles where username=?

The resulted column from distinct(attribute) will be put into attribute which can be used for ODBC Mappings. The actual result set from Oracle for this column would be named distinct(attribute).

3. The column list in the SQL statement must be delimited with a comma (,) and any extra spaces between statements are ignored. Aliasing for column names in SQL is not allowed. SQLDefinition properties define the SQL you want to execute, as shown in the following example.

Specifying More Than One Search Key

You can specify more than one search key for a table in the SQL SELECT. To do so, add another search criteria to the SQL statement and add the environment variable name to the MarkerList. For example, the following query and MarkerList can be used to look up a username and CLID match.

select password from user_table where username = ? and clid = ?

In this case, the marker list would look like this:

UserName/SQL_CHAR clid/SQL_CHAR

To configure the multiple entries in the MarkerList list, surround the entire string in double quotes like the following:

set MarkerList "UserName/SQL_CHAR CLID/SQL_CHAR"

To make this work, a variable called CLID must be in the environment dictionary. You can use a script to copy the appropriate value into the variable.

ODBCToRadiusMappings

You configure ODBCToRadiusMappings with a list of name/value pairs where name is the name of the data store attribute to retrieve from the user record and the value is the name of the RADIUS attribute to set to the value of the data store attribute retrieved.

For example, when the ODBCToRadiusMappings has the following entry, the RemoteServer retrieves the attribute from the data store user entry for the specified user, uses the value returned, and sets the response variable Framed-IP-Address to that value:

FramedIPAddress = Framed-IP-Address

When an SQL select statement returns more than one row for a column mapped under ODBCToRadiusMappings, multiple RADIUS attributes will be created. As of the Cisco AR 3.0R6 release, the table.column syntax requires an SQL alias for the mapping to work, as shown in the following example:

SQLStatements/
SQL1/
select table1.abc as t1abc, password from table2 where username = ? 
Mapping: t1abc = my_mapping

If two rows are returned for ciscoavpair column, two Cisco-AVPair attributes will be created.

ODBCToEnvironmentMappings

Under ODBCToEnvironmentMappings there is a list of name/value pairs in which the name is the name of the data store attribute to retrieve from the user record, and the value is the name of the Environment variable to set to the value of the ODBC attribute retrieved.

For example, when the ODBCToEnvironmentMappings has the entry: group = User-Group, the RemoteServer retrieves the attribute from the ODBC user entry for the specified user, uses the value returned, and sets the Environment variable User-Group to that value. When an SQL select statement returns more than one row for a column mapped under ODBCToEnvironmentMappings, the first row's value will be taken.


Note As of the Cisco AR 3.0R6 release, the table.column syntax requires an SQL alias for the mapping to work.


Configuring an ODBC DataSource

ODBCDataSource is the name of the datasource to be used by the remote server. You configure ODBCDataSources under /Radius/Advanced/ODBCDataSources. Multiple remote servers can use the same ODBCDataSource.

Under the ODBCDataSource object definition, a list defines ODBC.ini file name/value pairs for a connection. The list includes a Type field and a Driver field, different for each Driver and Data Source, to indicate its Driver and Data Source. Cisco Access Registrar 3.0 currently supports only the Easysoft Open Source Oracle Driver.

Table 13-4 describes the Easysoft Open Source Oracle Driver options.

Table 13-4 Easysoft Open Source Oracle Driver Options 

Parameter
Description

Name

Name of the ODBCDataSource

Type

Mandatory; must be Oracle_es

Driver

Mandatory; liboarodbc.so (default value)

Database

Mandatory; Oracle Client configuration database name (no default value)

UserID

Mandatory; database user name (no default value)

Password

Optional user password; shown encrypted


Setting ODBC As Authentication and Authorization Service

Use aregcmd to configure the ODBC Service as the default authentication and authorization service under //localhost /Radius as in the following:

set DefaultAuthenticationService odbc-service

set DefaultAuthorizationService odbc-service

Saving Your Configuration

When you use aregcmd to save your configuration, Cisco AR attempts to validate the configuration, checks for all required parameters, and ensures there is no logic error. If the validation is successful, the configuration is saved to the MCD database. When you reload, Cisco AR shuts down any current ODBC connections and builds new connections for the configured ODBC Data Sources.