Asterisk : Setting up PJSIP with LDAP Realtime Driver

  • New LDAP schema integrating PJSIP classes
  • A PJSIP pair is identified by three LDAP classes: AsteriskPjsipAor, AsteriskPjsipAuth and AsteriskPjsipEndpoint whereas a SIP pair requires one LDAP class: AsteriskSIPUser
  • Realtime drivers in PJSIP requires one more configuration file compared to SIP : sorcery.conf

Prerequisites

LDAP side implementation

  • AsteriskPjsipAor: For the Address Of Record class
  • AsteriskPjsipAuth: For the Authentication class
  • AsteriskPjsipEndpoint: For the Endpoint class
# PEERS
dn: cn=101,ou=pjsip,dc=test,dc=local
objectClass: top
objectClass: AsteriskAccount
objectClass: AsteriskPjsipAor
objectClass: AsteriskPjsipAuth
objectClass: AsteriskPjsipEndpoint
cn: 101
AstAccountName: 101
AstAorId: 101
AstAorMaxContacts: 1
AstAuthId: 101
AstAuthType: userpass
AstAuthUsername: 101
AstAuthPassword: 101
AstEndpointId: 101
AstEndpointTransport: transport-udp
AstEndpointAors: 101
AstEndpointAuth: 101
AstEndpointContext: testing
AstEndpointDisallow: all
AstEndpointAllow: g722;alaw
AstEndpointDirectMedia: no

dn: cn=102,ou=pjsip,dc=test,dc=local
objectClass: top
objectClass: AsteriskAccount
objectClass: AsteriskPjsipAor
objectClass: AsteriskPjsipAuth
objectClass: AsteriskPjsipEndpoint
cn: 102
AstAccountName: 102
AstAorId: 102
AstAorMaxContacts: 1
AstAuthId: 102
AstAuthType: userpass
AstAuthUsername: 102
AstAuthPassword: 102
AstEndpointId: 102
AstEndpointTransport: transport-udp
AstEndpointAors: 102
AstEndpointAuth: 102
AstEndpointContext: testing
AstEndpointDisallow: all
AstEndpointAllow: g722;alaw
AstEndpointDirectMedia: no

Asterisk side implementation

preload => res_config_ldap.so

Realtime LDAP Driver Settings

[_general]
host=127.0.0.1
port=389
protocol=3
basedn=dc=test,dc=local
user=cn=admin,dc=test,dc=local
pass=password
rasterisk
asterisk*CLI> core restart now
rasterisk
asterisk*CLI> realtime show ldap status
Connected to 'ldap://127.0.0.1:389', baseDN dc=test,dc=local with username cn=admin,dc=test,dc=local for 15 seconds.
[_general]
host=127.0.0.1
port=389
protocol=3
basedn=dc=test,dc=local
user=cn=admin,dc=test,dc=local
pass=password
[ps_aors]
id=AstAorId
max_contacts=AstAorMaxContacts
[ps_auths]
id=AstAuthId
auth_type=AstAuthType
username=AstAuthUsername
password=AstAuthPassword
[ps_endpoints]
id=AstEndpointId
transport=AstEndpointTransport
aors=AstEndpointAors
auth=AstEndpointAuth
context=AstEndpointContext
disallow=AstEndpointDisallow
allow=AstEndpointAllow
direct_media=AstEndpointDirectMedia

Configure the realtime driver for LDAP

[settings]
ps_endpoints => ldap,"ou=pjsip,dc=test,dc=local",ps_endpoints
ps_auths => ldap,"ou=pjsip,dc=test,dc=local",ps_auths
ps_aors => ldap,"ou=pjsip,dc=test,dc=local",ps_aors

Bind the Realtime Driver

[test_sorcery_section]
test=memory
[test_sorcery_cache]
test/cache=test
test=memory
[res_pjsip]
endpoint=realtime,ps_endpoints
auth=realtime,ps_auths
aor=realtime,ps_aors
asterisk*CLI> core restart now
asterisk*CLI> pjsip show endpoints
Endpoint: 101 Unavailable 0 of inf
InAuth: 101/101
Aor: 101 1
Transport: transport-udp udp 0 0 0.0.0.0:5060
Endpoint: 102 Unavailable 0 of inf
InAuth: 102/102
Aor: 102 1
Transport: transport-udp udp 0 0 0.0.0.0:5060
Objects found: 2

Combine Realtime Driver with pjsip.conf

[res_pjsip]
endpoint=config,pjsip.conf,criteria=type=endpoint
endpoint=realtime,ps_endpoints
auth=config,pjsip.conf,criteria=type=auth
auth=realtime,ps_auths
aor=config,pjsip.conf,criteria=type=aor
aor=realtime,ps_aors
asterisk*CLI> module reload
asterisk*CLI> pjsip show endpoints
Endpoint: 101 Unavailable 0 of inf
InAuth: 101/101
Aor: 101 1
Transport: transport-udp udp 0 0 0.0.0.0:5060
Endpoint: 102 Unavailable 0 of inf
InAuth: 102/102
Aor: 102 1
Transport: transport-udp udp 0 0 0.0.0.0:5060
Endpoint: 201/201 Unavailable 0 of inf
InAuth: 201/201
Aor: 201 1
Transport: transport-udp udp 0 0 0.0.0.0:5060
Objects found: 3

TroubleShooting

“realtime show ldap status” failed

basedn= dc=test,dc=local ; My base DN
basedn=dc=test,dc=local

“pjsip show endpoints” does not return LDAP endpoints

[ps_aors]
id=AstAorId
max_contacts=AstAorMaxContacts
[ps_auths]
id=AstAorId
auth_type=userpass
username=AstAuthUsername
password=AstAuthPassword
[ps_aors]
id=AstAorId
max_contacts=AstAorMaxContacts
[ps_auths]
id=AstAuthId
auth_type=AstAuthType
username=AstAuthUsername
password=AstAuthPassword

Conclusion

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Transferring data from MySQL to MsSQL DataBase

Dealing with Reliability Related Uncertainty

Install OpenJDK 11 LTS in the Ubuntu 20.04 LTS

Go: How to Mitigate RUDY DoS Attack

Java Abstraction

PDX 31th bi-weekly report (Oct13th-Oct 25th)

Python Skills - 7 Ways To Take Them to The Next Level

hasura: GraphQL error: invalid input syntax for type timestamp with time zone: “{a number}”]

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Xavier Brassoud

Xavier Brassoud

More from Medium

Deploying Micro Frontends to AWS Step by Step Using React, Webpack 5, and Module Federation

How to Install Apache Web Server on CentOS 8.

Want to auto-retry a failing request in postman based on a set number of max tries and with a…

Serverless Monitoring Tool for AWS Lambda Functions