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
MySQL Support
MySQL Driver
Configuring MySQL Datasource
Example 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 4.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.
This chapter has the following sections:
•
Oracle Software Requirements
•
Configuring ODBC
•
MySQL Support
Oracle Software Requirements
The Cisco Access Registrar 4.0 ODBC feature requires that you have Oracle 8.1.6, 8.1.7 or 9.0 client software installed. All Oracle client software library files are expected under $ORACLE_HOME/lib.
When you install Cisco Access Registrar 4.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.
The following changes have been made to support Oracle 9:
•
The file liboraodbc.so has been renamed to liboraodbc8.so.
•
The file liboraodbc9.so has been added.
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 queries 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 ]
OutagePolicy~ = RejectAll
MultipleServersPolicy = Failover
Table 19-1 describes the ODBC service parameters.
Table 19-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 19-2 describes the ODBC service parameters.
Table 19-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:
UserPasswordAttribute = asdfjkl
The following example is an SQL statement used for Authentication and Authorization:
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 19-3 describes the SQL Statement parameters.
Table 19-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 4.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.
For example, consider the following SQL select statement with ciscoavpair configured to Cisco-AVPair under ODBCToRadiusMappings. The table.column syntax requires an SQL alias for the mapping to work, as shown in the following example:
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.
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 4.0 currently supports only the Easysoft Open Source Oracle Driver.
Table 19-4 describes the Easysoft Open Source Oracle Driver options.
Table 19-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.
MySQL Support
Cisco AR 4.0 provides support for MySQL to query user records from a MySQL database and enables you to write accounting records into MySQL when using Oracle accounting. Cisco Access Registrar 4.0 has been tested with MySQL 4.0.18 and MyODBC 3.51.06 (reentrant).
For the Cisco AR server to use MySQL, you must create and configure an ODBCDataSource object of type myodbc and a RemoteServer object set to protocol odbc.
MySQL Driver
You can download the MySQL driver from the MySQL website at http://mysql.com. You can go directly to the driver download page using the following URL:
http://dev.mysql.com/downloads/connector/odbc/3.51.html
Save the downloaded file to a temporary location such as /tmp. Use commands like the following to unzip and install the driver:
gunzip -c MyODBC-3.51.06-sun-solaris2.8-sparc.tar.gz | tar xvf -
ln -s MyODBC-3.51.06-sun-solaris2.8-sparc myodbc
Configuring MySQL Datasource
To configure the Cisco AR server to query records form a MySQL database, complete the following configuration:
Step 1
Log in to the Cisco AR server and launch aregcmd.
Log in as a user with administrative rights such as user admin.
Step 2
Change directory to the /Radius/Advanced/ODBCDataSources and add a new ODBCDataSource.
cd /Radius/Advanced/ODBCDataSources
add mysql
Step 3
Set the new ODBCDatasource type to myodbc.
cd mysql
set type myodbc
Step 4
Set the Driver property to the path of the MyODBC library. Use a command like the following:
set driver /scratch/myodbc/libmyodbc3_r.so
Step 5
Set the UserID property to a valid username for the MyODBC database and provide a valid password for this user.
set userid ar-mysql-user
set password biscuit
Step 6
Provide a DataBase name and the name of the Cisco AR RemoteServer object to associate with the ODBCDataSource.
set database database_name
set server remote_server_name
Step 7
Change directory to /Radius/RemoteServers and add a RemoteServer object to associate with the new ODBCDatasource.
cd /Radius/RemoteServers
add mysql
Step 8
Change directory to the new RemoteServer and set its protocol to odbc.
cd mysql
set protocol odbc
Step 9
Set the ODBCDataSource property to the name of the ODBCDataSource to associate with this RemoteServer object.
set ODBCDataSource mysql
Example Configuration
The following shows an example configuration for a MySQL ODBC data source.
[ //localhost/Radius/Advanced/ODBCDataSources/mysql ]
Driver = /tmp/libmyodbc3_r.so
The following shows an example configuration for a RemoteServer
[ //localhost/Radius/RemoteServers/mysql-a ]
ReactivateTimerInterval = 300000
DataSourceConnections = 8
KeepAliveTimerInterval = 0
ODBCToEnvironmentMappings/