// check which fields are needed $fields = get_fields_from_template($entrytpl); //prepare filter $ldapfilter = _makeldapfilter(); // fetch results $result = ldap_queryabooks($ldapfilter, $fields); $list = ''; if (count($result) == 1 && $_REQUEST['search']) { //only one result on a search -> display page header("Location: entry.php?dn=" . rawurlencode($result[0]['dn'])); exit; } elseif (count($result)) { $keys = array_keys($result); uksort($keys, "_namesort"); foreach ($keys as $key) { tpl_entry($result[$key]); $list .= $smarty->fetch($entrytpl); } } //prepare templates tpl_std(); if (empty($_REQUEST['filter'])) { $_REQUEST['filter'] = ''; } if (empty($_REQUEST['marker'])) { $_REQUEST['marker'] = ''; } if (empty($_REQUEST['search'])) { $_REQUEST['search'] = ''; } $smarty->assign('list', $list);
/** * fetches the Data from the LDAP directory and assigns it to * the global smarty object using tpl_entry() */ function _fetchData($dn) { global $LDAP_CON; global $conf; global $smarty; global $users; //contains the users for manager role $sr = @ldap_search($LDAP_CON, $dn, '(objectClass=inetOrgPerson)'); tpl_ldaperror(); if (!@ldap_count_entries($LDAP_CON, $sr)) { return false; } $result = ldap_get_binentries($LDAP_CON, $sr); $entry = $result[0]; //remove dn from entry when copy if (!empty($_REQUEST['mode']) && $_REQUEST['mode'] == 'copy') { $entry['dn'] = ''; } //assign entry to template: tpl_entry($entry); /*print '<pre>'; print_r($entry); print '</pre>';*/ // make username from dn for manager: if (empty($entry['manager'])) { $entry['manager'] = array(""); } if (empty($users[$entry['manager'][0]])) { $users[$entry['manager'][0]] = ''; } $smarty->assign('managername', $users[$entry['manager'][0]]); return true; }