You are here

function cas_ldap_guid_bin2hex in CAS Attributes 7

Converts a binary GUID into a string representation.

Parameters

$guid binary: The GUID.

Return value

string The safe string representation of the GUID.

1 call to cas_ldap_guid_bin2hex()
cas_ldap_tokens in ./cas_ldap.tokens.inc
Implements hook_tokens().

File

./cas_ldap.tokens.inc, line 70
Token module integration.

Code

function cas_ldap_guid_bin2hex($guid) {
  $guid = bin2hex($guid);

  // Format $guid so it matches what other LDAP tool displays for AD GUIDs.
  // If $guid is not the normal length for a GUID, do not format.
  if (strlen($guid) === 32) {
    $guid = strtoupper(substr($guid, 6, 2) . substr($guid, 4, 2) . substr($guid, 2, 2) . substr($guid, 0, 2) . '-' . substr($guid, 10, 2) . substr($guid, 8, 2) . '-' . substr($guid, 14, 2) . substr($guid, 12, 2) . '-' . substr($guid, 16, 4) . '-' . substr($guid, 20));
  }
  return $guid;
}