Replacing calling endpoint

Hello!

I have trunk with lync server that can call through Asterisk. Every lync user has extension number and when lync sends Invite it places this username(extension number) in SIP message. At the moment such calls are defined as calls from trunk and not bound to extensions(based on IP). If i disable auth on endpoint and setup identify to username instead of IP such calls would be reflected as calls from those endpoints e.g. changing device state and other info respectively. My question is can this or something similar be done with auth enabled? So those calls would come from lync trunk but be reflected as calls from specific endpoints based on username in SIP message?

Thanks for any help!

With chan_sip, just define a user for each Lync extension, all using the same secret. I assume something similar is possible with PJSIP.

If you provide an actual SIP trace then it can be determined what to do. As @david551 said it is likely possible with PJSIP as well. For example you can set the authentication on each endpoint, and you can also set endpoint matching so it uses the authentication username to find the endpoint.

Lync trunk doesn’t pass authorization, it has none because it can’t authorize with asterisk with different users. Here is trunk configuration:

[lync]
type=endpoint
transport=transport-tcp
context=from-lync
from_user=mypbx
disallow=all
allow=alaw
aors=lync
send_pai=yes
send_rpid=yes
force_rport=yes
direct_media=no

[lync]
type=aor
qualify_frequency=60
contact=sip:LYNC_IP:5060

[lync]
type=identify
endpoint=lync
match=LYNC_IP

When call comes from lync to Asterisk it sends Invite like this at the moment:

INVITE sip:+102@PBX;user=phone SIP/2.0
FROM: "My name"sip:+101@example.com;user=phone;epid=C178E17545;tag=5ab8f62c55
TO: sip:+102@PBX;user=phone
CSEQ: 88141 INVITE
CALL-ID: 93cfb78a-fae7-4190-b9f8-588f98b233f9
MAX-FORWARDS: 70
VIA: SIP/2.0/TCP LYNC_IP:49394;branch=z9hG4bK5098b1b2
CONTACT: sip:LYNC_SERVER:5060;transport=Tcp;maddr=LYNC_IP;ms-opaque=448182e4ead76c94
CONTENT-LENGTH: 840
SUPPORTED: timer
SUPPORTED: 100rel
USER-AGENT: RTCC/6.0.0.0 MediationServer
CONTENT-TYPE: application/sdp
ALLOW: ACK
Session-Expires: 1800
Min-SE: 90
Allow: CANCEL,BYE,INVITE,PRACK,UPDATE

v=0
o=- 0 0 IN IP4 IP_ADDR
s=session
c=IN IP4 IP_ADDR
b=CT:99980
t=0 0
m=audio 20974 RTP/AVP 117 104 114 9 112 111 0 8 103 116 115 97 13 118 119 101
c=IN IP4 IP_ADDR
a=rtcp:20975
a=label:main-audio
a=rtpmap:117 G722/8000/2
a=rtpmap:104 SILK/16000
a=rtpmap:114 x-msrta/16000

I get username from header(i have endpoint 101 on asterisk):

FROM: "My name"sip:+101@example.com;user=phone;epid=C178E17545;tag=5ab8f62c55

and setup CallerID and other Info but the call itself in asterisk come from lync trunk, so device_state and other information is changed for endpoint lync.
If i setup From header like this:

FROM: "My name"sip:101@example.com;user=phone;epid=C178E17545;tag=5ab8f62c55

and authorization is disabled for endpoint 101 it will be defined in asterisk as endpoint 101 and not lync trunk, so device_state is changed for endpoint 101. The problem is that i actually need authorization for endpoints and they must be protected by passwords so only owner can user his extension with SIP client.

My main goal is to see calls from Lync server(lync trunk) as from endpoints so lync client can use all features in the same way as any SIP client with asterisk and i would be able to see it’s state, real-time calls and other statistics.

I don’t understand - if Lync can’t authenticate, then how can you expect it to… authenticate?

It is not so much authenticate as i would like to know if there is possibility to change source endpoint with dialplan functions? So i authenticate lync trunk, receive call from it and then, in dialplan, change source of a call from lync ednpoint to 101 endpoint.

No, you can’t change or alter what endpoint is in use from the dialplan. You can, however, use the same authentication credentials for every endpoint…

Unfortunately it would be same as have no authorization at all :slight_smile:

Anyway thanks a lot for you time and help!