I have a strong need to create extensions and manage secrets outside the FreePBX GUI. We have an in-house built user management system where we store user information/passwords, etc. We need a way to create new extensions using existing user/passwords from our custom system, or change existing passwords. We don’t want to have to move back and forth between multiple systems to do something as simple (from a user standpoint) as adding a user and assigning an extension.
I’ve been looking and find nothing but similar questions with little or no response. This single issue (changes outside of the GUI) renders FreePBX and asterisk in general as a poor choice, at least for us. I don’t want to have to start over with FreeSwitch.
You will need to populate appropriately these mysql database tables, sip (or other technology) , devices and users, also populate the asterisk database with AMPUSER (extension)/*.
Use a working extension to extract exactly what is needed for that template.
Can you leverage PHP scripting? If so we can provide examples but you didn’t state how you want to interact with FreePBX. In fact you gave no details and instead posted an idle threat at the end.
Sorry for the lack of info. My first choice would be a web service since FreePBX would be external to our main admin site, which is .NET. The admin site would need to fire a request off to the offsite FreePBX location to handle the update. I could set the update to run from any server on that network. PHP is a definite possibility.
Not looking to punish anyone, just want to get this to work.
Since FreePBX is OpenSource you can go look at the simple PHP code in core and see how we add and remove users. Its not overly complicated and lots of it is in functions.
You’ll have to go with PHP. you can easily create PHP hooks (RESTFUL) if you wish. It’s not a hard thing to do. As tony mentioned I would go look at core/functions.inc.php the code to add and remove users is right there. I will give you more information as time permits. Right now I’m pretty swamped. But I don’t think you’d find it any easier in the freeswitch world…
Thanks for the help here. I did find a script that has the ability to update the extension, but when I run it I get “No direct script access allowed”. I’ve tried placing the code in the html and admin folder with the same results. I got the code from here http://samyantoun.50webs.com/asterisk/freepbx/createext.php.txt.
Sorry for acting like a newbie, but that’s what I am.
It’s all dev at this point so not a real issue. But I appreciate the message. I’d never do that on a production box.
Thanks for the code. I’ll test it out and let you know. I really appreciate your help here. If you know of any good books in this area I’d like to do some reading instead of blind key presses.
I’m still having newbie issues here. I take the script shown above and load into a php file or html for that matter. I execute that file using localhost and I get ‘No direct script access allowed’. Are there permissions I need to set or do I need to execute this in a different manner.
Where are you running it from? This is not something you can just blindly run from the web browser. It’s a command line orientated script to be run outside of the html directory.
I would like to initiate the script using a web request, hopefully not blindly. This will be initiated from a web site with a call to the FreePBX system to add the extension. Whatever means is best suited to do this I am open to. This update would only be allowed from a single IP with credentials. I understand the importance of limited access here. The important thing is to have the extension/user data added from a remote site in a background operation.
I can run it successfully from terminal if I place it anywhere other than html. But I need to fire the script using http from a remote site. Yeah, I know, I’m a Windows guy trying something new.
Not an AD account. We built a management system for a call center where the user and extension are created within this management system. I’d like to update the PBX with this user and extension remotely.
Once added, I was able to run the script with no errors. I also had to add “pinless” => “disabled” to get around another state error.
The issue I’m having now is with the password. I’m including “password” => “testpw123” in the array. the password is added correctly to the users table. But the secret in the GUI appears to be an auto generated pw. I looked in the sip table and there is no secret set. Should the script use core_devices_add or core_devices_addsip?