You are here

function ldap_servers_parse_user_attr_name in Lightweight Directory Access Protocol (LDAP) 7.2

Same name and namespace in other branches
  1. 8.2 ldap_servers/ldap_servers.tokens.inc \ldap_servers_parse_user_attr_name()

Parameters

$user_attr_key: of form <attr_type>.<attr_name>[:<instance>] such as field.lname, property.mail, field.aliases:2

Return value

array array($attr_type, $attr_name, $attr_ordinal) such as array('field','field_user_lname', NULL)

1 call to ldap_servers_parse_user_attr_name()
LdapUserConf::entryToUserEdit in ldap_user/LdapUserConf.class.php
Populate $user edit array (used in hook_user_save, hook_user_update, etc) ... should not assume all attribues are present in ldap entry.

File

ldap_servers/ldap_servers.tokens.inc, line 37
Collection of functions related to ldap tokens.

Code

function ldap_servers_parse_user_attr_name($user_attr_key) {

  // Make sure no [] are on attribute.
  $user_attr_key = trim($user_attr_key, LDAP_SERVERS_TOKEN_PRE . LDAP_SERVERS_TOKEN_POST);
  $parts = explode('.', $user_attr_key);
  $attr_type = $parts[0];
  $attr_name = isset($parts[1]) ? $parts[1] : FALSE;
  $attr_ordinal = FALSE;
  if ($attr_name) {
    $attr_name_parts = explode(':', $attr_name);
    if (isset($attr_name_parts[1])) {
      $attr_name = $attr_name_parts[0];
      $attr_ordinal = $attr_name_parts[1];
    }
  }
  return [
    $attr_type,
    $attr_name,
    $attr_ordinal,
  ];
}