*/ $dn ="ou=Addressbook,uid=" . $username . ",ou=People,domain=" . $domain . ",ou=Domains," . $basedn; $filter="(objectClass=addressbookEntry)"; $sr=ldap_search($ds,$dn,$filter); $info = ldap_get_entries($ds, $sr); echo "
"; echo ""; echo "
"; echo ""; ///////////////////////////////////////////////////////////////// // // Two entries are here comented out this are: fam.name and businessphone // "sn" and "businessPhone" // due to space limitations.... by removing the commenting "//" the fealds should reaccour!!! // Hans Berg ! // ///////////////////////////////////////////////////////////////// //---------Deklarerer noen subrutiner----------------- function testvar($cn,$mail) { if($cn == "" || $mail == "" ) { return (false); } else { return (true); } } function testmail($mail) { if(ereg("m/^ [a-zA-A] (\.[a-zA-A])* \@ [a-zA-A] (\.[a-zA-A]) $ /x ", $mail)) //Testing that the mail address is OK { return (true); } //else {return (false);} } //---------Ferdig med deklareringen------------------ if ($handle == "add") { if (testvar($gaddcn,$gaddmail) || testmail($gaddmail)) { unset($info); $id = "address=$gaddmail, ou=Addressbook, uid=$username, ou=People, domain=$domain, ou=Domains, $basedn"; $info["objectClass"] = "addressbookEntry"; $info["cn"] = utf8_encode($gaddcn); $gaddmail = strtolower("$gaddmail"); $info["mail"] = $gaddmail; if ($gaddhomePhone){ $info["telephonenumber"] = $gaddhomePhone; } $r=ldap_add ($ds, $id, $info); unset($info); $dn ="ou=Addressbook,uid=" . $username . ",ou=People,domain=" . $domain . ",ou=Domains," . $basedn; $filter="(objectClass=addressbookEntry)"; $sr=ldap_search($ds,$dn,$filter); $info = ldap_get_entries($ds, $sr); $status = "Entry added successfully"; } else $status = "Could not add. Missing arguments."; } elseif($handle == "update") { if (testvar($gaddcn,$gaddmail) || testmail($gaddmail)) { $temp=$info[$entry]["mail"][0]; $deldn ="address=$temp, ou=Addressbook, uid=$username, ou=People, domain=$domain, ou=Domains, $basedn"; ldap_delete($ds,$deldn); unset($info); $id = "address=$gaddmail, ou=Addressbook, uid=$username, ou=People, domain=$domain, ou=Domains, $basedn"; $info["objectClass"] = "addressbookEntry"; $info["cn"] = utf8_encode($gaddcn); $gaddmail = strtolower("$gaddmail"); $info["mail"] = $gaddmail; if ($gaddhomePhone) $info["telephonenumber"] = $gaddhomePhone; $r=ldap_add ($ds, $id, $info); unset($info); $dn ="ou=Addressbook,uid=" . $username . ",ou=People,domain=" . $domain . ",ou=Domains," . $basedn; $filter="(objectClass=addressbookEntry)"; $sr=ldap_search($ds,$dn,$filter); $info = ldap_get_entries($ds, $sr); $status = "Entry modified"; } else $status = "Could not change. Missing arguments."; } elseif ($handle == "delete") { $temp=$info[$entry]["mail"][0]; $deldn ="address=$temp, ou=Addressbook, uid=$username, ou=People, domain=$domain, ou=Domains, $basedn"; ldap_delete($ds,$deldn); $dn ="ou=Addressbook,uid=" . $username . ",ou=People,domain=" . $domain . ",ou=Domains," . $basedn; $filter="(objectClass=addressbookEntry)"; $sr=ldap_search($ds,$dn,$filter); $info = ldap_get_entries($ds, $sr); $status = "Entry deleted successfully"; } //----------------------------------------Normal/ Standard View-------------- ?> \n"; print "\n"; print "\n"; // print "\n"; print "\n"; // print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; $status = "Entry ready for modifying"; } else { print "\n"; print "\n"; print "\n"; // print "\n"; print "\n"; // print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; } ?> \n"; print "\n"; print "\n"; //print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; } print "\n"; print "\n"; print"\n"; $dn ="ou=Addressbook,domain=" . $domain . ",ou=Domains," . $basedn; $filter="(objectClass=addressbookEntry)"; $sr=ldap_search($ds,$dn,$filter); $info = ldap_get_entries($ds, $sr); $tc ="0"; for ($i=0; $i<$info["count"]; $i++) { if ($tc) { $color = "$ncolor"; $tc = "0"; } else { $color = "$ycolor"; $tc = "1"; } print ""; print ""; print ""; print ""; print ""; print ""; } ?>
Name Mail address Phone  
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print " 
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print " 
Personal address book
" . utf8_decode($info[$i]["cn"][0]) . " " . $info[$i]["mail"][0] . "" . $info[$i]["buisnessphone"][0] . "  " . $info[$i]["telephonenumber"][0] . "  
Domain addressbook
" . utf8_decode($info[$i]["cn"][0]) . " " . $info[$i]["mail"][0] . "" . $info[$i]["telephonenumber"][0] . "   
Status: