[SR-Users] Calculate ha1 with mysql trigger

Daniel-Constantin Mierla miconda at gmail.com
Tue May 25 23:04:04 CEST 2010


Hi Ole,

do you know what is the min mysql version required for trigger support?

It is useful, but I am not sure we can add it to db table definition, 
being based on a generic xml specification format. maybe the best for 
now is to add a wiki page for it at:
http://www.kamailio.org/dokuwiki/doku.php

Practical examples is a good section (just add under 'example:' namespace).

Thanks,
Daniel


On 5/18/10 4:21 PM, Ole Kaas wrote:
> Hello,
>
> When editing the subscriber table using phpmyadmin, updating the ha1 fields are no fun and error prone. The trigger below will calculate the hashes if the input fields are left empty. Navigate to the subscriber table in phpmyadmin and drop the code in the query field under the "SQL" tab. Remeber to set the delimiter to //
>
> /Ole
>
> DROP TRIGGER IF EXISTS calcha1 //
> CREATE TRIGGER calcha1 BEFORE INSERT ON subscriber
> FOR EACH ROW
> BEGIN
> IF NEW.ha1 = "" THEN SET NEW.ha1 = MD5(CONCAT(NEW.username,":",NEW.domain,":",NEW.password));
> END IF;
> IF NEW.ha1b = "" THEN SET NEW.ha1b = MD5(CONCAT(NEW.username,"@",NEW.domain,":",NEW.domain,":",NEW.password));
> END IF;
> END//
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
>    

-- 
Daniel-Constantin Mierla
Kamailio (OpenSER) Advanced Training
Miami, Fl, USA - June 21-23, 2010
http://www.asipto.com/index.php/kamailio-advanced-training/




More information about the sr-users mailing list