'domaincontroller.domain.com', // FQDN of your domain controller 'dn' => 'DC=domain,DC=com', // Domain DN 'username' => 'myusername@domain.com', // username with read access 'password' => 'password', // password for above 'color1' => '#DDDDDD', // alternating row colour 1 'color2' => '#FFFFFF', // alternating row colour 2 ); // $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 "" ; } else { echo ''; } } else { echo ''; //fial not set output empty cell } } ?>
" .$entries[$i][$value][0]. "'.$entries[$i][$value][0].'
No results found!

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