phpldapadmin/download_binary_attr.php

46 lines
1.6 KiB
PHP
Raw Normal View History

2009-06-30 08:07:14 +00:00
<?php
2009-06-30 09:24:29 +00:00
// $Header: /cvsroot/phpldapadmin/phpldapadmin/download_binary_attr.php,v 1.10 2005/03/05 06:27:06 wurley Exp $
2009-06-30 08:07:14 +00:00
2009-06-30 09:24:29 +00:00
/**
* @package phpLDAPadmin
*/
/**
*/
2009-06-30 09:22:30 +00:00
require './common.php';
2009-06-30 08:07:14 +00:00
2009-06-30 09:24:29 +00:00
$server_id = (isset($_GET['server_id']) ? $_GET['server_id'] : '');
$ldapserver = new LDAPServer($server_id);
if( $ldapserver->isReadOnly() )
pla_error( $lang['no_updates_in_read_only_mode'] );
if( ! $ldapserver->haveAuthInfo())
pla_error( $lang['not_enough_login_info'] );
2009-06-30 08:07:14 +00:00
$dn = rawurldecode( $_GET['dn'] );
$attr = $_GET['attr'];
2009-06-30 09:24:29 +00:00
2009-06-30 08:07:14 +00:00
// 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:24:29 +00:00
dn_exists( $ldapserver, $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:24:29 +00:00
$search = @ldap_read( $ldapserver->connect(),$dn,"(objectClass=*)",array($attr),0,0,0,get_view_deref_setting() );
2009-06-30 09:22:30 +00:00
if( ! $search )
2009-06-30 09:24:29 +00:00
pla_error( $lang['error_performing_search'],ldap_error($ldapserver->connect()),ldap_errno($ldapserver->connect()) );
$entry = ldap_first_entry( $ldapserver->connect(),$search );
$attrs = ldap_get_attributes( $ldapserver->connect(),$entry );
$attr = ldap_first_attribute( $ldapserver->connect(),$entry,$attrs );
$values = ldap_get_values_len( $ldapserver->connect(),$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 09:24:29 +00:00
header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
2009-06-30 08:07:14 +00:00
echo $values[$value_num];
?>