phpldapadmin/download_binary_attr.php

36 lines
1.4 KiB
PHP
Raw Normal View History

2009-06-30 08:07:14 +00:00
<?php
2009-06-30 09:22:30 +00:00
// $Header: /cvsroot/phpldapadmin/phpldapadmin/download_binary_attr.php,v 1.8 2004/08/15 17:39:20 uugdave Exp $
2009-06-30 08:07:14 +00:00
2009-06-30 09:22:30 +00:00
require './common.php';
2009-06-30 08:07:14 +00:00
$server_id = $_GET['server_id'];
$dn = rawurldecode( $_GET['dn'] );
$attr = $_GET['attr'];
// if there are multiple values in this attribute, which one do you want to see?
$value_num = isset( $_GET['value_num'] ) ? $_GET['value_num'] : 0;
2009-06-30 09:22:30 +00:00
check_server_id( $server_id ) or pla_error( $lang['bad_server_id'] );
have_auth_info( $server_id ) or pla_error( $lang['not_enough_login_info'] );
$ds = pla_ldap_connect( $server_id );
pla_ldap_connection_is_error( $ds );
dn_exists( $server_id, $dn ) or pla_error( sprintf( $lang['no_such_entry'], pretty_print_dn( $dn ) ) );
2009-06-30 08:07:14 +00:00
2009-06-30 09:22:30 +00:00
$search = @ldap_read( $ds, $dn, "(objectClass=*)", array( $attr ), 0, 0, 0, get_view_deref_setting() );
if( ! $search )
pla_error( $lang['error_performing_search'], ldap_error( $ds ), ldap_errno( $ds ) );
$entry = ldap_first_entry( $ds, $search );
$attrs = ldap_get_attributes( $ds, $entry );
$attr = ldap_first_attribute( $ds, $entry, $attrs );
$values = ldap_get_values_len( $ds, $entry, $attr );
2009-06-30 08:07:14 +00:00
$count = $values['count'];
2009-06-30 09:22:30 +00:00
// Dump the binary data to the browser
header( "Content-type: octet-stream" );
header( "Content-disposition: attachment; filename=$attr" );
2009-06-30 08:07:14 +00:00
header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
echo $values[$value_num];
?>