I put an eval statement around the lookup. Now person.pl doesn't crash.
#!/usr/bin/perl
=head1 NAME
person.pl - Person Lookup
=cut
require 5.8.5;
use strict;
use warnings;
use FindBin;
use Pod::Usage;
BEGIN {
use constant INSTALL_DIR => '/usr/local/pf';
use lib INSTALL_DIR . "/lib";
}
use pf::node;
use pf::db;
use pf::util;
use pf::person;
use pf::lookup::person;
my @person = person_view_all;
my $source_id = 'AD';
foreach my $pers ( @person ) {
print "$pers->{'pid'}\n";
eval {
pf::lookup::person::lookup_person($pers->{'pid'},$source_id);
};
if (my $e = $@) {
print("Something went wrong: $e\n");
};
}
=head1 AUTHOR
Inverse inc. <[email protected]>
=head1 COPYRIGHT
Copyright (C) 2005-2015 Inverse inc.
=head1 LICENSE
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
=cut
# vim: set shiftwidth=4:
# vim: set expandtab:
# vim: set backspace=indent,eol,start:
From: Morgan, Joel P.
Sent: Tuesday, July 5, 2016 10:14 AM
To: '[email protected]'
<[email protected]>
Subject: RE: Re: [PacketFence-users] take account details like
firstname/lastname from AD
I can comment out these lines in person.pl and input a single user:
#foreach my $pers ( @person ) {
# pf::lookup::person::lookup_person($pers->{'pid'},$source_id);
#}
This doesn't throw the error:
pf::lookup::person::lookup_person("domainuser",$source_id);
But this does:
pf::lookup::person::lookup_person("gmailuser\@gmail.com",$source_id);
The problem appears to be only guest users who registered with an email source,
not an LDAP source. Is there some logic I could add to skip lookup on non-LDAP
registered users or make sure the user exists before doing a lookup?
From: Morgan, Joel P.
Sent: Wednesday, June 29, 2016 9:24 AM
To: '[email protected]'
<[email protected]<mailto:[email protected]>>
Subject: Re: [PacketFence-users] take account details like firstname/lastname
from AD
I've been using the person.pl script to populate user details from LDAP. Since
upgrading from Packetfence 5.4 to 5.7, it no longer works.
[root@packetfence lookup]# perl /usr/local/pf/lib/pf/lookup/person.pl
Can't call method "get_value" on an undefined value at
/usr/local/pf/lib/pf/Authentication/Source/LDAPSource.pm line 558.
-------------------------
#!/usr/bin/perl
=head1 NAME
person.pl - Person Lookup
=cut
require 5.8.5;
use strict;
use warnings;
use FindBin;
use Pod::Usage;
BEGIN {
use constant INSTALL_DIR => '/usr/local/pf';
use lib INSTALL_DIR . "/lib";
}
use pf::node;
use pf::db;
use pf::util;
use pf::person;
use pf::lookup::person;
my @person = person_view_all;
my $source_id = 'AD';
foreach my $pers ( @person ) {
pf::lookup::person::lookup_person($pers->{'pid'},$source_id);
}
=head1 AUTHOR
Inverse inc. <[email protected]<mailto:[email protected]>>
=head1 COPYRIGHT
Copyright (C) 2005-2015 Inverse inc.
=head1 LICENSE
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
=cut
# vim: set shiftwidth=4:
# vim: set expandtab:
# vim: set backspace=indent,eol,start:
--------------------------
The error happens in /usr/local/pf/lib/pf/Authentication/Source/LDAPSource.pm
line 558
555 my $info = {};
556 foreach my $attrs (keys %ATTRIBUTES_MAP){
557 foreach my $attr (split('\|',$ATTRIBUTES_MAP{$attrs})) {
558 if(defined($entry->get_value($attr))){
559 $info->{$attrs} = $entry->get_value($attr);
560 }
561 }
562 }
Any ideas why this no longer works?
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
PacketFence-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/packetfence-users