powered by Jive Software

Adding users in a scritable way

Hi!

Is there a way for add users from a script. Something like the “User Service” plugin, that allows to add/del users via http requests.

Thank you,

Tom Lobato

Message was edited by: tomlobato

hi!

well, I found a way: adding records directly to the mysql tables. The script below assumes that there is the file user_list in the same directory, with lines such…

user1 extension_num1

user2 extension_num2

.

.


#!/bin/bash

uid=1

did=2

IFS=$’’\n’’

for line in cat users_list; do

user=$(echo $line|cut -d ‘’ ‘’ -f 1)

ext=$(echo $line|cut -d ‘’ ‘’ -f 2)

echo “$user $ext”

echo “INSERT INTO phoneUser values ($uid,’’$user’’)” |mysql -u root --password=’‘yourpass’’ openfire

echo “INSERT INTO phoneDevice values ($did,’‘SIP/$user’’,’’$ext’’,NULL,1,$uid,1)” | mysql -u root --password=’‘yourpass’’ openfire

let uid=uid+2

let did=did+2

done


but if someone knows a better method, please tell me.

Tom Lobato

The ‘‘proper’’ way would probably involve using Smack (or another XMPP library), logging into the server, and using AccountManager.createAccount

Using Smack to create phone mappings won’'t work.

Of course one could add some kind of web service like the user management plugin but I doubt this has a business case, so direct INSERTs are a bit dirty but very reasonable.

If anything I would like to invest effort into dynamically retrieving phone mappings from VCARD/LDAP/… - if there is enough interest.

I’'d really like being able to add user mappings from the Custom Database Integration method. We use this method to get our users from our CRM which also knows all of their extensions.

The Issue Tracker currently shows this type of functionality as having the most votes too (in the Asterisk-IM project).

http://www.igniterealtime.org/issues/browse/PHONE-56

Do you have the channel names in the database (e.g. SIP/1234, IAX2/username) or do you need addtional mappings to derive the channel name from the value in your database?

We have the user’‘s SIP extension without the channel. So if a user’'s channel is SIP/7669, we have 7669 stored in the CRM database. In our particular set up, we only use SIP for extensions, but three other channel types for trunks.

Ok i’'ll see we get PHONE-56 into the next release