"; $lc=@ldap_connect($ldapServer, $ldapPort); if ($debug) echo "connect result is [".$lc."]
"; if ($lc) { //prepneme na ldap v3 protokol kvoli add a update a delete $ldapV3 = @ldap_set_option($ds,LDAP_OPT_PROTOCOL_VERSION,3); if ($debug) echo "ldap protocol v3 [".$ldapV3."]
"; if ($debug) echo "Binding as [$ldapLogin:$ldapPwd]
"; if (@ldap_bind($lc, $ldapLogin, $ldapPwd)){ if ($debug) echo "Searching for "; //////////////////////////////////////// //mozne atributy objectClass inetOrgPerson: //audio $ businessCategory $ carLicense $ departmentNumber $ displayName $ employeeNumber $ employeeType $ givenName $ homePhone $ homePostalAddress $ initials $ jpegPhoto $ labeledURI $ mail $ manager $ mobile $ o $ pager $ photo $ roomNumber $ secretary $ uid $ userCertificate $ x500uniqueIdentifier $ preferredLanguage $ userSMIMECertificate $ userPKCS12 $attr=explode(",","cn,sn,givenName,mail,telephoneNumber,o,ou,roomNumber"); //$attr[]="*"; //$filter="(|(sn=$person*)(givenname=$person*))"; if ($debug){ echo "attr[]="; for ($i=0;$i\n"; }; //////////////////////////////////////// //query builder if ($search_meno!=""){ $query[]="(cn=*".$search_meno."*)"; //$query[]="(o=*".$search_meno."*)"; }; if ($search_ou!=""){ /* if ($search_meno==""){ //moze hladat organizaciu $query[]="(cn=*".$search_ou."*)"; }; */ //$query[]="(ou=*".$search_ou."*)"; //$query[]="(o=*".$search_ou."*)"; $query[]="(|(ou=*".$search_ou."*)(o=*".$search_ou."*))"; }; if ($search_room!=""){ $query[]="(roomNumber=*".$search_room."*)"; }; if ($search_phone!=""){ $query[]="(telephoneNumber=*".$search_phone."*)"; }; if ($search_email!=""){ $query[]="(mail=*".$search_email."*)"; }; $queryStr=""; if (count($query)){ //mame aspon jeden zaznam if (count($query)>1){ if ($search_operation=="and") { $queryStr="(&"; //and } else { $queryStr="(|"; //or }; for ($i=0;$i$queryStr]
\n"; //$result=ldap_search($lc, $ldapDN, "(objectclass=*)", $atr, 0, $search_limit); $result=@ldap_search($lc, $ldapDN, $queryStr, $attr, 0, $search_limit); /* ldap_search( connection $this->res base_dn $this->dn_all filter sets the restrictions attributes as array array of attributes returned attrsonly 1 = return only the attributes, 0 = return attributes and values amount number of results to return; 0 means all time limit time limit in seconds; 0 means no limit deref handling of aliases: LDAP_DEREF_NEVER never resolv aliases LDAP_DEREF_SEARCHING not if base object is called LDAP_DEREF_FINDING only if base object is called LDAP_DEREF_ALWAYS always resolv aliases $result=ldap_search($lc, $ldapDN, "(objectclass=*)"); */ if (!isset($result)) die("empty result, dying"); //////////////////////////////////////////////////////////// //triedenie //ldap_sort MUSI byt zavolany hned po ldap_search if ($search_sort!="none"){ $querySort=""; switch ($search_sort){ case "meno": $querySort="sn"; break; case "room": $querySort="roomNumber"; break; case "mail": $querySort="mail"; break; }; if ($debug) echo "skusime sort podla [".$querySort."]
\n"; $sortResult = ldap_sort($lc, $result, $querySort); if ($debug) echo "sort vratil: $sortResult
\n"; }; if ($debug) echo "Search result is ".$result."
"; if ($debug) echo "Number of entires returned is ".ldap_count_entries($lc,$result)."
"; if ($debug) echo "Getting entries ...
"; $info = ldap_get_entries($lc, $result); if ($debug) echo "Data for ".$info["count"]." items returned:


