Add support for domain configuration in zmldapsync
This commit is contained in:
parent
3e858dd880
commit
b79a215211
|
@ -15,6 +15,7 @@ The goals are :
|
|||
A few other features are included, like :
|
||||
* Creating domains
|
||||
* Creating / removing domain aliases
|
||||
* Configure domain attributes
|
||||
|
||||
All from a simple yaml configuration file
|
||||
|
||||
|
@ -152,6 +153,14 @@ domains:
|
|||
domain_aliases:
|
||||
- mail.corp2.com
|
||||
- corp4.net
|
||||
# A list of attr which will be set using zmprov modifyDomain. The key is the Zimbra attr in LDAP, as you can get/set with zmprov
|
||||
additional_domain_attrs:
|
||||
zimbraVirtualHostname:
|
||||
- zm.corep.com
|
||||
- mail.corp2.com
|
||||
zimbraPublicServicePort: 443
|
||||
zimbraPublicServiceProtocol: https
|
||||
zimbraPublicServiceHostname: mail.corp2.com
|
||||
```
|
||||
|
||||
## Command line
|
||||
|
|
|
@ -130,7 +130,11 @@ DOMAIN: foreach my $domain ( keys $conf->{domains} ) {
|
|||
}
|
||||
|
||||
# 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
|
||||
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 " .
|
||||
join( ' or ', @{ $conf->{domains}->{$domain}->{ldap}->{servers} } ) );
|
||||
|
||||
|
@ -873,16 +904,6 @@ sub search_zim_domain {
|
|||
# Search in Zimbra LDAP if the required domain exists
|
||||
my $zim_domain_search = $zim_ldap->ldap->search(
|
||||
filter => "(&(objectClass=zimbraDomain)(zimbraDomainName=$dom)(!(zimbraDomainAliasTargetId=*)))",
|
||||
attrs => [
|
||||
'zimbraDomainName',
|
||||
'zimbraDomainType',
|
||||
'zimbraId',
|
||||
'zimbraAuthMechAdmin',
|
||||
'zimbraAuthMech',
|
||||
'zimbraAuthLdapSearchBindDn',
|
||||
'zimbraAuthLdapSearchBindPassword',
|
||||
'zimbraAuthLdapSearchFilter'
|
||||
]
|
||||
);
|
||||
return $zim_domain_search;
|
||||
}
|
||||
|
@ -1039,6 +1060,7 @@ sub get_default_conf {
|
|||
create_if_missing => 0,
|
||||
setup_ldap_auth => 0,
|
||||
domain_aliases => undef,
|
||||
additional_domain_attrs => {}
|
||||
};
|
||||
|
||||
# If some attribute mapping is defined in the provided conf
|
||||
|
|
Loading…
Reference in New Issue
Block a user