initial commit of file from CVS for e-smith-ldap on Wed 12 Jul 08:58:23 BST 2023
This commit is contained in:
21
root/usr/lib/systemd/system/ldap.init.service
Normal file
21
root/usr/lib/systemd/system/ldap.init.service
Normal file
@@ -0,0 +1,21 @@
|
||||
[Unit]
|
||||
Description=Koozali SME Server ldap.init
|
||||
After=syslog.target network-online.target ldap.service
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
Restart=no
|
||||
TimeoutSec=5min
|
||||
IgnoreSIGPIPE=no
|
||||
KillMode=process
|
||||
GuessMainPID=no
|
||||
RemainAfterExit=yes
|
||||
ExecStartPre=/sbin/e-smith/service-status ldap.init
|
||||
ExecStart=/etc/rc.d/init.d/ldap.init start
|
||||
ExecStop=/etc/rc.d/init.d/ldap.init stop
|
||||
|
||||
|
||||
[Install]
|
||||
WantedBy=sme-server.target
|
||||
|
||||
|
26
root/usr/lib/systemd/system/ldap.service
Normal file
26
root/usr/lib/systemd/system/ldap.service
Normal file
@@ -0,0 +1,26 @@
|
||||
[Unit]
|
||||
Description=Koozali SME Server OpenLDAP Server Daemon
|
||||
After=syslog.target network-online.target
|
||||
Documentation=man:slapd
|
||||
Documentation=man:slapd-config
|
||||
Documentation=man:slapd-hdb
|
||||
Documentation=man:slapd-mdb
|
||||
Documentation=file:///usr/share/doc/openldap-servers/guide.html
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
PIDFile=/var/run/openldap/slapd.pid
|
||||
Environment="SLAPD_URLS=ldap:/// ldaps:/// ldapi:///" "SLAPD_OPTIONS=-4 -d 256 -s 0"
|
||||
EnvironmentFile=/etc/sysconfig/slapd
|
||||
ExecStartPre=/sbin/e-smith/service-status ldap
|
||||
ExecStartPre=/sbin/e-smith/expand-template /etc/openldap/ssl/slapd.pem
|
||||
ExecStartPre=/sbin/e-smith/systemd/ldap-prepare
|
||||
#ExecStartPre=/usr/libexec/openldap/check-config.sh
|
||||
ExecStart=/usr/sbin/slapd -u ldap -h ${SLAPD_URLS} $SLAPD_OPTIONS
|
||||
TimeoutStartSec=300
|
||||
Restart=always
|
||||
|
||||
ExecStopPost=/sbin/e-smith/systemd/ldap-finish
|
||||
|
||||
[Install]
|
||||
WantedBy=sme-server.target
|
@@ -0,0 +1,6 @@
|
||||
[Service]
|
||||
# disabled
|
||||
# we are using ldap.service
|
||||
ExecStart=/usr/bin/true
|
||||
ExecStartPre=
|
||||
PIDFile=
|
@@ -0,0 +1,204 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
#
|
||||
# $Id: directory.pm,v 1.3 2003/12/18 17:19:54 msoulier Exp $
|
||||
#
|
||||
|
||||
package esmith::FormMagick::Panel::directory;
|
||||
|
||||
use strict;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::ConfigDB;
|
||||
use esmith::FormMagick;
|
||||
use esmith::util;
|
||||
use File::Basename;
|
||||
use Exporter;
|
||||
use Carp;
|
||||
|
||||
our @ISA = qw(esmith::FormMagick Exporter);
|
||||
|
||||
our @EXPORT = qw(
|
||||
get_ldap_base get_value get_prop change_settings
|
||||
);
|
||||
|
||||
our $VERSION = sprintf '%d.%03d', q$Revision: 1.3 $ =~ /: (\d+).(\d+)/;
|
||||
|
||||
our $db = esmith::ConfigDB->open();
|
||||
|
||||
|
||||
# {{{ header
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
esmith::FormMagick::Panels::directory - useful panel functions
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use esmith::FormMagick::Panels::directory;
|
||||
|
||||
my $panel = esmith::FormMagick::Panel::directory->new();
|
||||
$panel->display();
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
=cut
|
||||
|
||||
# }}}
|
||||
|
||||
# {{{ new
|
||||
|
||||
=head2 new();
|
||||
|
||||
Exactly as for esmith::FormMagick
|
||||
|
||||
=begin testing
|
||||
|
||||
|
||||
use_ok('esmith::FormMagick::Panel::directory');
|
||||
use vars qw($panel);
|
||||
ok($panel = esmith::FormMagick::Panel::directory->new(), "Create panel object");
|
||||
isa_ok($panel, 'esmith::FormMagick::Panel::directory');
|
||||
|
||||
=end testing
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
|
||||
sub new {
|
||||
shift;
|
||||
my $self = esmith::FormMagick->new();
|
||||
$self->{calling_package} = (caller)[0];
|
||||
bless $self;
|
||||
return $self;
|
||||
}
|
||||
|
||||
# }}}
|
||||
|
||||
# {{{ get_prop
|
||||
|
||||
=head2 get_prop ITEM PROP
|
||||
|
||||
A simple accessor for esmith::ConfigDB::Record::prop
|
||||
|
||||
=cut
|
||||
|
||||
sub get_prop {
|
||||
my $fm = shift;
|
||||
my $item = shift;
|
||||
my $prop = shift;
|
||||
|
||||
my $record = $db->get($item);
|
||||
if ($record) {
|
||||
return $record->prop($prop);
|
||||
}
|
||||
else {
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# }}}
|
||||
|
||||
=head2 get_ldap_base
|
||||
|
||||
Gets the LDAP base for this domain
|
||||
|
||||
=cut
|
||||
|
||||
sub get_ldap_base {
|
||||
return esmith::util::ldapBase(get_value('','DomainName'));
|
||||
}
|
||||
|
||||
|
||||
# {{{ get_value
|
||||
|
||||
=head2 get_value ITEM
|
||||
|
||||
A simple accessor for esmith::ConfigDB::Record::value
|
||||
|
||||
=cut
|
||||
|
||||
sub get_value {
|
||||
my $fm = shift;
|
||||
my $item = shift;
|
||||
|
||||
my $record = $db->get($item);
|
||||
if ($record) {
|
||||
return $record->value();
|
||||
}
|
||||
else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
# }}}
|
||||
|
||||
=head1 ACTION
|
||||
|
||||
|
||||
# {{{ change_settings
|
||||
|
||||
=head2 change_settings
|
||||
|
||||
If everything has been validated, properly, go ahead and set the new settings
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
|
||||
sub change_settings {
|
||||
my ($fm) = @_;
|
||||
|
||||
my $q = $fm->{'cgi'};
|
||||
|
||||
my $access = $q->param ('Access') || 'private';
|
||||
my $department = $q->param ('Department') || "";
|
||||
my $company = $q->param ('Company') || "";
|
||||
my $street = $q->param ('Street') || "";
|
||||
my $city = $q->param ('City') || "";
|
||||
my $phone = $q->param ('PhoneNumber') || "";
|
||||
my $existing = $q->param ('Existing') || 'leave' ;
|
||||
$db->get('ldap')->set_prop('access', $access);
|
||||
$db->get('ldap')->set_prop('defaultDepartment', $department);
|
||||
$db->get('ldap')->set_prop('defaultCompany', $company);
|
||||
$db->get('ldap')->set_prop('defaultStreet', $street);
|
||||
$db->get('ldap')->set_prop('defaultCity', $city);
|
||||
$db->get('ldap')->set_prop('defaultPhoneNumber', $phone);
|
||||
|
||||
#------------------------------------------------------------
|
||||
# If requested, update the account records for all existing users.
|
||||
# Don't need to signal any special events for this, since we're only
|
||||
# changing LDAP information. If we were changing the user names
|
||||
# or email parameters, we'd have to signal events to trigger the
|
||||
# right updates.
|
||||
#------------------------------------------------------------
|
||||
|
||||
if ($existing eq 'update') {
|
||||
my $a = esmith::AccountsDB->open;
|
||||
my @users = $a->users();
|
||||
|
||||
foreach my $user (@users) {
|
||||
$user->set_prop('Phone', $phone);
|
||||
$user->set_prop('Company', $company);
|
||||
$user->set_prop('Dept', $department);
|
||||
$user->set_prop('City', $city);
|
||||
$user->set_prop('Street', $street);
|
||||
|
||||
}
|
||||
}
|
||||
#------------------------------------------------------------
|
||||
# Update the system
|
||||
#------------------------------------------------------------
|
||||
|
||||
system ("/sbin/e-smith/signal-event ldap-update") == 0
|
||||
or return $fm->error('ERROR_UPDATING_CONFIGURATION');
|
||||
|
||||
return $fm->success('SUCCESS');
|
||||
}
|
||||
|
||||
# }}}
|
||||
|
||||
1;
|
Reference in New Issue
Block a user