Hello, I use usermanager interested of the script to retrieve the login, password, service plan, and the date of disconnection, now doing just sending a file to a backup database on your mail, but then move this database to another mikrotik I have not come out, which is interested in the script just might save the data from UserManager the format of:
Note that if you need to fetch several pieces of information at once (even if for a single user), not only can you, but also should, use “print” instead of “get”.
$users = $client->sendSync(new RouterOS\Request('/tool user-manager user print'))->getAllOfType(RouterOS\Response::TYPE_DATA);
foreach ($users as $user) {
$username = $user('name');
$password = $user('password');
$actual_profile = $user('actual-profile');
$last_seen = $user('last-seen');
// Do what you will with each user's data
}
last-seen - this time, to which the user account is valid? My vouchers have time limitations 4w2d, I need the date to which the my vouchers are valid(in user manager i have not found time limit for my vouchers), thank you very much.
No. You have to install PHP on the backup server. You can’t install PHP on RouterOS even if you wanted to.
I thought you said you want it in a backup database (you know, as in MySQL, PostgreSQL, MSSQL, etc.)… in which case, this is the best way to do it.
If you want it in a file that you then email, you’d have to use the “/tool email send” command, and the email will just receive the raw file that you’d then have to manually parse out if you want it in a database. If you instead have an API application, you can skip the file parsing phase, and just directly instert the data into the database, once you’ve fetched it, as above.
No. This is “date of disconnect”, i.e. the time the user is known to have disconnected (either on their own, or because their time was up)… or “dateofdisconnect”, as you said.
If by “date of disconnect” you mean “date I am supposed to be disconnecting this user, because that’s the time they have paid up to” (as you are only NOW implying), you’d want to check the profile of the customer this user is associated with. It’s “start-at” time, plus “validity” will give you the time you’re supposed to disconnect the user.