diff options
author | Alexander Sulfrian <alex@spline.inf.fu-berlin.de> | 2014-12-06 04:26:42 +0100 |
---|---|---|
committer | Alexander Sulfrian <alex@spline.inf.fu-berlin.de> | 2014-12-06 04:26:42 +0100 |
commit | d7d7d7af5b11ffe493c27666efc79d92ddc56f6d (patch) | |
tree | 15b1dbcf08660677997fd53f416731f1bee44765 /Kernel/System | |
parent | 6c9c1db0c25d5d0c2b941ea6ba38fa52f1c39e93 (diff) | |
download | custom-d7d7d7af5b11ffe493c27666efc79d92ddc56f6d.tar.gz custom-d7d7d7af5b11ffe493c27666efc79d92ddc56f6d.tar.bz2 custom-d7d7d7af5b11ffe493c27666efc79d92ddc56f6d.zip |
Kernel::System::Auth::Sync::LDAP: add fix for complex mappings
We need a complex mapping for LDAP Sync, because the required fields
does not appear as single fileds in LDAP. No you could set a sub ref
as SyncMap in the configuration, that gets the LDAP Entry and sould
return the poppulated user object.
Diffstat (limited to 'Kernel/System')
-rw-r--r-- | Kernel/System/Auth/Sync/LDAP.pm | 79 |
1 files changed, 42 insertions, 37 deletions
diff --git a/Kernel/System/Auth/Sync/LDAP.pm b/Kernel/System/Auth/Sync/LDAP.pm index 3c2632d..5f83068 100644 --- a/Kernel/System/Auth/Sync/LDAP.pm +++ b/Kernel/System/Auth/Sync/LDAP.pm @@ -223,48 +223,53 @@ sub Sync { # get whole user dn my %SyncUser; for my $Entry ( $Result->all_entries() ) { - for my $Key ( sort keys %{$UserSyncMap} ) { - - # detect old config setting - if ( $Key =~ m{ \A (?: Firstname | Lastname | Email ) }xms ) { - $Key = 'User' . $Key; - $Kernel::OM->Get('Kernel::System::Log')->Log( - Priority => 'error', - Message => 'Old config setting detected, please use the new one ' - . 'from Kernel/Config/Defaults.pm (User* has been added!).', - ); - } + if (ref $UserSyncMap eq 'CODE') { + %SyncUser = $UserSyncMap->($Entry); + } + else { + for my $Key ( sort keys %{$UserSyncMap} ) { + + # detect old config setting + if ( $Key =~ m{ \A (?: Firstname | Lastname | Email ) }xms ) { + $Key = 'User' . $Key; + $Kernel::OM->Get('Kernel::System::Log')->Log( + Priority => 'error', + Message => 'Old config setting detected, please use the new one ' + . 'from Kernel/Config/Defaults.pm (User* has been added!).', + ); + } - my $AttributeNames = $UserSyncMap->{$Key}; - if ( ref $AttributeNames ne 'ARRAY' ) { - $AttributeNames = [$AttributeNames]; - } - ATTRIBUTE_NAME: - for my $AttributeName ( @{$AttributeNames} ) { - if ( $AttributeName =~ /^_/ ) { - $SyncUser{$Key} = substr( $AttributeName, 1 ); - last ATTRIBUTE_NAME; + my $AttributeNames = $UserSyncMap->{$Key}; + if ( ref $AttributeNames ne 'ARRAY' ) { + $AttributeNames = [$AttributeNames]; } - elsif ( $Entry->get_value($AttributeName) ) { - $SyncUser{$Key} = $Entry->get_value($AttributeName); - last ATTRIBUTE_NAME; + ATTRIBUTE_NAME: + for my $AttributeName ( @{$AttributeNames} ) { + if ( $AttributeName =~ /^_/ ) { + $SyncUser{$Key} = substr( $AttributeName, 1 ); + last ATTRIBUTE_NAME; + } + elsif ( $Entry->get_value($AttributeName) ) { + $SyncUser{$Key} = $Entry->get_value($AttributeName); + last ATTRIBUTE_NAME; + } } - } - # e. g. set utf-8 flag - $SyncUser{$Key} = $Self->_ConvertFrom( - $SyncUser{$Key}, - 'utf-8', - ); - } - if ( $Entry->get_value('userPassword') ) { - $SyncUser{UserPw} = $Entry->get_value('userPassword'); + # e. g. set utf-8 flag + $SyncUser{$Key} = $Self->_ConvertFrom( + $SyncUser{$Key}, + 'utf-8', + ); + } + if ( $Entry->get_value('userPassword') ) { + $SyncUser{UserPw} = $Entry->get_value('userPassword'); - # e. g. set utf-8 flag - $SyncUser{UserPw} = $Self->_ConvertFrom( - $SyncUser{UserPw}, - 'utf-8', - ); + # e. g. set utf-8 flag + $SyncUser{UserPw} = $Self->_ConvertFrom( + $SyncUser{UserPw}, + 'utf-8', + ); + } } } |