-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview_status.cgi
executable file
·48 lines (38 loc) · 1.21 KB
/
view_status.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
#! /usr/bin/perl
use strict;
use NetLdap;
use Constants;
use LMConfig;
use Utils;
use ParseExop;
use Tmpl;
use ManipCGI;
my @disp_attr = (
'cn', 'uidNumber', 'gidNumber', 'homeDirectory', 'mail',
'modifyTimestamp', 'modifiersName', 'objectClass', 'maildrop', 'sn',
'o', 'c', 'l', 'jpegPhoto',
'creatorsName', 'createTimestamp',
);
my $obj_tmpl = new Tmpl;
my $obj_cgi = new ManipCGI;
my $user_name = $ENV{'REMOTE_USER'};
my $obj_ldap = new NetLdap;
if (! $obj_ldap->bind) {
print $obj_cgi->header();
$obj_tmpl->throw_error_code('ldap_bind_anonymous');
}
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);
$obj_tmpl->set_vars("dn", $user_dn);
$obj_tmpl->set_vars("uid", $ENV{'REMOTE_USER'});
$obj_tmpl->set_vars("entry", $user_attr);
$obj_tmpl->set_vars("groups", $obj_ldap->SearchMemberGroups($user_name));
$obj_tmpl->set_vars("groupmember", $obj_ldap->SearchMemberGroupsGN($user_dn));
$obj_tmpl->set_vars("photo_exist", defined($user_attr->{'jpegPhoto'}) ? 0 : 1);
print $obj_cgi->header();
$obj_tmpl->process('view_status');
exit;