You are here

function hook_ldap_user_groups_alter in LDAP integration 6

Allows an LDAP user's set of ldap groups be altered or added to.

This hook is called after the group detection methods defined in the admin UI have been processed but before any access rules or role mapping has been done..

Parameters

Array $groups An array whose values are the user's groupsr:

LDAPInterface $ldap LDAP server interface object bound to server as ldap user.:

String $dn The DN for the user being processed.:

String $name The user's LDAP user name.:

1 invocation of hook_ldap_user_groups_alter()
ldapgroups_groups_load in ./ldapgroups.inc
Create an array of LDAP groups related to a dn/user.

File

./ldapgroups.api.php, line 20
LDAPGroups API function documentation

Code

function hook_ldap_user_groups_alter(&$groups, $ldap, $dn, $name) {

  // Some example code to add a group that is the parent on the
  // user's dn, e.g. cn=Bob Admin,ou=admins,ou=dept1,dc=myorg will have a
  // group added like:  ou=admin,ou=dept1,dc=myorg.  This can then be used
  // in access rules or role mapping.
  $parts = explode(",", $dn, 2);
  $groups[] = $parts[1];
}