You are here

public function Server::groupAddGroup in Lightweight Directory Access Protocol (LDAP) 8.3

Add a group entry.

Functionality is not in use, only called by server test form.

Parameters

string $group_dn: The group DN as an LDAP DN.

array $attributes: Attributes in key value form $attributes = array( "attribute1" = "value", "attribute2" = array("value1", "value2"), )

Return value

bool Operation result.

File

ldap_servers/src/Entity/Server.php, line 1848

Class

Server
Defines the Server entity.

Namespace

Drupal\ldap_servers\Entity

Code

public function groupAddGroup($group_dn, array $attributes = []) {
  if ($this
    ->checkDnExists($group_dn)) {
    return FALSE;
  }
  $attributes = array_change_key_case($attributes, CASE_LOWER);
  if (empty($attributes['objectclass'])) {
    $objectClass = $this
      ->groupObjectClass();
  }
  else {
    $objectClass = $attributes['objectclass'];
  }
  $attributes['objectclass'] = $objectClass;
  $context = [
    'action' => 'add',
    'corresponding_drupal_data' => [
      $group_dn => $attributes,
    ],
    'corresponding_drupal_data_type' => 'group',
  ];
  $ldap_entries = [
    $group_dn => $attributes,
  ];
  $this->moduleHandler
    ->alter('ldap_entry_pre_provision', $ldap_entries, $this, $context);
  $attributes = $ldap_entries[$group_dn];
  $ldap_entry_created = $this
    ->createLdapEntry($attributes, $group_dn);
  if ($ldap_entry_created) {
    $this->moduleHandler
      ->invokeAll('ldap_entry_post_provision', [
      $ldap_entries,
      $this,
      $context,
    ]);
    return TRUE;
  }
  else {
    return FALSE;
  }
}