0) { $ldapConfName = "ldap_{$ldap}"; } if (!array_key_exists($ldapConfName, $_instance)) { $_instance[$ldapConfName] = null; Lib::loadClass('Config'); $conf = Config::getConfFile($ldapConfName); if ($conf) { $version = V::get('version', 3, $conf); $host = V::get('host', '', $conf); $port = V::get('port', '', $conf); $user = V::get('user', '', $conf); $pass = V::get('pass', '', $conf); $base_dn = V::get('base_dn', '', $conf); if ($base_dn && $host) { if ($port && $host) { $host .= ":{$port}"; } $clientClass = 'Core_Client_Ldap'; Lib::loadClass($clientClass); if (class_exists($clientClass)) { $_instance[$ldapConfName] = new $clientClass($host, $user, $pass, $base_dn, $version); } } else { trigger_error("Config file for ldap {$ldapConfName} not set: base_dn, host!", E_USER_WARNING); } } else { trigger_error("Config file for ldap {$ldapConfName} not exists!", E_USER_WARNING); } } return $_instance[$ldapConfName]; } public static function TEST_DUMP_1($ldap, $res) { $info = $ldap->get_entries($res); echo'
info: ';print_r($info);echo'
'; echo'
';
		// print number of entries found
		echo "Number of entries found: " . $ldap->count_entries($res) . "\n";
		// iterate over array and print data for each entry
		for ($i=0; $i < $info['count']; $i++) {
			echo"\n".'-------------------------';
			echo"\n".'dn: ('.$info[$i]['dn'].')';
			for ($j=0; $j < $info[$i]['count']; $j++) {
				$k2 = $info[$i][$j];
				echo"\n".''.$k2.': ';
				for ($k=0; $k < $info[$i][$k2]['count']; $k++) {
					echo '"'.$info[$i][$k2][$k].'" ';
				}
			}
		}
		echo'
'; } public static function TEST_DUMP($ldap, $res) { $ldap = self::getInstance(); echo'
';
		// print number of entries found
		echo "Number of entries found: " . $ldap->count_entries($res) . "\n";
		$entry = $ldap->first_entry($res);
		while ($entry) {
			$dn = $ldap->get_dn($entry);
			echo "$dn\n";
			$attrs = $ldap->get_attributes($entry);
			for ( $i=0; $i < $attrs['count']; $i++) {
				echo "$attrs[$i]: ";
				for ( $j=0; $j < $attrs[$attrs[$i]]['count']; $j++ ) {
					echo $attrs[$attrs[$i]][$j] . " ";
				}
				echo "\n";
			}
			echo "\n";
			$entry = $ldap->next_entry($entry);
		}
		$ldap->free_result($res);
		echo'
'; } }