|
|
@ -130,7 +130,11 @@ DOMAIN: foreach my $domain ( keys $conf->{domains} ) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Get LDAP entry representing the domain |
|
|
|
# Get LDAP entry representing the domain |
|
|
|
my $domain_entry = ldap2hashref( $zim_domain_search, 'zimbraDomainName' )->{$domain}; |
|
|
|
my $domain_entry = ldap2hashref( |
|
|
|
|
|
|
|
$zim_domain_search, |
|
|
|
|
|
|
|
'zimbraDomainName', |
|
|
|
|
|
|
|
[ 'zimbraVirtualHostname' ] |
|
|
|
|
|
|
|
)->{$domain}; |
|
|
|
|
|
|
|
|
|
|
|
# Check if auth is set to ad or ldap |
|
|
|
# Check if auth is set to ad or ldap |
|
|
|
if ( not defined $domain_entry->{zimbraAuthMech} or |
|
|
|
if ( not defined $domain_entry->{zimbraAuthMech} or |
|
|
@ -166,6 +170,33 @@ DOMAIN: foreach my $domain ( keys $conf->{domains} ) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Domain configuration, as defined in the conf |
|
|
|
|
|
|
|
if (defined $conf->{domains}->{$domain}->{zimbra}->{additional_domain_attrs} ) { |
|
|
|
|
|
|
|
my $attr_mod = ''; |
|
|
|
|
|
|
|
foreach my $attr (keys $conf->{domains}->{$domain}->{zimbra}->{additional_domain_attrs} ) { |
|
|
|
|
|
|
|
if ( ref $conf->{domains}->{$domain}->{zimbra}->{additional_domain_attrs}->{$attr} eq 'ARRAY' ) { |
|
|
|
|
|
|
|
my $attr_diff = Array::Diff->diff( |
|
|
|
|
|
|
|
$domain_entry->{$attr} || [], |
|
|
|
|
|
|
|
$conf->{domains}->{$domain}->{zimbra}->{additional_domain_attrs}->{$attr} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
foreach ( @{ $attr_diff->added } ) { |
|
|
|
|
|
|
|
$attr_mod .= " +$attr " . zim_attr_value($_); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
foreach ( @{ $attr_diff->deleted } ) { |
|
|
|
|
|
|
|
$attr_mod .= " -$attr " . zim_attr_value($_); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if ( ($domain_entry->{$attr} || '') ne $conf->{domains}->{$domain}->{zimbra}->{additional_domain_attrs}->{$attr} ) { |
|
|
|
|
|
|
|
$attr_mod .= " $attr " . zim_attr_value( $conf->{domains}->{$domain}->{zimbra}->{additional_domain_attrs}->{$attr} ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if ($attr_mod ne ''){ |
|
|
|
|
|
|
|
log_info( "Domain $domain configuration must be updated ($attr_mod)" ); |
|
|
|
|
|
|
|
send_zmprov_cmd( "modifyDomain $domain $attr_mod" ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
log_verbose( "Trying to connect to " . |
|
|
|
log_verbose( "Trying to connect to " . |
|
|
|
join( ' or ', @{ $conf->{domains}->{$domain}->{ldap}->{servers} } ) ); |
|
|
|
join( ' or ', @{ $conf->{domains}->{$domain}->{ldap}->{servers} } ) ); |
|
|
|
|
|
|
|
|
|
|
@ -873,16 +904,6 @@ sub search_zim_domain { |
|
|
|
# Search in Zimbra LDAP if the required domain exists |
|
|
|
# Search in Zimbra LDAP if the required domain exists |
|
|
|
my $zim_domain_search = $zim_ldap->ldap->search( |
|
|
|
my $zim_domain_search = $zim_ldap->ldap->search( |
|
|
|
filter => "(&(objectClass=zimbraDomain)(zimbraDomainName=$dom)(!(zimbraDomainAliasTargetId=*)))", |
|
|
|
filter => "(&(objectClass=zimbraDomain)(zimbraDomainName=$dom)(!(zimbraDomainAliasTargetId=*)))", |
|
|
|
attrs => [ |
|
|
|
|
|
|
|
'zimbraDomainName', |
|
|
|
|
|
|
|
'zimbraDomainType', |
|
|
|
|
|
|
|
'zimbraId', |
|
|
|
|
|
|
|
'zimbraAuthMechAdmin', |
|
|
|
|
|
|
|
'zimbraAuthMech', |
|
|
|
|
|
|
|
'zimbraAuthLdapSearchBindDn', |
|
|
|
|
|
|
|
'zimbraAuthLdapSearchBindPassword', |
|
|
|
|
|
|
|
'zimbraAuthLdapSearchFilter' |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
return $zim_domain_search; |
|
|
|
return $zim_domain_search; |
|
|
|
} |
|
|
|
} |
|
|
@ -1039,6 +1060,7 @@ sub get_default_conf { |
|
|
|
create_if_missing => 0, |
|
|
|
create_if_missing => 0, |
|
|
|
setup_ldap_auth => 0, |
|
|
|
setup_ldap_auth => 0, |
|
|
|
domain_aliases => undef, |
|
|
|
domain_aliases => undef, |
|
|
|
|
|
|
|
additional_domain_attrs => {} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
# If some attribute mapping is defined in the provided conf |
|
|
|
# If some attribute mapping is defined in the provided conf |
|
|
|