diff options
Diffstat (limited to 'Kernel')
-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', + ); + } } } |