zenlord Posted January 4, 2010 Share Posted January 4, 2010 Hi, First post on the forums. I am a self-thought PHP-coder and after some relatively simple websites I'm currently building a intranet-website to interconnect several of the services we're using in our 3-people-office. This time I'm stuck connecting the asterisk-call-data-records to our ldap-addressbook. I would like to show the name of the person that has called our office. This is my code: function TBS_tel($BlockName,&$CurrRec,$RecNum){ // 1. Extraheer ID van het toestel waarmee getelefoneerd werd $CurrRec['src_dev_id'] = substr($CurrRec['channel'],4,3); $CurrRec['dst_dev_id'] = substr($CurrRec['dstchannel'],4,3); // 2. Haal de persoonsgegevens uit de LDAP-dir // Persoonsgegevens zoeken $notNumbers = array(".", "/", ":", " ", "-"); if ($CurrRec['dcontext'] == "internal") { // Zoeken op dst: $tel = str_replace($notNumbers, "", $CurrRec['dst']); } else { // Zoeken op src: $tel = str_replace($notNumbers, "", $CurrRec['src']); } [b]$filter = "(|(mobile=$tel)(Phone=$tel)(homePhone=$tel))";[/b] $attributes = array("sn", "givenName", "dn", "title", "o"); $result = ldap_search(CNX_LDAP, LDAP_DIR_ADR, $filter, $attributes); $persID = ldap_get_entries(CNX_LDAP, $result); $CurrRec['pers_id'] = $persID[0]["title"][0]; $CurrRec['pers_id'] .= " "; $CurrRec['pers_id'] .= $persID[0]["givenname"][0]; $CurrRec['pers_id'] .= " <a href=\"link.php?dn="; $CurrRec['pers_id'] .= urlencode($persID[0]["dn"]); $CurrRec['pers_id'] .= "\">"; $CurrRec['pers_id'] .= $persID[0]["sn"][0]; $CurrRec['pers_id'] .= "</a>"; if ($persID[0][2]) { $CurrRec['pers_id'] .= "<br /><a href=\"link.php?org="; $CurrRec['pers_id'] .= urlencode($persID[0]["o"][0]); $CurrRec['pers_id'] .= "\">"; $CurrRec['pers_id'] .= $persID[0]["o"][0]."</a>"; } ldap_free_result($result); } This code is working, but not completely: everytime $tel is equal to a mobile number, then it outputs the requested data. But if we are called by someone with a number that is in 'Phone' or 'homePhone', than the result is blank. I have tried to ditch the capitals in 'Phone', I have tried to remove the (mobile=$tel)-filter, but to no effect. My guess is that the bug is situated on the bold line of my code. Am I overlooking something silly here? Thank you in advance... Quote Link to comment Share on other sites More sharing options...
zenlord Posted January 6, 2010 Author Share Posted January 6, 2010 OK, I found the problem myself. Seems like I was mislead by phpldapadmin. Phpldapadmin showed the values of the attribute 'telephoneNumber' under (probably an alias) 'Phone'. Of course PHP doesn't know the attribute 'Phone'. So: if an LDAP-filter doesn't return the expected values, check the relevant RFC's. The one for inetOrgPerson can be found here: http://www.rfc-archive.org/getrfc.php?rfc=2798 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.