LdapBundle
LdapBundle copied to clipboard
Allow roles to be loaded recursively
For large user bases, LDAP admins may wish to assign roles based on user groups.
When loading roles, the bundle should not only search for groups the user directly belongs to, but also to any ancestor groups of those groups. That way, roles assigned by user groups will be assigned correctly.
:+1: for this PR. This would be a very nice feature to have.
Maybe an additional config option that alters the behaviour of addLdapRoles. With addLdapRoles rather than checking for various flags it could be refactored to separate methods. To get memberOf from LDAP user :
if (true === $this->params['client']['get_roles_from_user']) { $tab = array(); // required or PHP complains that the array_push first param should be an array
for ($i = 0; $i < $this->ldapUser['memberof']['count']; $i++) {
$group = ldap_explode_dn($this->ldapUser['memberof'][$i],1)[0];
array_push($tab, sprintf('ROLE_%s', strtoupper($group)));
}
$this->ldapUser['roles']=$tab;
return;
}
This would be a really handy feature, @ktsharp are you able to PR what you did in your branch? (apologies if you already have and I couldn't find it)