Enforcing Login-Time on NAS
I know that Login-Time can be used with Users and Groups but is there a way to use this with NAS'? For example, If I want NAS-A to allow logins only from 1700-1800 and NAS-B to allow logins only from 0900-1300. How would I be able to ensure this? I have tried this with Huntgroups, but only able to prevent/allow logins unconditionally. How do I attach the Login-Time attribute to NAS and not users or groups? -- Regards, Shivkumar
Use Unlang or Similar Scripts : If Nas = 1 then update Login Time = xxxx If Nas = 2 then update Login Time = yyyy Use this in PreAuth (I am not sure) Section and give it a try . Regards Suman On Tue, Sep 27, 2011 at 5:42 PM, Shiv <shivkumar.jags@gmail.com> wrote:
I know that Login-Time can be used with Users and Groups but is there a way to use this with NAS'? For example, If I want NAS-A to allow logins only from 1700-1800 and NAS-B to allow logins only from 0900-1300. How would I be able to ensure this?
I have tried this with Huntgroups, but only able to prevent/allow logins unconditionally. How do I attach the Login-Time attribute to NAS and not users or groups?
-- Regards, Shivkumar - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Thanks Suman, I put the following in the sites-enabled/default file under the authorize section and it worked! update request { #Huntgroup-Name := "%{sql:SELECT `groupname` FROM `radhuntgroup` WHERE nasipaddress='%{NAS-IP-Address}'}" Huntgroup-Name := "%{sql:SELECT `groupname` FROM `radhuntgroup` WHERE rtrmac='%{Called-Station-Id}'}" } if ( "%{Huntgroup-Name}" == HotspotA ) { update control{ Login-Time := Al1900-2100 } Now, to write a query to pull in Login-Time Corresponding to the NAS from the database ! Thanks again for showing the way. -- View this message in context: http://freeradius.1045715.n5.nabble.com/Enforcing-Login-Time-on-NAS-tp484514... Sent from the FreeRadius - User mailing list archive at Nabble.com.
Update - I've managed to get it working against a custom table in the mysql radius database. The sites-enabled/default authorize section is as below:- update request { Huntgroup-Name := "%{sql:SELECT `groupname` FROM `radhuntgroup` WHERE rtrmac='%{Called-Station-Id}'}" } if ("%{Huntgroup-Name}" != "") { update request{ Tmp-String-0 = "%{sql:SELECT `logintime` FROM `wifihotspots` WHERE hotspotname='%{Huntgroup-Name}'}" } } if ( "%{Tmp-String-0}" != "") { update control{ Login-Time := "%{Tmp-String-0}" } } The wifihotspots table contains Huntgroup-Name and its Corresponding Login-Time Thanks again for the help! -- View this message in context: http://freeradius.1045715.n5.nabble.com/Enforcing-Login-Time-on-NAS-tp484514... Sent from the FreeRadius - User mailing list archive at Nabble.com.
Glad to be of some help !! Cheers On Tue, Sep 27, 2011 at 8:53 PM, shiv <shivkumar.jags@gmail.com> wrote:
Update - I've managed to get it working against a custom table in the mysql radius database. The sites-enabled/default authorize section is as below:-
update request { Huntgroup-Name := "%{sql:SELECT `groupname` FROM `radhuntgroup` WHERE rtrmac='%{Called-Station-Id}'}" }
if ("%{Huntgroup-Name}" != "") { update request{ Tmp-String-0 = "%{sql:SELECT `logintime` FROM `wifihotspots` WHERE hotspotname='%{Huntgroup-Name}'}" } }
if ( "%{Tmp-String-0}" != "") { update control{ Login-Time := "%{Tmp-String-0}" }
}
The wifihotspots table contains Huntgroup-Name and its Corresponding Login-Time Thanks again for the help!
-- View this message in context: http://freeradius.1045715.n5.nabble.com/Enforcing-Login-Time-on-NAS-tp484514... Sent from the FreeRadius - User mailing list archive at Nabble.com. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Why not create a view in the database that joins the two tables? Then you can get the login time in a single query. On 28/09/2011, at 1:23 AM, shiv <shivkumar.jags@gmail.com> wrote:
Update - I've managed to get it working against a custom table in the mysql radius database. The sites-enabled/default authorize section is as below:-
update request { Huntgroup-Name := "%{sql:SELECT `groupname` FROM `radhuntgroup` WHERE rtrmac='%{Called-Station-Id}'}" }
if ("%{Huntgroup-Name}" != "") { update request{ Tmp-String-0 = "%{sql:SELECT `logintime` FROM `wifihotspots` WHERE hotspotname='%{Huntgroup-Name}'}" } }
if ( "%{Tmp-String-0}" != "") { update control{ Login-Time := "%{Tmp-String-0}" }
}
The wifihotspots table contains Huntgroup-Name and its Corresponding Login-Time Thanks again for the help!
-- View this message in context: http://freeradius.1045715.n5.nabble.com/Enforcing-Login-Time-on-NAS-tp484514... Sent from the FreeRadius - User mailing list archive at Nabble.com. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
@Frank: Yes indeed! just goes to show Im not much of a database guy :) Anyways, Ill try that too since Id rather have a single query being fired for each request than multiple ones; which obviously is not efficient. -- View this message in context: http://freeradius.1045715.n5.nabble.com/Enforcing-Login-Time-on-NAS-tp484514... Sent from the FreeRadius - User mailing list archive at Nabble.com.
I tried this, but ran into another basic issue. How to collect the results of an SQL query into an array? for example: Tmp-String-0 = "%{sql:SELECT `logintime`,`hotspotname`,`rtrmac` FROM `hotspotview` WHERE `status`='UP'}" doesnt give me an array. The unlang manual does mention arrays but with this caveat:- /%{Attribute-Name[index]} Reference the N'th occurance of the given attribute. The syntax %{<list>:Attribute-Name[index]} may also be used. The indexes start at zero. This feature is NOT available for non-attribute dynamic translations, like %{sql:...}./ -- View this message in context: http://freeradius.1045715.n5.nabble.com/Enforcing-Login-Time-on-NAS-tp484514... Sent from the FreeRadius - User mailing list archive at Nabble.com.
participants (4)
-
Frank Ranner -
Shiv -
shiv -
Suman Dash