public static function ConversionHelper::convertAttribute in Lightweight Directory Access Protocol (LDAP) 8.4
Same name and namespace in other branches
- 8.3 ldap_servers/src/Helper/ConversionHelper.php \Drupal\ldap_servers\Helper\ConversionHelper::convertAttribute()
Converts an attribute by their format.
Parameters
string $value: Value to be converted.
string|null $conversion: Conversion type such as base64_encode, bin2hex, msguid, md5.
Return value
string Converted string.
1 call to ConversionHelper::convertAttribute()
- TokenProcessor::processLdapTokenKey in ldap_servers/
src/ Processor/ TokenProcessor.php - Process a single LDAP Token key.
File
- ldap_servers/
src/ Helper/ ConversionHelper.php, line 92
Class
- ConversionHelper
- Conversion helper to escape values correctly for LDAP filters.
Namespace
Drupal\ldap_servers\HelperCode
public static function convertAttribute(string $value, string $conversion = NULL) : string {
switch ($conversion) {
case 'base64_encode':
$value = base64_encode($value);
break;
case 'binary':
case 'bin2hex':
$value = bin2hex($value);
break;
case 'msguid':
$value = self::convertMsguidToString($value);
break;
case 'md5':
$value = '{md5}' . base64_encode(pack('H*', md5($value)));
break;
}
return $value;
}