Tôi muốn truy xuất thông tin từ thư mục hoạt động (chẳng hạn như ảnh thu nhỏ) bằng bài đăng.Thực hiện cuộc gọi ajax đến thư mục hoạt động và kéo ảnh thu nhỏ bằng cách sử dụng bài đăng
<?php
/**
* Get a list of users from Active Directory.
*/
$ldap_password = $_POST['password'];
$ldap_username = $_POST['username'];
$server = 'ldap://xxxxxxxxxxxxxxxxxxxxxx';
$domain = 'xxxxxxxxxxxxxxxxx';
$port = 389;
$ldap_connection = ldap_connect($server, $port);
if (FALSE === $ldap_connection){
// Uh-oh, something is wrong...
}
// We have to set this option for the version of Active Directory we are using.
ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3) or die('Unable to set LDAP protocol version');
ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, 0); // We need this for doing an LDAP search.
if (TRUE === ldap_bind($ldap_connection, $ldap_username.$domain, $ldap_password)){
$ldap_base_dn = "OU=Employees,OU=Accounts,OU=xxxxx,DC=xxxxxx,DC=xxxxxxx,DC=com";
$search_filter = '(&(objectCategory=person)(samaccountname=*))';
$attributes = array();
$attributes[] = 'givenname';
$attributes[] = 'mail';
$attributes[] = 'samaccountname';
$attributes[] = 'sn';
$result = ldap_search($ldap_connection, $ldap_base_dn, $search_filter, $attributes);
$maxPageSize = 1000;
if (FALSE !== $result){
$entries = ldap_get_entries($ldap_connection, $result);
for ($x=0; $x<$entries['count']; $x++){
if (!empty($entries[$x]['givenname'][0]) &&
!empty($entries[$x]['mail'][0]) &&
!empty($entries[$x]['samaccountname'][0]) &&
!empty($entries[$x]['sn'][0]) &&
'Shop' !== $entries[$x]['sn'][0] &&
'Account' !== $entries[$x]['sn'][0]){
$ad_users[strtoupper(trim($entries[$x]['samaccountname'][0]))] = array('email' => strtolower(trim($entries[$x]['mail'][0])),'first_name' => trim($entries[$x]['givenname'][0]),'last_name' => trim($entries[$x]['sn'][0]));
}
}
}
ldap_unbind($ldap_connection); // Clean up after ourselves.
}
$message .= "Retrieved ". count($ad_users) ." Active Directory users\n";
?>
Tôi đã thử sử dụng http://localhost:8666/web1/activedirectory.php
để xem có trả về gì không nhưng trả về lỗi sau là kết quả> 1000.
Cảnh báo: ldap_search(): kết quả tìm kiếm phần trả về: Sizelimit vượt trong C: \ xampp \ htdocs \ web1 \ activedirectory.php trên đường dây 28
Notice: Undefined biến: Thông điệp trong C: \ xampp \ htdocs \ web1 \ activedirectory.php trên đường dây 46
dưới đây là jquery nơi tôi muốn liên kết các tập tin .php
đến tập tin trên:
$('.leaderboard li').on('click', function() {
$.ajax({
url: "../popupData/activedirectory.php", // php file with link to the active directory.
type: "POST",
data: {id:$(this).find('.parent-div').data('id')},
success: function(data){
console.log(data);
data = JSON.parse(data);
$('#popup').fadeIn();
//call for the thumbnail photo
// etc ..
},
error: function(){
alert('failed, possible script does not exist');
}
});
});
bạn có quen thuộc với thẻ không? – Cashbee