Code Duplication    Length = 8-9 lines in 2 locations

html/includes/authentication/ad-authorization.inc.php 1 location

@@ 352-359 (lines=8) @@
349
    return $matches[0][0];
350
}
351
352
function sid_from_ldap($sid)
353
{
354
    $sidHex = unpack('H*hex', $sid);
355
    $subAuths = unpack('H2/H2/n/N/V*', $sid);
356
    $revLevel = hexdec(substr($sidHex, 0, 2));
357
    $authIdent = hexdec(substr($sidHex, 4, 12));
358
    return 'S-'.$revLevel.'-'.$authIdent.'-'.implode('-', $subAuths);
359
}
360
361
function auth_ldap_session_cache_get($attr)
362
{

html/includes/authentication/active_directory.inc.php 1 location

@@ 430-438 (lines=9) @@
427
    return preg_replace('/.*-(\d+)$/', '$1', $sid);
428
}
429
430
function sid_from_ldap($sid)
431
{
432
        $sidUnpacked = unpack('H*hex', $sid);
433
        $sidHex = array_shift($sidUnpacked);
434
        $subAuths = unpack('H2/H2/n/N/V*', $sid);
435
        $revLevel = hexdec(substr($sidHex, 0, 2));
436
        $authIdent = hexdec(substr($sidHex, 4, 12));
437
        return 'S-'.$revLevel.'-'.$authIdent.'-'.implode('-', $subAuths);
438
}
439
440
/**
441
 * Bind to AD with the bind user if available, otherwise anonymous bind