mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix AD auth with large SID components (#9207)
* Fix AD auth with large SID components Per http://php.net/manual/en/function.unpack.php unpack on 32bit will convert large unsigned long values into signed long values, so we check for PHP_INT_SIZE and fix them up if necessary. * Fix indentation
This commit is contained in:
committed by
Tony Murray
parent
3e4315c158
commit
e0e08e9b52
@ -345,12 +345,19 @@ class ActiveDirectoryAuthorizer extends AuthorizerBase
|
||||
|
||||
protected function sidFromLdap($sid)
|
||||
{
|
||||
$sidUnpacked = unpack('H*hex', $sid);
|
||||
$sidHex = array_shift($sidUnpacked);
|
||||
$subAuths = unpack('H2/H2/n/N/V*', $sid);
|
||||
$revLevel = hexdec(substr($sidHex, 0, 2));
|
||||
$authIdent = hexdec(substr($sidHex, 4, 12));
|
||||
return 'S-'.$revLevel.'-'.$authIdent.'-'.implode('-', $subAuths);
|
||||
$sidUnpacked = unpack('H*hex', $sid);
|
||||
$sidHex = array_shift($sidUnpacked);
|
||||
$subAuths = unpack('H2/H2/n/N/V*', $sid);
|
||||
if (PHP_INT_SIZE <= 4) {
|
||||
for ($i = 1; $i <= count($subAuths); $i++) {
|
||||
if ($subAuths[$i] < 0) {
|
||||
$subAuths[$i] = $subAuths[$i] + 0x100000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
$revLevel = hexdec(substr($sidHex, 0, 2));
|
||||
$authIdent = hexdec(substr($sidHex, 4, 12));
|
||||
return 'S-'.$revLevel.'-'.$authIdent.'-'.implode('-', $subAuths);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user