Padlock an extension

On our existing Alcatel system a few analog users (due to location) ‘padlock’ their phone. Their extension is fully functional during the day however when they finish (which varies so can’t use time conditions) they enter a * code that locks the line. It bars the extension from making any outgoing calls (internal and external) apart from the usual emergency numbers. When they enter their * code plus a pin it unlocks and becomes a fully functional extension again

We need this functionality with some of our extensions on Asterisk

Can anyone advise on the best way to achieve this?

I’m thinking making a custom script that puts the extension into a restrictive context (set up via the Custom Contexts module) but not too sure on how to do this as I don’t think it’s as as simple as setting a flag in the database…or is it?

The extension can still receive when padlocked, it’s only outgoing that needs to be restricted (by the user). The extensions in question are analog fed via a Cisco VG224. IP endpoint is not possible.

I’ve found this (it’s describing my situation almost 100%) however I can’t get it to work, perhaps as it’s for 1.4 and the coding is different for 11

I’m running the latest stable 64-bit FPBX with Asterisk 11 fully patched

http://www.freepbx.org/support/documentation/howtos/how-to-lock-and-unlock-an-extension-using-a-passcode-example-of-setting

Any advice would be greatly appreciated

What is not working? A call trace would be helpful.

Hi Alan

Sorry for being vague.

I can follow the prompts to aparantely lock the extension but once set I can still make calls as if nothings set. Making the call afterwords the trace is just like a normal call but the trace below is setting the extension to ‘lock’ which seems to do what it says on the tin correctly, I’m thinking it’s something to do with the DB AMPUSER line that’s wrong for Asterisk 11

