You are here

public static function ConversionHelper::convertMsguidToString in Lightweight Directory Access Protocol (LDAP) 8.4

Same name and namespace in other branches
  1. 8.3 ldap_servers/src/Helper/ConversionHelper.php \Drupal\ldap_servers\Helper\ConversionHelper::convertMsguidToString()

Function to convert microsoft style guids to strings.

Parameters

string $value: Value to convert.

Return value

string Converted value.

2 calls to ConversionHelper::convertMsguidToString()
ConversionHelper::convertAttribute in ldap_servers/src/Helper/ConversionHelper.php
Converts an attribute by their format.
TokenTest::testBinaryConversion in ldap_servers/tests/src/Unit/TokenTest.php
Test binary conversion.

File

ldap_servers/src/Helper/ConversionHelper.php, line 70

Class

ConversionHelper
Conversion helper to escape values correctly for LDAP filters.

Namespace

Drupal\ldap_servers\Helper

Code

public static function convertMsguidToString(string $value) : string {
  $hex_string = bin2hex($value);

  // (MS?) GUID are displayed with first three GUID parts as "big endian"
  // Doing this so String value matches what other LDAP tool displays for AD.
  return strtoupper(substr($hex_string, 6, 2) . substr($hex_string, 4, 2) . substr($hex_string, 2, 2) . substr($hex_string, 0, 2) . '-' . substr($hex_string, 10, 2) . substr($hex_string, 8, 2) . '-' . substr($hex_string, 14, 2) . substr($hex_string, 12, 2) . '-' . substr($hex_string, 16, 4) . '-' . substr($hex_string, 20, 12));
}