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.
https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Virus-free. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
On Wed, Dec 20, 2017 at 04:45:07PM +0530, Arun NV wrote:
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*.
ha1 and ha1b aren't needed. But you question has been asked in the past and even been answered: https://lists.kamailio.org/pipermail/sr-users/2010-May/063982.html
On 21.12.17 10:34, Daniel Tryba wrote:
On Wed, Dec 20, 2017 at 04:45:07PM +0530, Arun NV wrote:
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*.
ha1 and ha1b aren't needed. But you question has been asked in the past and even been answered: https://lists.kamailio.org/pipermail/sr-users/2010-May/063982.html
Siremis has the code to get ha1 and ha1b in PHP:
- https://github.com/asipto/siremis/blob/master/siremis/modules/sipadmin/sbs/a...
The keys of recArr should be self explanatory, however, if the realm is not the same as domain, then repalce the domain field with realm value.
Cheers, Daniel