sub call_find_user { my($attribute, $search) = @_; if(length($search)){ my $ldap = bind_ldap_new(\@LDAP_SERVERS,$LDAP_PORT,$LDAP_BIND_DN,$CA_FILE,$LDAP_BIND_PASS); my $mesg = search_ldap($ldap, $BASE_DNUSERS_SEARCH, "($search=$attribute)", $SCOPE); my $entry = $mesg->entry(0); if(defined($entry)) { my $localdn = $entry->dn(); display_msg("dn: $localdn\n", "other"); unbind_ldap($ldap); return 1; } unbind_ldap($ldap); } } ----- sub bind_ldap_new { my ($ldap_servers,$ldap_port,$ldap_bind_dn,$ldap_ca_file,$ldap_password) = @_; my @LOCAL_LDAP_SERVERS = @{$ldap_servers}; my $ldap = Net::LDAP->new( @LOCAL_LDAP_SERVERS, port => $ldap_port, timeout => 3); $ldap-> start_tls( verify => 'optional', cafile => $ldap_ca_file) or die "ERROR: Can't connect to ldap servers($@)\n"; my $mesg = ldapassert($ldap->bind($ldap_bind_dn, password=>$ldap_password),"Binding to ldap server"); return $ldap; } .... my @LDAP_SERVERS=('ldap1.example.com','ldap2.example.com'); if($changeOnUser && call_find_user("test.user","uid")) { modify_zimbra_account(\%hashValues); }