dataset/seed/openldap/templates/users.ldif

148 lines
4.5 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-08 19:42:28 +01:00
# BaseDN
2022-06-24 19:00:16 +02:00
%set groups = {}
dn: %%ldapclient_base_dn
%set %%attribute, %%organization = %%ldapclient_base_dn.split(',', 1)[0].split('=')
2022-03-08 19:42:28 +01:00
%%attribute: %%organization
objectClass: top
%if %%attribute == 'o'
objectClass: organization
%else
objectClass: organizationalUnit
%end if
# 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, %%name, %%get_password(server_name=%%domain_name_eth0, username=%%name, description="remote account", type="cleartext", hide=%%hide_secret, temporary=True)))%slurp
%end for
2022-03-08 19:42:28 +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], %%remote, %%accounts['remote_' + %%name]['password_' + %%name]))%slurp
%end for
%for %%dn, %%remote, %%password in %%acc
dn: %%dn
2022-03-08 19:42:28 +01:00
cn: %%remote
sn: %%remote
uid: %%remote
2022-07-07 09:37:49 +02:00
userPassword:: %%ssha_encode(%%password)
2022-03-08 19:42:28 +01:00
objectClass: top
objectClass: inetOrgPerson
%end for
2022-05-07 08:11:18 +02:00
# Accounts
2022-06-26 19:33:44 +02:00
dn: %%ldap_account_dn
2022-05-07 08:11:18 +02:00
ou: accounts
objectClass: top
objectClass: organizationalUnit
2022-06-24 19:00:16 +02:00
## Accounts users
2022-06-26 19:33:44 +02:00
%set %%users = %%ldap_user_dn
2022-05-07 08:11:18 +02:00
dn: %%users
2022-03-08 19:42:28 +01:00
ou: users
objectClass: top
objectClass: organizationalUnit
2022-07-16 22:16:24 +02:00
%set %%userdn = 'cn=' + %%username + ',' + %%calc_ldapclient_base_dn(%%ldapclient_base_dn)
%set %%userfamilydn = 'cn=' + %%username_family + ',' + %%calc_ldapclient_base_dn(%%ldapclient_base_dn, family_name=%%name_family)
%set %%acc = [(%%userdn, %%username, %%get_password(server_name='test', username=%%username, description="test", type="cleartext", hide=%%hide_secret, temporary=True), 'Rougail', 'Test', 'rougail_test', [], 'users'),
(%%userfamilydn, %%username_family, %%get_password(server_name='test', username=%%username_family, description='test', type="cleartext", hide=%%hide_secret, temporary=True), 'Rougail', 'Test', 'rougail_test_gnunux', [], %%name_family),
]
%set %%groups['users'] = [%%userdn]
%set %%groups[%%name_family] = [%%userfamilydn]
2022-03-08 19:42:28 +01:00
%for %%user in %%accounts.users.ldap_user_mail
2022-06-24 19:00:16 +02:00
%set %%userdn = "cn=" + %%user + "," + %%users
2022-07-16 22:16:24 +02:00
%%acc.append((%%userdn, %%user, %%user.ldap_user_password, %%user.ldap_user_sn, %%user.ldap_user_gn, %%user.ldap_user_uid, %%user.ldap_user_aliases, 'users'))%slurp
%%groups.setdefault('users', []).append(%%userdn)%slurp
2022-03-08 19:42:28 +01:00
%end for
2022-05-07 08:11:18 +02:00
## Families
2022-06-24 19:00:16 +02:00
dn: %%calc_ldapclient_base_dn(%%ldapclient_base_dn, family_name='-')
2022-04-28 21:48:16 +02:00
ou: families
objectClass: top
objectClass: organizationalUnit
%for %%family in %%accounts.families
2022-06-24 19:00:16 +02:00
%set %%families = %%calc_ldapclient_base_dn(%%ldapclient_base_dn, family_name=%%family)
2022-05-07 08:11:18 +02:00
dn: %%families
2022-04-28 21:48:16 +02:00
ou: %%family
objectClass: top
objectClass: organizationalUnit
%for %%user in %%accounts['family_' + %%family]['users_' + %%family]['ldap_user_mail_' + %%family]
2022-06-24 19:00:16 +02:00
%set %%userdn = "cn=" + %%user + "," + %%families
2022-07-16 22:16:24 +02:00
%%groups.setdefault(%%family, []).append(%%userdn)%slurp
%%acc.append((%%userdn, %%user, %%user['ldap_user_password_' + %%family], %%user['ldap_user_sn_' + %%family], %%user['ldap_user_gn_' + %%family], %%user['ldap_user_uid_' + %%family], %%user['ldap_user_aliases_' + %%family], %%family))%slurp
#pouet
#dn: %%userdn
#cn: %%user
#mail: %%user
#sn:
#givenName:
#uid:
#userPassword:: %%ssha_encode()
#homeDirectory: /srv/home/families/%%family/%%user
#mailLocalAddress: %%user
# %if %%user['ldap_user_aliases_' + %%family]
# %for %%alias in
#mailLocalAddress: %%alias
# %end for
# %end if
#uidNumber: 0
#gidNumber: 0
#objectClass: top
#objectClass: inetOrgPerson
#objectClass: posixAccount
#objectClass: inetLocalMailRecipient
#
# %end for
#%end for
%end for
%end for
%for %%userdn, %%user, %%password, %%sn, %%gn, %%uid, %%aliases, %%family in %%acc
2022-06-24 19:00:16 +02:00
dn: %%userdn
2022-04-28 21:48:16 +02:00
cn: %%user
mail: %%user
2022-07-16 22:16:24 +02:00
sn: %%sn
givenName: %%gn
uid: %%uid
userPassword:: %%ssha_encode(%%password)
%if %%family == 'users'
homeDirectory: /srv/home/users/%%user
%else
2022-05-04 10:29:03 +02:00
homeDirectory: /srv/home/families/%%family/%%user
2022-07-16 22:16:24 +02:00
%end if
2022-05-23 08:54:15 +02:00
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-04 10:29:03 +02:00
uidNumber: 0
gidNumber: 0
2022-04-28 21:48:16 +02:00
objectClass: top
objectClass: inetOrgPerson
2022-05-04 10:29:03 +02:00
objectClass: posixAccount
2022-05-23 08:54:15 +02:00
objectClass: inetLocalMailRecipient
2022-04-28 21:48:16 +02:00
%end for
2022-06-24 19:00:16 +02:00
## Groups
2022-06-26 19:33:44 +02:00
%set %%groupdn = %%ldap_group_dn
2022-06-24 19:00:16 +02:00
dn: %%groupdn
ou: groups
objectClass: top
objectClass: organizationalUnit
%for %%group, %%members in %%groups.items()
dn: cn=%%group,%%groupdn
cn: %%group
objectclass: top
objectclass: groupOfNames
%for %%member in %%members
member: %%member
%end for
%end for