View Issue Details

IDProjectCategoryView StatusLast Update
0026809mantisbtldappublic2020-04-03 04:40
Reportermaturbet Assigned Tocommunity  
PrioritynormalSeverityfeatureReproducibilityalways
Status assignedResolutionopen 
Product Version2.24.0 
Summary0026809: Personalize LDAP fields cached
Description

To customize the list of ldap account fields to be cached for a user.

Adding global variable :
$g_ldap_cache_fields = array();
And include it in search attributes :
$t_search_attrs = array_merge(
array(
'mail',
config_get( 'ldap_realname_field' )
),
config_get( 'ldap_cache_fields' )
);

Additional Information

PR https://github.com/mantisbt/mantisbt/pull/1637

TagsNo tags attached.

Relationships

related to 0023392 new Mantis LDAP Avatar plugin 

Activities

maturbet

maturbet

2020-04-03 03:36

reporter   ~0063821

Som usage exemples
*1 : actualy in use in our company

personal_fields.png (60,174 bytes)   
personal_fields.png (60,174 bytes)   
showing_field.png (65,398 bytes)   
showing_field.png (65,398 bytes)   
exemple_ldap.txt (1,878 bytes)   
<?php

#config/custom_constants_inc.php
define( 'CUSTOM_FIELD_TYPE_LDAP_LINK', 11 );

#config/config_inc.php
$g_custom_field_types[CUSTOM_FIELD_TYPE_LDAP_LINK] = 'standard';
$g_custom_field_type_enum_string = '0:string,1:numeric,2:float,3:enum,4:email,5:checkbox,6:list,7:multiselection list,8:date,9:radio,10:textarea,11:ldaplink';
$g_custom_field_type_definition[CUSTOM_FIELD_TYPE_LDAP_LINK] = array (
    '#display_possible_values' => FALSE,
    '#display_valid_regexp' => FALSE,
    '#display_length_min' => TRUE,
    '#display_length_max' => TRUE,
    '#display_default_value' => TRUE,
    '#function_return_distinct_values' => null,
    '#function_value_to_database' => null,
    '#function_database_to_value' => null,
    '#function_print_input' => 'cfdef_input_textbox',
    '#function_string_value' => null,
    '#function_string_value_for_email' => null,
    '#function_default_to_value' => 'cfdef_get_ldap_value',
);

#config/custom_strings_inc.php
$s_custom_field_type_enum_string = '0:Chaîne de caractères,1:Nombre entier,2:Nombre réel,3:Énumération,4:Courriel,5:Case à cocher,6:Liste,7:Liste à sélection multiple,8:Date,9:Bouton radio, 10:Zone de texte,11:Lien LDAP';

#config/custom_functions_inc.php
/**
 * Gets the field value from LDAP.
 *
 * @param  string $p_value The LDAP field name.
 * @return string The LDAP field value.
 */
function cfdef_get_ldap_value($p_value) {
    return ldap_field(auth_get_current_user_id(), $p_value);
}
/**
 * returns a field value from LDAP, given a userid.
 *
 * @param  int    $p_user_id The user id.
 * @param  string $p_value   The LDAP field name.
 * @return string $t_value   The LDAP field value.
 */
function ldap_field( $p_user_id, $p_field_name) {
    $t_username = user_get_field( $p_user_id, 'username' );
    $t_value = ldap_get_field_from_username( $t_username, $p_field_name );
    return $t_value;
}

exemple_ldap.txt (1,878 bytes)   
maturbet

maturbet

2020-04-03 03:37

reporter   ~0063822

*2 : (not implemented yet in internal plugin) :
Associated with EVENT_MENU_ACCOUNT we will be able to add to the user's menu, specific links composed with data from LDAP.

maturbet

maturbet

2020-04-03 03:37

reporter   ~0063823

*3 : https://www.mantisbt.org/bugs/view.php?id=23392