Possibility to autoconfigure LDAP notification backend from LDAP configuration backend (#457)
This commit is contained in:
parent
625ae5ece0
commit
3106100c5d
@ -35,7 +35,7 @@ sub new {
|
|||||||
unless ( $self->{type} =~ /::/ );
|
unless ( $self->{type} =~ /::/ );
|
||||||
eval "require $self->{type}";
|
eval "require $self->{type}";
|
||||||
if ($@) {
|
if ($@) {
|
||||||
$msg = "Error: unknown storage type $type";
|
$msg = "Error: unknown storage type $type ($@)";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
unless ( $self->_prereq ) {
|
unless ( $self->_prereq ) {
|
||||||
|
@ -4,40 +4,6 @@
|
|||||||
## @class
|
## @class
|
||||||
# LDAP storage methods for notifications
|
# LDAP storage methods for notifications
|
||||||
|
|
||||||
# Use case: copy and adapt the following lines into lemonldap-ng.ini
|
|
||||||
#
|
|
||||||
# [Portal]
|
|
||||||
#
|
|
||||||
# notification = 1
|
|
||||||
# notificationStorage = LDAP
|
|
||||||
# notificationStorageOptions = { \
|
|
||||||
# 'ldapServer' => 'ldap://directory.com:389',\
|
|
||||||
# 'ldapBindDN' => 'cn=lemonldap,ou=people,dc=directory,dc=com',\
|
|
||||||
# 'ldapBindPassword' => 'secret',\
|
|
||||||
# 'notifBase' => 'ou=notifications,ou=websso,dc=directory,dc=com',\
|
|
||||||
# 'notificationWildcard' => 'allusers',\
|
|
||||||
# 'fileNameSeparator' => '_',\
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# [...]
|
|
||||||
#
|
|
||||||
# [Manager]
|
|
||||||
#
|
|
||||||
# notificationStorage = LDAP
|
|
||||||
# notificationStorageOptions = { \
|
|
||||||
# 'ldapServer' => 'ldap://directory.com:389',\
|
|
||||||
# 'ldapBindDN' => 'cn=lemonldap,ou=people,dc=directory,dc=com',\
|
|
||||||
# 'ldapBindPassword' => 'secret',\
|
|
||||||
# 'notifBase' => 'ou=notifications,ou=websso,dc=directory,dc=com',\
|
|
||||||
# 'notificationWildcard' => 'allusers',\
|
|
||||||
# 'fileNameSeparator' => '_',\
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# possible other notificationStorageOptions are:
|
|
||||||
# caFile, caPath, ldapPort
|
|
||||||
# notifBase can be replaced by ldapConfBase
|
|
||||||
|
|
||||||
package Lemonldap::NG::Common::Notification::LDAP;
|
package Lemonldap::NG::Common::Notification::LDAP;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
@ -46,19 +12,13 @@ use MIME::Base64;
|
|||||||
use Net::LDAP;
|
use Net::LDAP;
|
||||||
use utf8;
|
use utf8;
|
||||||
|
|
||||||
our $VERSION = '1.0.0';
|
our $VERSION = '1.3.0';
|
||||||
|
|
||||||
## @method boolean prereq()
|
## @method boolean prereq()
|
||||||
# Check if LDAP parameters are set.
|
# Check if LDAP parameters are set.
|
||||||
# @return true if all is OK
|
# @return true if all is OK
|
||||||
sub prereq {
|
sub prereq {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
if ( $self->{notifBase} ) {
|
|
||||||
$self->{ldapConfBase} = $self->{notifBase};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$self->{ldapConfBase} =~ s/[^,]+,/ou=notifications,/;
|
|
||||||
}
|
|
||||||
unless ( $self->{ldapServer} ) {
|
unless ( $self->{ldapServer} ) {
|
||||||
$self->lmLog( '"ldapServer" is required in LDAP notification type',
|
$self->lmLog( '"ldapServer" is required in LDAP notification type',
|
||||||
'error' );
|
'error' );
|
||||||
@ -66,6 +26,10 @@ sub prereq {
|
|||||||
'"ldapServer" is required in LDAP notification type';
|
'"ldapServer" is required in LDAP notification type';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if ( $self->{table} ) {
|
||||||
|
$self->{ldapConfBase} =~ s/^\w+=\w+(,.*)$/ou=$self->{table}$1/;
|
||||||
|
}
|
||||||
|
|
||||||
$self->lmLog( 'Warning: "ldapBindDN" parameter is not set', 'warn' )
|
$self->lmLog( 'Warning: "ldapBindDN" parameter is not set', 'warn' )
|
||||||
unless ( $self->{ldapBindDN} );
|
unless ( $self->{ldapBindDN} );
|
||||||
1;
|
1;
|
||||||
|
@ -81,7 +81,7 @@ sub new {
|
|||||||
|
|
||||||
# Else use the configuration backend
|
# Else use the configuration backend
|
||||||
else {
|
else {
|
||||||
(%$tmp) = ( %{ $self->{lmConf} } );
|
(%$tmp) = ( %{ $conf } );
|
||||||
$class->abort( "notificationStorage not defined",
|
$class->abort( "notificationStorage not defined",
|
||||||
"This parameter is required to use notification system" )
|
"This parameter is required to use notification system" )
|
||||||
unless ( ref($tmp) );
|
unless ( ref($tmp) );
|
||||||
@ -91,8 +91,8 @@ sub new {
|
|||||||
$tmp->{type} =~ s/(CBDI|RDBI)/DBI/; # CDBI/RDBI are DBI
|
$tmp->{type} =~ s/(CBDI|RDBI)/DBI/; # CDBI/RDBI are DBI
|
||||||
|
|
||||||
# If type not File or DBI, abort
|
# If type not File or DBI, abort
|
||||||
$class->abort("Only File or DBI supported for Notifications")
|
$class->abort("Only File, DBI or LDAP supported for Notifications")
|
||||||
unless $tmp->{type} =~ /^(File|DBI)$/;
|
unless $tmp->{type} =~ /^(File|DBI|LDAP)$/;
|
||||||
|
|
||||||
# Force table name
|
# Force table name
|
||||||
$tmp->{table} = 'notifications';
|
$tmp->{table} = 'notifications';
|
||||||
|
@ -433,9 +433,9 @@ sub new {
|
|||||||
$tmp->{type} =~ s/.*:://;
|
$tmp->{type} =~ s/.*:://;
|
||||||
$tmp->{type} =~ s/(CDBI|RDBI)/DBI/; # CDBI/RDBI are DBI
|
$tmp->{type} =~ s/(CDBI|RDBI)/DBI/; # CDBI/RDBI are DBI
|
||||||
|
|
||||||
# If type not File or DBI, abort
|
# If type not File, DBI or LDAP, abort
|
||||||
$self->abort("Only File or DBI supported for Notifications")
|
$self->abort("Only File, DBI or LDAP supported for Notifications")
|
||||||
unless $tmp->{type} =~ /^(File|DBI)$/;
|
unless $tmp->{type} =~ /^(File|DBI|LDAP)$/;
|
||||||
|
|
||||||
# Force table name
|
# Force table name
|
||||||
$tmp->{table} = 'notifications';
|
$tmp->{table} = 'notifications';
|
||||||
|
Loading…
Reference in New Issue
Block a user