There is a requirement to add a new user to Kamailio programmatically using PHP. I tried to add username and password to subscriber table manually using SQL queries, but it won't works because ha1 and ha1b should be added to the table. I don't know how Kamailio generate ha1 and ha1b. Following are the manually added entries using kamctl tool.

mysql> select * from subscriber limit 2;
+----+----------+---------------+--------------+---------------+----------------------------------+----------------------------------+------+
| id | username | domain        | password     | email_address | ha1                              | ha1b                             | rpid |
+----+----------+---------------+--------------+---------------+----------------------------------+----------------------------------+------+
|  9 | 1010101  | 10.101.101.10 | aswwwwwwwsdf |               | a37d1785953310c206481ca1a33f16b6 | 7e981130f05a547a738d3c29031e89d0 | NULL |
| 10 | 1010102  | 10.101.101.10 | 6eeeeee8a72  |               | 6b574f9047206481ca1a33501d7dbdce | cd9a8b89d926f3cb1290311a8cb8a2a8 | NULL |
+----+----------+---------------+--------------+---------------+----------------------------------+----------------------------------+------+

Then I tried with shell_exec function in PHP to use kamctl command(kamctl add username password). but it will prompt for Kamailio read-write user's password. So following command cannot add new users to Kamailio

$res = shell_exec("sudo kamctl add new_username new_password);   

so, please suggest a way to add new user's to Kamailio programmatically.


Virus-free. www.avast.com