-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview_photo.cgi
executable file
·52 lines (39 loc) · 972 Bytes
/
view_photo.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#! /usr/bin/perl
use strict;
use NetLdap;
use Constants;
use LMConfig;
use Utils;
use ParseExop;
use Tmpl;
use ManipCGI;
use Data::Dumper;
my @disp_attr = (
'cn', 'jpegPhoto',
);
my $obj_tmpl = new Tmpl;
my $obj_cgi = new ManipCGI;
my $user_name = $obj_cgi->param('uid');
my $obj_ldap = new NetLdap;
if (! $obj_ldap->bind) {
print $obj_cgi->header();
$obj_tmpl->throw_error_code('ldap_bind_anonymous');
}
if (! defined($user_name)) {
print $obj_cgi->header();
$obj_tmpl->throw_error_code('ldap_get_dn');
}
my $user_dn = $obj_ldap->GetDNFromUID($user_name);
if (! defined($user_dn)) {
print $obj_cgi->header();
$obj_tmpl->throw_error_code('ldap_get_dn');
}
my $user_attr = $obj_ldap->GetAttrsFromUID($user_name, @disp_attr);
my $ent_photo = $user_attr->{'jpegPhoto'};
if (! defined($ent_photo)) {
print $obj_cgi->header( -status => "404 Not found" );
exit;
}
print $obj_cgi->header('image/jpeg');
print $ent_photo->[0];
exit;