PHP ve JQuery kullanarak basit bir ajax LDAP arama (veya AD) yapmak istiyorum. Ben gibi mysql arama öğreticiler, bir dizi okudum:
http://www.codeforest.net/simple-search-with-php-jquery-and-mysql
Benim ldap bağlantı detayları ile mysql bağlantısı aşağıda detayları değiştirmek istiyor. Birisi sonuçları görüntülemek için alınamıyor olarak bu işe almak bana yardımcı olabilir.
Teşekkürler
LDAP Bağlantı komut
<?php echo "<?xml version='1.0' encoding='utf-8' ?>" ?><?php echo "<ul class='LSRes'>" ?>
<?php
if( isset($_GET['q']) &&!empty($_GET['q']) ){
// all your ldap code
// Designate a few variables
$host = "10.10.10.10"; // Add in your AD host name or IP
$user = "DOMAIN\user"; // Add in your AD access account user name
$pswd = "password"; // Add in your AD access account user name password
$ad = ldap_connect($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");
// Binding to ldap server
$bd = ldap_bind($ad, $user, $pswd)
or die ("Could not bind");
// Create the DN - Add in the OU of your AD
$dn = "OU=accounts,DC=domain,DC=com";
// Specify only those parameters we're interested in displaying from AD
$attrs = array("displayname","mail","samaccountname","telephonenumber","givenname", "title");
//$attrs = array("samaccountname");
// Create the filter from the search parameters
//$filter = "(|(givenName=".$_GET['q']."*) (sn=".$_GET['q']."*) (displayname=".$_GET['q']."*) (samaccountname=".$_GET['q']."*) (telephonenumber=".$_GET['q']."*))";
$filter = "(|(givenName=".$_GET['q']."*) (sn=".$_GET['q']."*) (displayname=".$_GET['q']."*) (samaccountname=".$_GET['q']."*))";
$search = ldap_search($ad, $dn, $filter, $attrs)
or die ("<span class='LSstyle_noresults'><strong>Could not connect to AD</strong></span>");
// Sort entries by last name ('sn')
ldap_sort ( $ad, $search, 'sn' ) ;
//ldap_sort ( $ad, $search, $samaccountname ) ;
$entries = ldap_get_entries($ad, $search);
if ($entries["count"] > 0) {
for ($i=0; $i<$entries["count"]; $i++) {
echo "<span class='LSstyle'>Name: <strong><a href=\"mailto:".$entries[$i]["mail"][0]."\">".$entries[$i]["displayname"][0]." ".$entries[$i]["sn"][0]."</a></strong></span><br />";
echo "<span class='LSstyle'>Short name: <strong>".$entries[$i]["samaccountname"][0]."</strong></span><br />";
echo "<span class='LSstyle'>Phone: <strong>".$entries[$i]["telephonenumber"][0]."</strong></span><br />";
echo "<span class='LSstyle'>Title: <strong>".$entries[$i]["title"][0]."</strong></span><br />";
echo "<span class='LSstyle'>Dept: <strong>".$entries[$i]["department"][0]."</strong></span></p>";
}
} else {
echo "<span class='LSstyle_noresults'><strong>No results found</strong></span>";
}
ldap_unbind($ad);
}
?>