Hi guys! I ran into the same problem a good while ago and it took me a while to figure it out. I must admit that I have only tried this method with Snom phones and not Yealink so you may have to look up manufacturers info if it will work with them.
I use sipsak and have custom coded the macro-user-logon and macro-user-logoff which alters the display to show the users name and extension. The only problem that this method has, is that it will not survive a power off situation in which the phone restarts and the display will return to what the phone’s initial SIP account settings are.
You can see the use the TrySystem command that uses local sipsak command to change display. The IP address is the actual Asterisk box.
Hope this helps in some way as it took me ages to figure as I’m not much of a coder
You need to modify the extensions_custom.conf file so that it overrides what is in the normal extensions.conf. The code also relies on your Users “Display Name” being their first name and then their Surname.
[macro-user-logon]
; check device type
;
exten => s,1,Set(DEVICETYPE=${DB(DEVICE/${CALLERID(number)}/type)})
exten => s,n,Answer()
exten => s,n,Wait(1)
exten => s,n,GotoIf($["${DEVICETYPE}" = "fixed"]?s-FIXED,1)
; get user's extension
;
exten => s,n,Set(AMPUSER=${ARG1})
exten => s,n,GotoIf($["${AMPUSER}" != ""]?gotpass)
exten => s,n,Read(AMPUSER,please-enter-your-extension-then-press-pound,,,4)
; get user's password and authenticate
;
exten => s,n,GotoIf($["${AMPUSER}" = ""]?s-MAXATTEMPTS,1)
exten => s,n(gotpass),GotoIf($["${DB_EXISTS(AMPUSER/${AMPUSER}/password)}" = "0"]?s-NOUSER,1)
exten => s,n,Set(AMPUSERPASS=${DB_RESULT})
exten => s,n,GotoIf($[${LEN(${AMPUSERPASS})} = 0]?s-NOPASSWORD,1)
; do not continue if the user has already logged onto this device
;
exten => s,n,Set(DEVICEUSER=${DB(DEVICE/${CALLERID(number)}/user)})
exten => s,n,GotoIf($["${DEVICEUSER}" = "${AMPUSER}"]?s-ALREADYLOGGEDON,1)
exten => s,n,Authenticate(${AMPUSERPASS})
exten => s,n,DeadAGI(user_login_out.agi,login,${CALLERID(number)},${AMPUSER})
exten => s,n,Set(PhoneName=${DB(AMPUSER/${AMPUSER}/cidname)})
exten => s,n,Set(FirstName=${CUT(PhoneName, ,1)})
exten => s,n,Set(Surname=${CUT(PhoneName, ,2)})
exten => s,n,Set(FirstLetter=${Surname:0:1}
exten => s,n,Set(RealExten=${DB(AMPUSER/${AMPUSER}/cidnum)})
exten => s,n,TrySystem(/usr/local/bin/sipsak -i -H 192.168.2.60 -M -B "${FirstName}${FirstLetter} ${RealExten}" -s ${SIPURI})
exten => s,n,Playback(roaming&user&enabled&vm-goodbye)
exten => s-FIXED,1,NoOp(Device is FIXED and cannot be logged into)
exten => s-FIXED,n,Playback(custom/roaminginvalid&vm-goodbye)
exten => s-FIXED,n,Hangup ;TODO should play msg indicated device cannot be logged into
exten => s-ALREADYLOGGEDON,1,NoOp(This device has already been logged into by this user)
exten => s-ALREADYLOGGEDON,n,Playback(vm-goodbye)
exten => s-ALREADYLOGGEDON,n,Hangup ;TODO should play msg indicated device is already logged into
exten => s-NOPASSWORD,1,NoOp(This extension does not exist or no password is set)
exten => s-NOPASSWORD,n,Playback(pbx-invalid)
exten => s-NOPASSWORD,n,Goto(s,playagain)
exten => s-MAXATTEMPTS,1,NoOp(Too many login attempts)
exten => s-MAXATTEMPTS,n,Playback(vm-goodbye)
exten => s-MAXATTEMPTS,n,Hangup
exten => s-NOUSER,1,NoOp(Invalid extension ${AMPUSER} entered)
exten => s-NOUSER,n,Playback(pbx-invalid)
exten => s-NOUSER,n,Goto(s,playagain)
[macro-user-logoff]
; check device type
;
exten => s,1,Set(DEVICETYPE=${DB(DEVICE/${CALLERID(number)}/type)})
exten => s,n,GotoIf($["${DEVICETYPE}" = “fixed”]?s-FIXED,1)
exten => s,n,DeadAGI(user_login_out.agi,logout,${CALLERID(number)})
exten => s,n,TrySystem(/usr/local/bin/sipsak -i -H 192.168.2.60 -M -B “” -s ${SIPURI})
exten => s,n(done),Playback(roaming&user&disabled&vm-goodbye)
exten => s-FIXED,1,NoOp(Device is FIXED and cannot be logged out of)
exten => s-FIXED,n,Playback(an-error-has-occured&vm-goodbye)
exten => s-FIXED,n,Hangup ;TODO should play msg indicated device cannot be logged into