use strict;
use warnings;
+use Carp (qw(cluck confess));
use Exporter;
-@LiCoM::Config::EXPORT_OK = ('get_config read_config');
+@LiCoM::Config::EXPORT_OK = (qw(get_config set_config read_config));
@LiCoM::Config::ISA = ('Exporter');
our $Config = {};
return (1);
-=head1 STATIC FUNCTIONS
+=head1 EXPORTED FUNCTIONS
=over 4
-=item LiCoM::Config-E<gt>B<get_config> (I<$key>)
+=item B<get_config> (I<$key>)
Returns the value for I<$key> or undef if it's unknown.
sub get_config
{
- my $pkg = shift;
my $key = shift;
+ cluck ("\$key was not defined") unless (defined ($key));
+
if (!%$Config)
{
read_config ();
return ($Config->{$key});
}
-=item LiCoM::Config-E<gt>B<set_config> (I<$key>, I<$value>)
+=item B<set_config> (I<$key>, I<$value>)
Sets the value of I<$key> to I<$value>.
sub set_config
{
- my $pkg = shift;
my $key = shift;
my $val = shift;
+ cluck ("\$key was not defined") unless (defined ($key));
+
$Config->{$key} = $val;
}
-=item LiCoM::Config-E<gt>B<read_config> ([I<@files>])
+=item B<read_config> ([I<@files>])
Read the config from the files given or F</etc/licom/licom.conf> and
F<~/.licomrc> if no files were given.
my $file = $_;
next unless (-r $file);
- read_file ($file, $config);
+ read_file ($file, $Config);
}
- return ($config);
+ return ($Config);
}
sub read_file
=cut
-our %Config = get_config ();
our $Ldap;
@LiCoM::Connection::EXPORT_OK = (qw($Ldap));
my %opts = @_;
my $bind_dn = $opts{'bind_dn'};
- my $base_dn = $opts{'base_dn'};
my $uri = $opts{'uri'};
my $passwd = $opts{'password'};
my $msg;
- die unless ($bind_dn and $base_dn and $uri and defined ($passwd));
+ die unless ($bind_dn and $uri and defined ($passwd));
$Ldap = Net::LDAP->new ($uri);
return (0);
}
- $Config{'base_dn'} = $base_dn;
-
return (1);
}
use URI::Escape;
use Data::Dumper;
-use LiCoM::Config (qw(get_config));
-use LiCoM::Person;
+use LiCoM::Config (qw(get_config set_config read_config));
+use LiCoM::Connection ();
+use LiCoM::Group ();
+use LiCoM::Person ();
our $Debug = 0;
-our $Config = {};
-our @MultiFields = (qw(address homephone cellphone officephone fax mail uri group));
+our @MultiFields = (qw(address homephone cellphone officephone fax mail uri));
our %FieldNames =
(
vcard => \&action_vcard
);
-$Config = get_config ();
+read_config ();
# make sure AuthLDAPRemoteUserIsDN is enabled.
die unless ($ENV{'REMOTE_USER'});
-$Config->{'base_dn'} = $ENV{'REMOTE_USER'};
+set_config ('base_dn', $ENV{'REMOTE_USER'});
-die unless (defined ($Config->{'uri'}) and defined ($Config->{'base_dn'})
- and defined ($Config->{'bind_dn'}) and defined ($Config->{'password'}));
+die unless (defined (get_config ('uri'))
+ and defined (get_config ('base_dn'))
+ and defined (get_config ('bind_dn'))
+ and defined (get_config ('password')));
-LiCoM::Person->connect
+LiCoM::Connection->connect
(
- uri => $Config->{'uri'},
- base_dn => $Config->{'base_dn'},
- bind_dn => $Config->{'bind_dn'},
- password => $Config->{'password'}
+ uri => get_config ('uri'),
+ bind_dn => get_config ('bind_dn'),
+ password => get_config ('password')
) or die;
-our ($UserCN, $UserID) = LiCoM::Person->get_user ($Config->{'base_dn'});
+our ($UserCN, $UserID) = LiCoM::Person->get_user ($ENV{'REMOTE_USER'});
if (!$UserID and $Action ne 'save')
{
}
}
-LiCoM::Person->disconnect ();
+LiCoM::Connection->disconnect ();
exit (0);
$group = shift if (@_);
$group ||= '';
+ return ('');
+
my @all;
if ($group)
{