Check if SIP user exists

I need to check if a SIP, IAX or H323 user exists before dialing this user.

If it does not exist, caller will receive a message like ‘you’ve dialed a non-existent extension, try another number’.

I found a solution for this to query database (I have users in mysql) against user, but I guess this is too complicated, there should be some normal way to do this, which I couldn’t find yet… :frowning:

ya easy way this just use ast db, bec its so simple as compared to mysql.
just save all sip users record like

put database sip sipname yes

if sip 100==yes

go to wht u want else IVR not listed like that

regards,

[b]Jehanzaib Younis
IPT Engineer

+92.111.874.874 Ext: 2558
+92.321.5139853
jehanzaib.younis@trgcustomersolutions.com
trgcustomersolutions.com[/b]

zaib_kiani
Thanks for your response

AstDB is an idea, but I am going to write a php script for adding/removing/chaning users and to do some other things, so communicating to AstDB through php is not possible as I understand. or it is? :unamused:

It is, through AGI (Asterisk gateway interface), check the section “AGI commands” here: voip-info.org/wiki-Asterisk+AGI .

Regards.

i am not using AGI in my dialplan, found it complicated, long and useless for my purposes :smile:

There is MailBoxExists() application, which returns True or False for given mailbox, I need something similar for extensions.

Hi

Doesnt voip-info.org/wiki/index.php … hanIsAvail do what you want ?

Ian

ianplain
Hey, many thanks, I guess that’s it :smile:

I’ve just went through it’s description and ${AVAILSTATUS}=AST_DEVICE_INVALID seems to be what I need.

Will check in action soon and post result.

[quote=“georgy”]ianplain

Will check in action soon and post result.[/quote]

And ? :unamused:

Doesn’t work as intended.

_XXX => { Answer; ChanIsAvail(SIP/${EXTEN}); NoOp(${AVAILSTATUS}); HangUp; };

Existant extension:

dial 200 == Console is full duplex -- Executing [200@default:1] Answer("OSS/dsp", "") in new stack << Console call has been answered >> -- Executing [200@default:2] ChanIsAvail("OSS/dsp", "SIP/200") in new stack -- Executing [200@default:3] NoOp("OSS/dsp", "3) in new stack -- Executing [200@default:4] Hangup("OSS/dsp", "") in new stack == Spawn extension (default, 200, 4) exited non-zero on 'OSS/dsp' << Hangup on console >>

Non-existant extension:

dial 201 == Console is full duplex -- Executing [201@default:1] Answer("OSS/dsp", "") in new stack << Console call has been answered >> -- Executing [201@default:2] ChanIsAvail("OSS/dsp", "SIP/201") in new stack [Jul 8 08:43:02] WARNING[3702]: chan_sip.c:2738 create_addr: No such host: 201 -- Executing [201@default:3] NoOp("OSS/dsp", "3") in new stack -- Executing [201@default:4] Hangup("OSS/dsp", "") in new stack == Spawn extension (default, 201, 4) exited non-zero on 'OSS/dsp' << Hangup on console >>

Returns 3 all the time. According to ChanIsAvail manual, 3 for ${AVAILSTATUS} should be AST_DEVICE_BUSY - “Busy”; channel is busy, but that status doesn’t make sense for both unregistered and non-existant extensions.