dataset/seed/openldap/templates/users_mod.ldif

70 lines
2.3 KiB
Text
Raw Normal View History

2023-06-23 08:12:05 +02:00
{% set username="rougail_test@silique.fr" %}
{% set username_family="rougail_test@gnunux.info" %}
{% set name_family="gnunux" %}
2022-03-15 12:12:09 +01:00
# Remote
2023-06-23 08:12:05 +02:00
{% 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 }}
2022-03-15 12:12:09 +01:00
changetype: modify
replace: userPassword
2023-06-23 08:12:05 +02:00
userPassword:: {{ password|ssha_encode }}
2022-03-15 12:12:09 +01:00
2023-06-23 08:12:05 +02:00
{% endfor %}
2022-05-23 08:54:15 +02:00
# Users
2023-06-23 08:12:05 +02:00
{% 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 }}
2022-05-23 08:54:15 +02:00
changetype: modify
#add: objectClass
#objectClass: inetLocalMailRecipient
#-
replace: mailLocalAddress
2023-06-23 08:12:05 +02:00
mailLocalAddress: {{ user }}
{% if aliases %}
{% for alias in aliases %}
mailLocalAddress: {{ alias }}
{% endfor %}
{% endif %}
2022-05-23 08:54:15 +02:00
2023-06-23 08:12:05 +02:00
{% endfor %}
2022-07-07 09:37:49 +02:00
# Groups
2023-06-23 08:12:05 +02:00
{% set groupdn = ldap_group_dn %}
{% for group, members in groups.items() %}
dn: cn={{ group }},{{ groupdn }}
2022-07-07 09:37:49 +02:00
changetype: modify
replace: member
2023-06-23 08:12:05 +02:00
{% for member in members %}
member: {{ member }}
{% endfor %}
2022-07-07 09:37:49 +02:00
2023-06-23 08:12:05 +02:00
{% endfor %}