You are here

function ldap_servers_parse_user_attr_name in Lightweight Directory Access Protocol (LDAP) 8.2

Same name and namespace in other branches
  1. 7.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 33
collection of functions related to ldap tokens

Code

function ldap_servers_parse_user_attr_name($user_attr_key) {
  $user_attr_key = trim($user_attr_key, LDAP_SERVERS_TOKEN_PRE . LDAP_SERVERS_TOKEN_POST);

  // make sure no [] are on attribute
  $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 array(
    $attr_type,
    $attr_name,
    $attr_ordinal,
  );
}