You are here

public function LdapGroupManager::groupRemoveMember in Lightweight Directory Access Protocol (LDAP) 8.4

Remove a member from a group.

Functionality only called by server test form.

Parameters

string $group_dn: LDAP DN group.

string $member: LDAP DN member.

Return value

bool Operation successful.

File

ldap_servers/src/LdapGroupManager.php, line 224

Class

LdapGroupManager
LDAP Group Manager.

Namespace

Drupal\ldap_servers

Code

public function groupRemoveMember(string $group_dn, string $member) : bool {
  $result = FALSE;
  if ($this
    ->checkAvailability() && $this
    ->groupGroupEntryMembershipsConfigured()) {
    $entry = new Entry($group_dn);
    $manager = $this->ldap
      ->getEntryManager();
    try {
      $manager
        ->removeAttributeValues($entry, $this->server
        ->get('grp_memb_attr'), [
        $member,
      ]);
      $result = TRUE;
    } catch (LdapException $e) {
      $this->logger
        ->error('LDAP server error updating %dn on @sid exception: %ldap_error', [
        '%dn' => $group_dn,
        '@sid' => $this->server
          ->id(),
        '%ldap_error' => $e
          ->getMessage(),
      ]);
    }
  }
  return $result;
}