[Contents] [Prev] [Next] [Index] [Report an Error] [No Frames]


Sample Script

This is an example of a simple realm selection script and its configuration settings.

  1. To test this script, copy these lines to a new text file named SampleScript.jsi in the server's \radiusdir\scripts directory.
  2. [Settings]
    
    LogLevel = 2
    
    ScriptTraceLevel = 1
    
    
    
    [Script]
    
    // Print a message in the SBR log.
    
    SbrWriteToLog("Executing SampleScript.jsi");
    
    
    
    // Allocate a new Realm Selector object.
    
    var selector = new RealmSelector();
    
    
    
    // Invoke the built-in Suffix realm selection method to obtain
    
    // the realm for the request.
    
    var realm = selector.Execute("suffix");
    
    SbrWriteToLog("Suffix method returned '" + realm + "'");
    
    
    
    // Print a trace frame to the log.
    
    SbrTrace();
    
    
    
    //Return the realm name as the script result.
    
    return realm;
    
    
    
    [ScriptTrace]
    
    var = realm
    
    
    
    [Failure]
    
    DefaultRealm
    
    
    
  3. Next, edit the \radiusdir\proxy.ini file.

In the [Processing] section at the top of the file, you see this comment line:

;Script <RealmScript> 


Remove the ";" and replace <RealmScript> with the actual file name (omit the file extension):

[Processing]
Suffix
Prefix
DNIS
Attribute-Mapping
Script SampleScript


NOTE: Use only the script file base name only when configuring the Script setting. If you specify the .jsi extension, Steel-Belted Radius Carrier fails to load the file.


  1. In the \radiusdir\radius.ini file, scroll down to the [Configuration] section, and ensure that the following line is present:
  2. ExtendedProxy = 1
    

  1. If you wish to check the script syntax and environment, set up and run the scriptcheck utility, discussed in scriptcheck.
  2. Restart the Steel-Belted Radius Carrier process.
    When the server starts, log messages should indicate that the script loaded and is ready to run:
  3. Loading script from file 'C\radius\Service\scripts\SampleScript'
    
    Extended Proxy: Enabled precedence 4 processing for Script SampleScript
    
    
    
  4. When a RADIUS request is received, the script executes and messages similar to these appear in the log:
  5. Executing 'SampleScript'
    
    Suffix method returned 'realm1'
    
    *** Script Trace (C:\radius\Service\scripts\SampleScript)
    
        (line 41) SbrTrace();
    
        realm=realm1
    
    CreateRequestEx: using virtual realm realm1 for authentication.
    
    
    

    NOTE: The actual realm name returned by the script depends on the Steel-Belted Radius Carrier configuration and the suffix decoration of the username specified in the RADIUS request.

For detailed information on the proxy.ini file, see "proxy.ini File" in Chapter 7, Realm Configuration Files of the Steel-Belted Radius Carrier 7.2 Reference Guide.


[Contents] [Prev] [Next] [Index] [Report an Error] [No Frames]