RE: [dev] Proposed path to allow LDAP server redundancy

You wrote (18. Mai 2004 06:21):
I have included a diff file that contains the modifications made to each file. The basic idea is a foreach loop that loops through a list of servers looking for a valid host. The loop quits as soon as the first active host is found. The list is passed in from Config.pm via a reference to a regular array.
I cannot open your file, could you please resend it to me inline?
Here it is. Index: Kernel/System/CustomerAuth/LDAP.pm =================================================================== --- Kernel/System/CustomerAuth/LDAP.pm (revision 15) +++ Kernel/System/CustomerAuth/LDAP.pm (revision 16) @@ -100,14 +100,25 @@ # -- # ldap connect and bind (maybe with SearchUserDN and SearchUserPw) # -- - my $LDAP = Net::LDAP->new($Self->{Host}) or die "$@"; - if (!$LDAP->bind(dn => $Self->{SearchUserDN}, password => $Self->{SearchUserPw})) { - $Self->{LogObject}->Log( - Priority => 'error', - Message => "First bind failed!", - ); - return; - } + my $LDAP; + my $Host; + foreach $Host (@{$Self->{Host}}) { + $LDAP = Net::LDAP->new($Host) or next; + if ($Self->{Debug} > 0) { + $Self->{LogObject}->Log( + Priority => 'notice', + Message => "Found an active LDAP server at: $Host", + ); + } + last; + } + if (!$LDAP->bind(dn => $Self->{SearchUserDN}, password => $Self->{SearchUserPw})) { + $Self->{LogObject}->Log( + Priority => 'error', + Message => "First bind failed against $Host!", + ); + return; + } # -- # perform user search # -- Index: Kernel/System/CustomerUser/LDAP.pm =================================================================== --- Kernel/System/CustomerUser/LDAP.pm (revision 15) +++ Kernel/System/CustomerUser/LDAP.pm (revision 16) @@ -49,14 +49,25 @@ || die "Need CustomerUser->CustomerID in Kernel/Config.pm"; # ldap connect and bind (maybe with SearchUserDN and SearchUserPw) - $Self->{LDAP} = Net::LDAP->new($Self->{Host}) or die "$@"; - if (!$Self->{LDAP}->bind(dn => $Self->{SearchUserDN}, password => $Self->{SearchUserPw})) { - $Self->{LogObject}->Log( - Priority => 'error', - Message => "First bind failed!", - ); - return; - } + + my $Host; + foreach $Host (@{$Self->{Host}}) { + $Self->{LDAP} = Net::LDAP->new($Host) or next; + if ($Self->{Debug} > 0) { + $Self->{LogObject}->Log( + Priority => 'notice', + Message => "Found an active LDAP server at: $Host", + ); + } + last; + } + if (!$Self->{LDAP}->bind(dn => $Self->{SearchUserDN}, password => $Self->{SearchUserPw})) { + $Self->{LogObject}->Log( + Priority => 'error', + Message => "First bind failed against $Host!", + ); + return; + } return $Self; } # -- Index: Kernel/System/Auth/LDAP.pm =================================================================== --- Kernel/System/Auth/LDAP.pm (revision 15) +++ Kernel/System/Auth/LDAP.pm (revision 16) @@ -106,14 +106,25 @@ # -- # ldap connect and bind (maybe with SearchUserDN and SearchUserPw) # -- - my $LDAP = Net::LDAP->new($Self->{Host}) or die "$@"; - if (!$LDAP->bind(dn => $Self->{SearchUserDN}, password => $Self->{SearchUserPw})) { - $Self->{LogObject}->Log( - Priority => 'error', - Message => "First bind failed!", - ); - return; - } + my $LDAP; + my $Host; + foreach $Host (@{$Self->{Host}}) { + $LDAP = Net::LDAP->new($Host) or next; + if ($Self->{Debug} > 0) { + $Self->{LogObject}->Log( + Priority => 'notice', + Message => "Found an active LDAP server at: $Host", + ); + } + last; + } + if (!$LDAP->bind(dn => $Self->{SearchUserDN}, password => $Self->{SearchUserPw})) { + $Self->{LogObject}->Log( + Priority => 'error', + Message => "First bind failed against $Host!", + ); + return; + } # -- # perform user search # --
participants (1)
-
Tyler Hepworth