How to control calls between contexts

I recently added a second context to my Asterisk, and was able to figure out how to “transfer” a call from a member of one context to a member of the other. I just use Goto:

[internal] exten => 6000,1,Goto(othergroup,6000,1)

This approach, however is too generic. I would like to have a more fine grained rule. I need to allow only some specific dialers to cross the intercontext barrier.

A related question is how to have the ability of assigning the same extension numbers to user in different contexts. Is there support for some sort of virtual PBX or namespace in Asterisk?



Answer for 1st question-

to transfer call from 1 context to other . i will suggest use Features.conf
for diffrent transfer application

aslo to make call in other context extension you have to add second context in first one

exten => 6000,1,Goto(othergroup,6000,1)
include=> internal-2

exten => 6000,1,dail(SIP/113,t)
here small t for tranfer calls. to block some user in first context to call at user of other contex.
to avoid this u wrote this line b4 dailing actual extension in context 2
exten => 6000,1,GotoIf($[${EXTEN} = 312]?yes:no)
exten => 6000,n(yes),hangup
in this we block calling of user 312 in context 1 to dail number in context
2 if you want to same extension number to both of the context it is possible but both context name sud be diffrent .
i am not try this but my knowldge in Asterisk says this