\n"; if ($debug) echo "info[count] = ".$info["count"]."
"; echo '
'; echo ''."\n"; echo ''."\n"; if ($info["count"]){ for ($i=0; $i<$info["count"]; $i++) { list( $givenName,$sn,$mail,$cn,$telephoneNumber,$o,$ou,$roomNumber ) = getRecordAttribList( $info[$i], "givenname,sn,mail,cn,telephonenumber,o,ou,roomnumber" ); echo ''."\n"; if ($debug){ $displayScalars = false; echo ""; }; //if debug }; //for record } else { echo ''."\n"; }; //if count(info) echo '
Vysledky hladania
MenoeMailPracoviskoUdaje
'; //Meno if (($linkPrefix!="")&&($adminDN==$certDN)){ echo ''; } else { echo ''; }; //echo ''; $celeMeno = (( (''==$sn) || (''==$givenname) )?($cn):($sn.((""==$givenname)?(''):(', '.$givenname)))); if (''==$celeMeno) $celeMeno=$o; echo $celeMeno; echo ''; echo ''; //email if (isset($mail)) echo ''; echo $mail; if (isset($mail)) echo ''; //echo ldap_get_dn(); echo ''; //Pracovisko echo $ou; echo ''; //Udaje echo iconDef2("email", isset($mail)); echo iconDef2("phone", isset($telephoneNumber)); echo iconDef2("address", isset($roomNumber)); echo ' vCard'; echo '
record #".(1+$i)."
\n"; //for( $attr=0; list($key,$value) = each($info[$i]); $attr++) { //while(list($key,$value) = each($info[$i])) { $attr=0; while(list($key,$value) = each($info[$i])) { //printRecordAnonSearch($id); if(is_array($value)) { echo "attrib #".(1+$attr)."
\n"; echo "
"; echo "array
\n"; for($k=0; $k < $value[count]; $k++) { echo "key[$k]=$key, value[$k]=$value[$k]
\n"; } //for value echo "
"; } else { //not array if ($displayScalars){ echo "attrib #".(1+$attr)."
\n"; echo "
"; echo "scalar
\n"; if($key != "count" && !is_int($key)) { if($full) { echo "key=$key, value=$value
\n"; } } else { echo "special: key=$key, value=[$value]
\n"; } echo "
"; } //if displayScalars } //if value=array $attr++; } //while echo "
Server nenasiel ziadne zodpovedajuce data
'; /* for ($record=0; $record < $info["count"]; $record++) { //zaznamy echo "\nrecord # $record of ".$info["count"]."
\n"; for ($attrib; $attrib < $info[$record]["count"]; $attrib++){ //atributy echo "\nattribute # $attrib of ".$info[$record]["count"]."
\n"; echo "atribut: [".$info[$record][$attrib]."] "; for ($value; $value < $info[$record][$attrib]["count"]; $value++){ echo "\nvalue # $value of ".$info[$record][$attrib]["count"]."
\n"; //hodnoty echo "hodnota: [".$info[$record][$attrib][$value]."]"; echo "
\n"; }; //value echo "
\n"; }; //attrib echo "
\n"; //vonkajsia (ramik) }; //record */ /* for ($record=0; $record < $info["count"]; $record++) { //zaznamy echo "\n\n"; echo ''; echo "
"; echo ''; for ($attrib; $attrib < $info[$record]["count"]; $attrib++){ //atributy echo "\n\n"; //echo ""; echo ""; echo ""; for ($value; $value < $info[$record][$attrib]["count"]; $value++){ echo "\n\n"; //hodnoty if (1<$value){ //mame viac values, musime spravit aj echo ""; }; echo "\n"; }; //value echo "\n"; }; //attrib echo "
"; //tr echo "atribut: [".$info[$record][$attrib]."]
"; echo "hodnota: [".$info[$record][$attrib][$value]."]"; echo "
\n"; //vnutorna echo "
\n"; //vonkajsia (ramik) }; //record echo ""; */ /* echo "dn". $info[$i]["dn"] ."]
"; echo "objectClass=[". $info[$i]["objectClass"][0] ."]
"; echo "cn[0]=[". $info[$i]["cn"][0] ."]
"; echo "email[0]=[". $info[$i]["mail"][0] ."]
"; */ } else { echo "Nemozem sa nalogovat na LDAP server! Je nutne skontrolovat konfiguraciu $wpldapName.
\nKontaktuje prosim administratora systemu."; }; // if bind if ($debug) echo "Closing connection"; ldap_close($lc); } else { echo "Nemozem sa pripojit k LDAP serveru na adrese $ldapServer:$ldapPort
\nKontaktuje prosim administratora systemu."; }; ?>