0
我有这样的代码:如何从Active Directory获取缩略图照片? PHP
if (TRUE === ldap_bind($ldap_connection, $ldap_username, $ldap_password)){
$ldap_base_dn = 'DC=xx,dc=xx,dc=xx';
$search_filter = '(&(objectCategory=person)(samaccountname=*))';
$attributes = array();
$attributes[] = 'givenname';
$attributes[] = 'mail';
$attributes[] = 'samaccountname';
$attributes[] = 'ipphone';
$attributes[] = 'thumbnailPhoto';
$result = ldap_search($ldap_connection, $ldap_base_dn, $search_filter, $attributes);
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]['ipphone'][0]) &&
'Shop' !== $entries[$x]['ipphone'][0] &&
'Account' !== $entries[$x]['ipphone'][0]){
$ad_users[strtoupper(trim($entries[$x]['samaccountname'][0]))] = array('email' => strtolower(trim($entries[$x]['mail'][0])),'first_name' => trim($entries[$x]['givenname'][0]),'phone' => trim($entries[$x]['ipphone'][0]), 'photo' => trim ($entries[$x]['thumbnailPhoto'][0]));
}
}
}
ldap_unbind($ldap_connection);
}
echo json_encode($ad_users);
我只得到空的thumbnailPhoto。
如何处理这类数据?我可以得到这张照片的网址吗? 我正在开发iOS应用程序并在php中使用json发送员工数据,但我怎样才能将此thumbnailPhoto也与json中的每个员工一起发送?