- Автор темы
- #1
считывние полей из таблицы LDAP базы.
По принципу сортировки
По принципу сортировки
PHP:
<?php
$ldap_server = "ldap://sursrv02.test.xxx.com";
$auth_user = "update@test.xxx.com";
$auth_pass = "123456";
// Set the base dn to search the entire directory.
$base_dn = " OU=staff,DC=test,DC=xxx,DC=com";
$filter = "(&(objectCategory=*)(objectClass=*)(memberOf=CN=inet,CN=Users,DC=test,DC=xxx,DC=com)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))";
// connect to server
if (!($connect=@ldap_connect($ldap_server))) {
die("Could not connect to ldap server");
}
// bind to server
if (!($bind=@ldap_bind($connect, $auth_user, $auth_pass))) {
die("Unable to bind to server");
}
//if (!($bind=@ldap_bind($connect))) {
// die("Unable to bind to server");
//}
// search active directory
if (!($search=@ldap_search($connect, $base_dn, $filter))) {
die("Unable to search ldap server");
}
$number_returned = ldap_count_entries($connect,$search);
$entries = ldap_get_entries($connect, $search);
echo "Количество строк ". $number_returned."<p>";
// for ($i=0; $i<$info["count"]; $i++) {
/* echo "Name is: ". $entries[$i]["name"][0]."<br>";
echo "Display name is: ". $entries[$i]["displayname"][0]."<br>";
echo "Email is: ". $entries[$i]["mail"][0]."<br>";
echo "Telephone number is: ". $entries[$i]["telephonenumber"][0]."<br>";
echo "Department: ". $entries[$i]["department"][0]."<br>";
echo "Title: ". $entries[$i]["title"][0]."<p>";
/////////////////////
*/
//$entries = ldap_get_entries($ad, $search);
echo "Пользователи Интернет, динамичный список";
if ($entries["count"] > 0) {
echo "<table border='1' width='90%'>";
echo "<tr>";
// echo "<td>Name:</td>";
echo "<td><b>ФИО</b></td>";
echo "<td><b>Email</b></td>";
echo "<td><b>Телефон</b></td>";
echo "<td><b>Отдел</b></td>";
echo "<td><b>Должность</b></td>";
echo "<td><b>Объем, Мб/мес</b></td>";
echo "<td><b>Набор доступа</b></td>";
echo "<td><b>Примечание</b></td>";
echo "</tr>";
for ($i=0; $i<$entries["count"]; $i++) {
echo "<tr>";
// echo "<td>". $entries[$i]["name"][0]."<br></td>";
echo "<td>".iconv('CP1251', 'UTF-8',$entries[$i]["displayname"][0])."<br></td>";
// echo "<td>". $entries[$i]["mail"][0]."<br></td>";
echo "<td> <a href='mailto:".$entries[$i]["mail"][0]."'>".$entries[$i]["mail"][0]."</a></td>";
echo "<td>".iconv('CP1251', 'UTF-8',$entries[$i]["telephonenumber"][0])."<br></td>";
echo "<td>".iconv('CP1251', 'UTF-8',$entries[$i]["department"][0])."<br></td>";
echo "<td>".iconv('CP1251', 'UTF-8',$entries[$i]["title"][0])."<p></td>";
echo "<td>".iconv('CP1251', 'UTF-8',$entries[$i]["ipphone"][0])."<p></td>";
echo "<td>".iconv('CP1251', 'UTF-8',$entries[$i]["otheripphone"][0])."<p></td>";
echo "<td>".iconv('CP1251', 'UTF-8',$entries[$i]["info"][0])."<p></td>";
echo "</tr>";
}
echo "</table>";
}
?>