69 lines
2.3 KiB
Text
69 lines
2.3 KiB
Text
{% set username="rougail_test@silique.fr" %}
|
|
{% set username_family="rougail_test@gnunux.info" %}
|
|
{% set name_family="gnunux" %}
|
|
# Remote
|
|
{% set acc = [] %}
|
|
{% for idx in range(3) %}
|
|
{% set name = 'remote_test' + idx|string %}
|
|
{{ acc.append(('cn=' + name + ',' + ldap_base_dn, name|get_password(server_name=domain_name_eth0, description="remote account", type="cleartext", hide=hide_secret, temporary=True))) }}
|
|
{% endfor %}
|
|
{% for remote in accounts.remotes %}
|
|
{% set name = remote|normalize_family %}
|
|
{{ acc.append((accounts['remote_' + name]['dn_' + name], accounts['remote_' + name]['password_' + name])) }}
|
|
{% endfor %}
|
|
{% for dn, password in acc %}
|
|
dn: {{ dn }}
|
|
changetype: modify
|
|
replace: userPassword
|
|
userPassword:: {{ password|ssha_encode }}
|
|
|
|
{% endfor %}
|
|
# Users
|
|
{% set userdn = 'cn=' + username + ',' + ldap_base_dn|calc_ldapclient_base_dn %}
|
|
{% set userfamilydn = 'cn=' + username_family + ',' + ldap_base_dn|calc_ldapclient_base_dn(family_name=name_family) %}
|
|
{% set acc = [(userdn, username, ['alias_' + username]),
|
|
(userfamilydn, username_family, ['alias_' + username_family]),
|
|
] %}
|
|
{% set groups = {'users': [userdn],
|
|
name_family: [userfamilydn],
|
|
} %}
|
|
{% set users = ldap_user_dn %}
|
|
{% for user in accounts.users.ldap_user_mail %}
|
|
{% set userdn = 'cn=' + user + ',' + users %}
|
|
{{ groups['users'].append(userdn) }}
|
|
{{ acc.append((userdn, user, user.ldap_user_aliases)) }}
|
|
{% endfor %}
|
|
{% for family in accounts.families %}
|
|
{% set families = ldap_base_dn|calc_ldapclient_base_dn(family) %}
|
|
{% for user in accounts['family_' + family]['users_' + family]['ldap_user_mail_' + family] %}
|
|
{% set userdn = 'cn=' + user + ',' + families %}
|
|
{{ groups.setdefault(family, []).append(userdn) }}
|
|
{{ acc.append((userdn, user, user['ldap_user_aliases_' + family])) }}
|
|
{% endfor %}
|
|
{% endfor %}
|
|
{% for userdn, user, aliases in acc %}
|
|
dn: {{ userdn }}
|
|
changetype: modify
|
|
#add: objectClass
|
|
#objectClass: inetLocalMailRecipient
|
|
#-
|
|
replace: mailLocalAddress
|
|
mailLocalAddress: {{ user }}
|
|
{% if aliases %}
|
|
{% for alias in aliases %}
|
|
mailLocalAddress: {{ alias }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
# Groups
|
|
{% set groupdn = ldap_group_dn %}
|
|
{% for group, members in groups.items() %}
|
|
dn: cn={{ group }},{{ groupdn }}
|
|
changetype: modify
|
|
replace: member
|
|
{% for member in members %}
|
|
member: {{ member }}
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|