This module is sligthly different than last module; The significant difference is in the query attribute where the sql query will calculate the time used by a user from the first access time of a user.
It will compare to Access-Period we define, and terminate a user session when the times expire.

Using this, we can limit a user access period for 1 day or 1 week from his first time he login using the a prepaid card.
The counter module we create is as below,

— snipped —
sqlcounter accessperiod {

counter-name = Max-Access-Period-Time
check-name = Access-Period
sqlmod-inst = sql
key = User-Name
reset = never
query = “SELECT UNIX_TIMESTAMP() - UNIX_TIMESTAMP(AcctStartTime) FROM radacct WHERE UserName = ‘%{%k}’ ORDER BY AcctStartTime LIMIT 1?

— snipped —

In the authorize section, we should include the module:

— snipped —
authorize {

 

preprocess
chap
mschap
suffix
eap
files
sql
pap
accessperiod

}
— snipped —

And as usual, we need to restart/reload the server to make the new configuration take effect.

Then for the radcheck table, we insert the appropriate attribute:

+—-+—–———–+———————+—-+————-+
| id   | UserName  | Attribute           | op | Value     |
+—-+——–——–+———————+—-+————-+
| 3    | user             | Access-Period   | := | 3600     |
+—-+——–——–+———–———-+—-+————-+

Tags: , ,

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Furl
  • MisterWong
  • Ma.gnolia
  • Google
  • Slashdot
  • StumbleUpon
  • Technorati
  • YahooMyWeb
  • Live

Another posts :

Related posts