'10.1.80.41', 'dn' => 'DC=cowetaschools,DC=net', 'username' => 'ldaplookup@cowetaschools.net', 'password' => 'look', 'color1' => '#DDDDDD', 'color2' => '#FFFFFF', ); // $search_fields , select which AD fields you want to search on $search_fields=array('First Name' => 'givenname', 'Last Name' => 'sn', ); //$return_fields , select which AD fields you wish to have displayed in the results $return_fields=array('Display Name' => 'displayname', 'First Name' => 'givenname', 'Last Name' => 'sn', 'Telephone Number' => 'telephonenumber', 'Email Address' => 'mail', 'Company' => 'company', ); //CONFIGURATION END ?>

 

ACTIVEDIRECTORY SEARCH TOOL
$value) { ?>
$value) //build filter { if (empty($_POST[$value])) { $filter[$value]="($value=*)"; } else { $filter[$value]="($value=$_POST[$value])"; } $ldap_search=$ldap_search.$filter[$value]; } $attrs=array(); foreach ($return_fields as $item => $value) //build attr array { $attrs[]=$value; } $ldap_search='(&'.$and.$ldap_search.')'; $ad = ldap_connect($config['host']) or die( "Could not connect!" ); // Set version number ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3) or die ("Could not set ldap protocol"); ldap_set_option($ad, LDAP_OPT_REFERRALS,0) or die ("could no se the ldap referrals"); // Binding to ldap server $bd = ldap_bind($ad, $config['username'], $config['password']) or die ("Could not bind"); // Create the DN // Specify only those parameters we're interested in displaying // Create the filter from the search parameters $search = ldap_search($ad, $config['dn'], $ldap_search, $attrs) or die ("ldap search failed"); $entries = ldap_get_entries($ad, $search); if ($entries["count"] > 0) { $row_count = 0; ?>

No of results =

$value) { ?> $value) { if (isset ($entries[$i][$value][0])) { if ($value == 'mail') // do i need a mailto: link ? { echo " " .$entries[$i][$value][0]. " " ; } else { echo ' '.$entries[$i][$value][0].' '; } } else { echo ' '; //fial not set output empty cell } } ?>
No results found!

"; } ldap_unbind($ad); } ?>
script by James Lloyd