I’ve just spotted the part where it says I need to put the extension into custom-checklock context however it does not say how to do that. Can that be done with the Custom Contexts module?

  == Using SIP RTP TOS bits 184
  == Using SIP RTP CoS mark 5
    -- Executing [*77@restricted-group-6:1] NoOp("SIP/5004-00002475", "Running miscapp 35: Padlock Ext") in new stack
    -- Executing [*77@restricted-group-6:2] Macro("SIP/5004-00002475", "user-callerid,") in new stack
    -- Executing [s@macro-user-callerid:1] Set("SIP/5004-00002475", "TOUCH_MONITOR=1413818084.25178") in new stack
    -- Executing [s@macro-user-callerid:2] Set("SIP/5004-00002475", "AMPUSER=5004") in new stack
    -- Executing [s@macro-user-callerid:3] GotoIf("SIP/5004-00002475", "0?report") in new stack
    -- Executing [s@macro-user-callerid:4] ExecIf("SIP/5004-00002475", "1?Set(REALCALLERIDNUM=5004)") in new stack
    -- Executing [s@macro-user-callerid:5] Set("SIP/5004-00002475", "AMPUSER=5004") in new stack
    -- Executing [s@macro-user-callerid:6] GotoIf("SIP/5004-00002475", "0?limit") in new stack
    -- Executing [s@macro-user-callerid:7] Set("SIP/5004-00002475", "AMPUSERCIDNAME=IT Workshop") in new stack
    -- Executing [s@macro-user-callerid:8] GotoIf("SIP/5004-00002475", "0?report") in new stack
    -- Executing [s@macro-user-callerid:9] Set("SIP/5004-00002475", "AMPUSERCID=5004") in new stack
    -- Executing [s@macro-user-callerid:10] Set("SIP/5004-00002475", "__DIAL_OPTIONS=trw") in new stack
    -- Executing [s@macro-user-callerid:11] Set("SIP/5004-00002475", "CALLERID(all)="IT Workshop" <5004>") in new stack
    -- Executing [s@macro-user-callerid:12] GotoIf("SIP/5004-00002475", "0?limit") in new stack
    -- Executing [s@macro-user-callerid:13] ExecIf("SIP/5004-00002475", "0?Set(GROUP(concurrency_limit)=5004)") in new stack
    -- Executing [s@macro-user-callerid:14] GosubIf("SIP/5004-00002475", "7?sub-ccss,s,1(restricted-group-6,*77)") in new stack
    -- Executing [s@sub-ccss:1] ExecIf("SIP/5004-00002475", "0?Return()") in new stack
    -- Executing [s@sub-ccss:2] Set("SIP/5004-00002475", "CCSS_SETUP=TRUE") in new stack
    -- Executing [s@sub-ccss:3] GosubIf("SIP/5004-00002475", "0?monitor_config,1(restricted-group-6,*77):monitor_default,1(restricted-group-6,*77)") in new stack
    -- Executing [monitor_default@sub-ccss:1] GotoIf("SIP/5004-00002475", "0?is_exten") in new stack
    -- Executing [monitor_default@sub-ccss:2] StackPop("SIP/5004-00002475", "") in new stack
    -- Executing [monitor_default@sub-ccss:3] Return("SIP/5004-00002475", "FALSE") in new stack
    -- Executing [s@macro-user-callerid:15] ExecIf("SIP/5004-00002475", "0?Set(CHANNEL(language)=)") in new stack
    -- Executing [s@macro-user-callerid:16] GotoIf("SIP/5004-00002475", "0?continue") in new stack
    -- Executing [s@macro-user-callerid:17] ExecIf("SIP/5004-00002475", "1?Set(__CALLEE_ACCOUNCODE=)") in new stack
    -- Executing [s@macro-user-callerid:18] Set("SIP/5004-00002475", "__TTL=64") in new stack
    -- Executing [s@macro-user-callerid:19] GotoIf("SIP/5004-00002475", "1?continue") in new stack
    -- Goto (macro-user-callerid,s,30)
    -- Executing [s@macro-user-callerid:30] Set("SIP/5004-00002475", "CALLERID(number)=5004") in new stack
    -- Executing [s@macro-user-callerid:31] Set("SIP/5004-00002475", "CALLERID(name)=IT Workshop") in new stack
    -- Executing [s@macro-user-callerid:32] Set("SIP/5004-00002475", "CDR(cnum)=5004") in new stack
    -- Executing [s@macro-user-callerid:33] Set("SIP/5004-00002475", "CDR(cnam)=IT Workshop") in new stack
    -- Executing [s@macro-user-callerid:34] Set("SIP/5004-00002475", "CHANNEL(language)=en") in new stack
    -- Executing [*77@restricted-group-6:3] Goto("SIP/5004-00002475", "custom-setlock,s,1") in new stack
    -- Goto (custom-setlock,s,1)
    -- Executing [s@custom-setlock:1] NoOp("SIP/5004-00002475", "In Set Lock") in new stack
    -- Executing [s@custom-setlock:2] Read("SIP/5004-00002475", "PIN1,vm-password,,,,") in new stack
    -- <SIP/5004-00002475> Playing 'vm-password.alaw' (language 'en')
    -- User entered '5432'
    -- Executing [s@custom-setlock:3] Read("SIP/5004-00002475", "PIN2,vm-password,,,,") in new stack
    -- <SIP/5004-00002475> Playing 'vm-password.alaw' (language 'en')
    -- User entered '5432'
    -- Executing [s@custom-setlock:4] GotoIf("SIP/5004-00002475", "1?okey") in new stack
    -- Goto (custom-setlock,s,7)
    -- Executing [s@custom-setlock:7] Set("SIP/5004-00002475", "DB(AMPUSER/5004/locked)=5432") in new stack
    -- Executing [s@custom-setlock:8] Playback("SIP/5004-00002475", "vm-goodbye") in new stack
    -- <SIP/5004-00002475> Playing 'vm-goodbye.alaw' (language 'en')
    -- Executing [s@custom-setlock:9] Hangup("SIP/5004-00002475", "") in new stack
  == Spawn extension (custom-setlock, s, 9) exited non-zero on 'SIP/5004-00002475'
    -- Executing [h@custom-setlock:1] Hangup("SIP/5004-00002475", "") in new stack
  == Spawn extension (custom-setlock, h, 1) exited non-zero on 'SIP/5004-00002475'