function hook_ldap_user_edit_user_alter in Lightweight Directory Access Protocol (LDAP) 8.4
Same name and namespace in other branches
- 8.2 ldap_user/ldap_user.api.php \hook_ldap_user_edit_user_alter()
- 8.3 ldap_user/ldap_user.api.php \hook_ldap_user_edit_user_alter()
- 7.2 ldap_user/ldap_user.api.php \hook_ldap_user_edit_user_alter()
Alter the user object in the context of an LDAP entry during synchronization.
Parameters
\Drupal\user\UserInterface $account: The edit array (see hook_user_insert). Make changes to this object as required.
\Symfony\Component\Ldap\Entry $entry: The LDAP entry for the Drupal user.
array $context: Contains ldap_server and provisioning events.
See also
\Drupal\ldap_user\Processor\DrupalUserProcessor::applyAttributesToAccount()
\Drupal\ldap_user\Processor\DrupalUserProcessor::applyAttributesToAccountOnCreate()
2 invocations of hook_ldap_user_edit_user_alter()
- DrupalUserProcessor::applyAttributesToAccount in ldap_user/
src/ Processor/ DrupalUserProcessor.php - Apply field values to user account.
- DrupalUserProcessor::applyAttributesToAccountOnCreate in ldap_user/
src/ Processor/ DrupalUserProcessor.php - Apply field values to user account.
File
- ldap_user/
ldap_user.api.php, line 64
Code
function hook_ldap_user_edit_user_alter(UserInterface $account, Entry $entry, array $context) {
/** @var \Drupal\ldap_servers\Processor\TokenProcessor $tokenProcessor */
$tokenProcessor = \Drupal::service('ldap.token_processor');
$value = $tokenProcessor
->ldapEntryReplacementsForDrupalAccount($entry, '[sn]');
$account
->set('myfield', $value);
}