public function SimpleLdapRole::addUser in Simple LDAP 7.2
Same name and namespace in other branches
- 7 simple_ldap_role/SimpleLdapRole.class.php \SimpleLdapRole::addUser()
Add an LDAP user to the LDAP group.
File
- simple_ldap_role/
SimpleLdapRole.class.php, line 287 - SimpleLdapRole class file.
Class
- SimpleLdapRole
- @file SimpleLdapRole class file.
Code
public function addUser($user) {
// Make sure the user is a SimpleLdapUser object.
if (is_string($user)) {
$user = SimpleLdapUser::singleton($user);
}
// Get the module configuration.
$user_attribute_name = simple_ldap_user_variable_get('simple_ldap_user_attribute_name');
$attribute_member = simple_ldap_role_variable_get('simple_ldap_role_attribute_member');
$attribute_member_format = simple_ldap_role_variable_get('simple_ldap_role_attribute_member_format');
// Determine the member attribute format.
if ($attribute_member_format == 'dn') {
$member = $user->dn;
}
else {
$member = $user->{$user_attribute_name}[0];
}
// Add the user to this group.
if (empty($this->attributes[$attribute_member]) || !in_array($member, $this->attributes[$attribute_member], TRUE)) {
$this->attributes[$attribute_member][] = $member;
$this->dirty = TRUE;
}
}