Пример #1
0
/**
 * Hook to add more fields from LDAP
 *
 * @param $fields   array
 *
 * @return un tableau
 **/
function plugin_retrieve_more_field_from_ldap_moreldap($fields)
{
    $pluginAuthLDAP = new PluginMoreldapAuthLDAP();
    // There is no way to know which LDAP will be used, so we have
    // to retrieve all LDAP attributes in any LDAP server
    $result = $pluginAuthLDAP->find("");
    if (is_array($result)) {
        foreach ($result as $attribute) {
            $fields[$attribute['location']] = $attribute['location'];
            // Explode multiple attributes for location hierarchy
            $locationHierarchy = explode('>', $attribute['location']);
            foreach ($locationHierarchy as $locationSubAttribute) {
                $locationSubAttribute = trim($locationSubAttribute);
                $fields[$locationSubAttribute] = $locationSubAttribute;
            }
        }
    }
    return $fields;
}