Command to disconnect all logged on users?
-
Hello,
I have a setup where multiple users are logging in on active portal using the same username created with Local User Manager.
The password for this account will be changed daily at midnight, and at that time I need to disconnect all the users who are currently logged on with the old password.I have not been able to find any command line or GUI way of doing this, other than going to Status > Captive Portal and manually disconnecting each client one at a time. This is something that needs to be run automatically daily and therefor not something that can be done manually. Is there any command line way of doing this that can be incorporated into the script I have that changes password?
-
Hmm… and why don't you just set up vouchers valid for one day?
-
Hmm… and why don't you just set up vouchers valid for one day?
Because I found no information that said that multiple users can be logged in with the same voucher code. The wish from the client is that everyone uses the same password and that this password is changed daily. They also want a captive portal with guidelines etc.
If this is doable with vouchers I could go that route.
-
@AB:
….
I have not been able to find any command line or GUI way of doing this, other than going to Status > Captive Portal and manually disconnecting each client one at a time. This is something that needs to be run automatically daily and therefor not something that can be done manually. Is there any command line way of doing this that can be incorporated into the script I have that changes password?
When you use the Status > Captive Portal page, a list is shown with logged in users.
Have a look at the PHP code that maks this list, as you we see, it's rather simple. A couple of lines using PHP makes this list. Add one line more that logs out every user it finds and your are nearly there.
Make a cron task that runs you PHP script at midnight, and you're ok. -
Yes, multiple users can log in with a single voucher (Allow concurrent logins I think.) Or you can limit it to one. What you cannot do is limit it to, say, 10.
If you have to kick everyone off, manually expire the voucher.
-
Hi,
I had the same requirement and did little coding, which worked in 2.1 through cron. But, after upgrading to 2.2.2, if I run this code it gives error; Failed setsockopt.
I do not know where to check! Code is below;
##|+PRIV ##|*IDENT=page-status-captiveportal ##|*NAME=Status: Captive portal page ##|*DESCR=Allow access to the 'Status: Captive portal' page. ##|*MATCH=status_captiveportal.php* ##|-PRIV require("captiveportal.inc"); $cpzone = "wifi"; ?> flush(); function clientcmp($a, $b) { global $order; return strcmp($a[$order], $b[$order]); } if (!empty($cpzone)) { $cpdb = captiveportal_read_db(); } // Load MAC-Manufacturer table $mac_man = load_mac_manufacturer_table(); foreach ($cpdb as $cpent): //echo $cpent[2]." - ".$cpent[3]." - ". $cpent[4]." - ".$cpent[0]." - ".$cpent[5]; //echo "Disconnecting...".$cpent[2]."-". $cpent[4]." "; captiveportal_disconnect_client($cpent[5]); endforeach; ?>
-
This snippet will disconnect ALL users from ALL zones (more then one can exist) :
require("captiveportal.inc"); if (!is_array($config['captiveportal'])) { $config['captiveportal'] = array(); } $a_cp =& $config['captiveportal']; foreach ($a_cp as $captiveportalzone) { // set $cp_zone so the correct database will use used $cpzone = $captiveportalzone['zone']; // also surface the global $cpzoneid $cpzoneid = $captiveportalzone['zoneid']; // Read the corresponding database $cpdb = captiveportal_read_db(); foreach ($cpdb as $cpent) { captiveportal_disconnect_client($cpent[5]); } unset($cpdb); } unset($a_cp); ?>
Place this PHP file in … /root/zzz.php
Execute it like this:
/usr/local/bin/php -q /root/zzz.php
Be carefull : running it WILL disconnect all users from the command line (wasn't this something that many were asking on this forum ??)
Up to you to put it in a cron which executes it at midnight.
-
Thank you Gertjan,
Your code disconnected all users without error, when executed from the command line.
Made the entry in cron. Thank you.
-
….
if I run this code it gives error; Failed setsockopt.Somewhere, deep down in /etc/inc/captiveportal.inc, the global variable "$cpzoneid" needs to have a valid value - related and like "$cpzone".
This part is handling that one:// also surface the global $cpzoneid $cpzoneid = $captiveportalzone['zoneid'];