From f0c609f169ff7bff936e3d3245e8d96b67887886 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Tue, 18 Oct 2011 10:53:03 +1300 Subject: [PATCH] We should map fields regardless of whether there are defaults set for anything. They might all be mapped! --- inc/drivers_ldap.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/inc/drivers_ldap.php b/inc/drivers_ldap.php index c6e21613..fadac299 100644 --- a/inc/drivers_ldap.php +++ b/inc/drivers_ldap.php @@ -263,20 +263,20 @@ function sync_user_from_LDAP( Principal &$principal, $mapping, $ldap_values ) { $fields_to_set = array(); $updateable_fields = Principal::updateableFields(); - if ( isset($c->authenticate_hook['config']['default_value']) && is_array($c->authenticate_hook['config']['default_value']) ) { - foreach( $updateable_fields AS $field ) { - if ( isset($mapping['active']) && !isset($mapping['user_active']) ) $field = 'active'; // Backward compatibility: now 'user_active' - else if ( isset($mapping['updated']) && !isset($mapping['modified']) ) $field = 'updated'; // Backward compatibility: now 'modified' - if ( isset($mapping[$field]) && isset($ldap_values[$mapping[$field]]) ) { - $fields_to_set[$field] = $ldap_values[$mapping[$field]]; - dbg_error_log( "LDAP", "Setting usr->%s to %s from LDAP field %s", $field, $ldap_values[$mapping[$field]], $mapping[$field] ); - } - else if ( isset($c->authenticate_hook['config']['default_value'][$field] ) ) { - $fields_to_set[$field] = $c->authenticate_hook['config']['default_value'][$field]; - dbg_error_log( "LDAP", "Setting usr->%s to %s from configured defaults", $field, $c->authenticate_hook['config']['default_value'][$field] ); - } + foreach( $updateable_fields AS $field ) { + if ( isset($mapping['active']) && !isset($mapping['user_active']) ) $field = 'active'; // Backward compatibility: now 'user_active' + else if ( isset($mapping['updated']) && !isset($mapping['modified']) ) $field = 'updated'; // Backward compatibility: now 'modified' + if ( isset($mapping[$field]) && isset($ldap_values[$mapping[$field]]) ) { + $fields_to_set[$field] = $ldap_values[$mapping[$field]]; + dbg_error_log( "LDAP", "Setting usr->%s to %s from LDAP field %s", $field, $ldap_values[$mapping[$field]], $mapping[$field] ); + } + else if ( isset($c->authenticate_hook['config']['default_value']) && is_array($c->authenticate_hook['config']['default_value']) + && isset($c->authenticate_hook['config']['default_value'][$field] ) ) { + $fields_to_set[$field] = $c->authenticate_hook['config']['default_value'][$field]; + dbg_error_log( "LDAP", "Setting usr->%s to %s from configured defaults", $field, $c->authenticate_hook['config']['default_value'][$field] ); } } + if ( $principal->Exists() ) { $principal->Update($fields_to_set); } -- 2.11.4.GIT