dataset/seed/openldap/templates/users_mod.ldif

70 lines
2.3 KiB
Text
Raw Normal View History

2022-07-16 22:16:24 +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
2022-07-07 09:37:49 +02:00
%set %%acc = []
%for %%idx in %%range(3)
%set %%name = 'remote_test' + %%str(%%idx)
%%acc.append(('cn=' + %%name + ',' + %%ldapclient_base_dn, %%get_password(server_name=%%domain_name_eth0, username=%%name, description="remote account", type="cleartext", hide=%%hide_secret, temporary=True)))%slurp
%end for
2022-03-15 12:12:09 +01:00
%for %%remote in %%accounts.remotes
%set %%name = %%normalize_family(%%remote)
2022-07-07 09:37:49 +02:00
%%acc.append((%%accounts['remote_' + %%name]['dn_' + %%name], %%accounts['remote_' + %%name]['password_' + %%name]))%slurp
%end for
%for %%dn, %%password in %%acc
dn: %%dn
2022-03-15 12:12:09 +01:00
changetype: modify
replace: userPassword
2022-07-07 09:37:49 +02:00
userPassword:: %%ssha_encode(%%password)
2022-03-15 12:12:09 +01:00
%end for
2022-05-23 08:54:15 +02:00
# Users
2022-07-16 22:16:24 +02:00
%set %%userdn = 'cn=' + %%username + ',' + %%ldapclient_base_dn
%set %%userfamilydn = 'cn=' + %%username_family + ',' + %%calc_ldapclient_base_dn(%%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],
}
2022-06-26 19:33:44 +02:00
%set %%users = %%ldap_user_dn
2022-05-23 08:54:15 +02:00
%for %%user in %%accounts.users.ldap_user_mail
2022-07-07 09:37:49 +02:00
%set %%userdn = 'cn=' + %%user + ',' + %%users
2022-07-16 22:16:24 +02:00
%%groups['users'].append(%%userdn)%slurp
%%acc.append((%%userdn, %%user, %%user.ldap_user_aliases))%slurp
2022-05-23 08:54:15 +02:00
%end for
%for %%family in %%accounts.families
2022-06-24 19:00:16 +02:00
%set %%families = %%calc_ldapclient_base_dn(%%ldapclient_base_dn, %%family)
2022-05-23 08:54:15 +02:00
%for %%user in %%accounts['family_' + %%family]['users_' + %%family]['ldap_user_mail_' + %%family]
2022-07-07 09:37:49 +02:00
%set %%userdn = 'cn=' + %%user + ',' + %%families
%%groups.setdefault(%%family, []).append(%%userdn)%slurp
2022-07-16 22:16:24 +02:00
%%acc.append((%%userdn, %%user, %%user['ldap_user_aliases_' + %%family]))%slurp
%end for
%end for
%for %%userdn, %%user, %%aliases in %%acc
2022-07-07 09:37:49 +02:00
dn: %%userdn
2022-05-23 08:54:15 +02:00
changetype: modify
#add: objectClass
#objectClass: inetLocalMailRecipient
#-
replace: mailLocalAddress
mailLocalAddress: %%user
2022-07-16 22:16:24 +02:00
%if %%aliases
%for %%alias in %%aliases
2022-05-23 08:54:15 +02:00
mailLocalAddress: %%alias
2022-07-16 22:16:24 +02:00
%end for
%end if
2022-05-23 08:54:15 +02:00
%end for
2022-07-07 09:37:49 +02:00
# 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
%end for
%end for