forked from stove/dataset
127 lines
3.3 KiB
Text
127 lines
3.3 KiB
Text
%set name_family = 'gnunux'
|
|
# BaseDN
|
|
%set groups = {}
|
|
dn: %%ldapclient_base_dn
|
|
%set %%attribute, %%organization = %%ldapclient_base_dn.split(',', 1)[0].split('=')
|
|
%%attribute: %%organization
|
|
objectClass: top
|
|
%if %%attribute == 'o'
|
|
objectClass: organization
|
|
%else
|
|
objectClass: organizationalUnit
|
|
%end if
|
|
|
|
# Remote
|
|
%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
|
|
%for %%remote in %%accounts.remotes
|
|
%set %%name = %%normalize_family(%%remote)
|
|
%%acc.append((%%accounts['remote_' + %%name]['dn_' + %%name], %%remote, %%accounts['remote_' + %%name]['password_' + %%name]))%slurp
|
|
%end for
|
|
%for %%dn, %%remote, %%password in %%acc
|
|
dn: %%dn
|
|
cn: %%remote
|
|
sn: %%remote
|
|
uid: %%remote
|
|
userPassword:: %%ssha_encode(%%password)
|
|
objectClass: top
|
|
objectClass: inetOrgPerson
|
|
|
|
%end for
|
|
# Accounts
|
|
dn: %%ldap_account_dn
|
|
ou: accounts
|
|
objectClass: top
|
|
objectClass: organizationalUnit
|
|
|
|
## Accounts users
|
|
%set %%users = %%ldap_user_dn
|
|
dn: %%users
|
|
ou: users
|
|
objectClass: top
|
|
objectClass: organizationalUnit
|
|
|
|
%for %%user in %%accounts.users.ldap_user_mail
|
|
%set %%userdn = "cn=" + %%user + "," + %%users
|
|
%%groups.setdefault('users', []).append(%%userdn)
|
|
dn: %%userdn
|
|
cn: %%user
|
|
mail: %%user
|
|
sn: %%user.ldap_user_sn
|
|
givenName: %%user.ldap_user_gn
|
|
uid: %%user.ldap_user_uid
|
|
userPassword:: %%ssha_encode(%%user.ldap_user_password)
|
|
homeDirectory: /srv/home/users/%%user
|
|
mailLocalAddress: %%user
|
|
%if %%user.ldap_user_aliases
|
|
%for %%alias in %%user.ldap_user_aliases
|
|
mailLocalAddress: %%alias
|
|
%end for
|
|
%end if
|
|
uidNumber: 0
|
|
gidNumber: 0
|
|
objectClass: top
|
|
objectClass: inetOrgPerson
|
|
objectClass: posixAccount
|
|
objectClass: inetLocalMailRecipient
|
|
|
|
%end for
|
|
## Families
|
|
dn: %%calc_ldapclient_base_dn(%%ldapclient_base_dn, family_name='-')
|
|
ou: families
|
|
objectClass: top
|
|
objectClass: organizationalUnit
|
|
|
|
%for %%family in %%accounts.families
|
|
%set %%families = %%calc_ldapclient_base_dn(%%ldapclient_base_dn, family_name=%%family)
|
|
dn: %%families
|
|
ou: %%family
|
|
objectClass: top
|
|
objectClass: organizationalUnit
|
|
|
|
%for %%user in %%accounts['family_' + %%family]['users_' + %%family]['ldap_user_mail_' + %%family]
|
|
%set %%userdn = "cn=" + %%user + "," + %%families
|
|
%%groups.setdefault(%%family, []).append(%%userdn)
|
|
dn: %%userdn
|
|
cn: %%user
|
|
mail: %%user
|
|
sn: %%user['ldap_user_sn_' + %%family]
|
|
givenName: %%user['ldap_user_gn_' + %%family]
|
|
uid: %%user['ldap_user_uid_' + %%family]
|
|
userPassword:: %%ssha_encode(%%user['ldap_user_password_' + %%family])
|
|
homeDirectory: /srv/home/families/%%family/%%user
|
|
mailLocalAddress: %%user
|
|
%if %%user['ldap_user_aliases_' + %%family]
|
|
%for %%alias in %%user['ldap_user_aliases_' + %%family]
|
|
mailLocalAddress: %%alias
|
|
%end for
|
|
%end if
|
|
uidNumber: 0
|
|
gidNumber: 0
|
|
objectClass: top
|
|
objectClass: inetOrgPerson
|
|
objectClass: posixAccount
|
|
objectClass: inetLocalMailRecipient
|
|
|
|
%end for
|
|
%end for
|
|
## Groups
|
|
%set %%groupdn = %%ldap_group_dn
|
|
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
|