Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 

Realm Selection Script Examples

 

Example 1: Querying Multiple SQL Databases

Example 1: Querying Multiple SQL Databases

A common application of realm selection scripts is to query a database for information used to determine the realm name. If the database query fails, you can program the script to query other databases for the required information. In this example, the script defines two DataAccessor objects, each pointing to a different SQL database. It also defines AttributeFilter and RealmSelector objects.

When the script executes, it uses the AttributeFilter object to obtain the value of the Called-Station-ID attribute from the request. It uses this value as the key to look up a realm selection method name in the first SQL database. If the database record is not found, it retries the query on the second database.

The result of the database query is the name of a built-in Steel-Belted Radius Carrier realm selection method. The script then calls the RealmSelector.Execute() method to determine the realm name from the current request, which it returns as the script result.

Table 128 and Table 129 show sample data for the two databases:

Table 128: Database #1

CallStationId

RealmMethod

1111111

Suffix

2222222

Prefix

3333333

DNIS

4444444

Attribute-Mapping

Table 129: Database #2

CallStationId

RealmMethod

5555555

Suffix

6666666

Prefix

7777777

DNIS

8888888

Attribute-Mapping

Two data accessor .gen files are required. They are identical except for the MethodName and Connect settings.

Finally, here is the script configuration file (.jsi) for this example. For script efficiency, you can use an initialization block to define persistent API objects.

Example 2: Using JavaScript to Manipulate Request Attributes

Example 2: Using JavaScript to Manipulate Request Attributes

In this example, an AttributeFilter object is used to obtain the User-Name attribute from the request. JavaScript string functions are used to extract the realm suffix decoration from the username. The suffix string is concatenated with the value of the Called-Station-Id attribute and is used to look up the realm name in a SQL database. The database query also returns the name of a profile to be merged with the result list upon successful authentication. The SetAuthProfile() function is called by the script to register the profile name.

This is an example database table for use with this script.

Table 130: Database Information

KeyString

RealmName

Profile

spacely1111111

spacely-realm1

SPACELY-PROFILE

spacely2222222

spacely-realm2

SPACELY-PROFILE

spacely3333333

spacely-realm3

SPACELY-PROFILE

spacely4444444

spacely-realm4

SPACELY-PROFILE

cogswell1111111

cogswell-realm1

COGSWELL-PROFILE

cogswell2222222

cogswell-realm2

COGSWELL-PROFILE

cogswell3333333

cogswell-realm3

COGSWELL-PROFILE

cogswell4444444

cogswell-realm4

COGSWELL-PROFILE

The corresponding data accessor .gen file is:

 

The script configuration file is as follows.