note 99403 added to function.ldap-get-values-len

From: Date: Sun, 15 Aug 2010 18:25:28 +0000
Subject: note 99403 added to function.ldap-get-values-len
Groups: php.notes 
Request: Send a blank email to php-notes+get-171696@lists.php.net to get a copy of this message
To complement the collection gathered from the previous posts: <?php // Return the binary SID (for LDAP search in AD, for example) function str_to_bin_sid($strsid) { if (empty($strsid) || !is_string($strsid)) throw new Exception( 'no SID string', 13); $sid = explode('-', $strsid); if (empty($sid) || count($sid) < 4) throw new Exception( 'invalid SID string', 14); $sid[0] = $sid[1]; // move rev, don't need "S-" $sid[1] = count($sid) - 3; // set subcount if ($sid[1] > 8) throw new Exception( 'SID string with invalid sub authority count', 15); foreach($sid as $idx => &$field) { $field = dechex($field); switch($idx) { case 0: // rev, 8-bit case 1: // subcount, 8-bit $pad = 2; break; case 2: // auth, 48-bit $pad = 12; break; default: // subauth, 32-bit, byteswap $pad = 8; } $field = str_pad($field, $pad, '0', STR_PAD_LEFT); if ($pad == 8) $field = byteswap($field); } return pack('H*', implode('', $sid)); } // Do a simple byte swap on a hex string // borrowed from derek's post below function byteswap($hex) { for ($i = strlen($hex) - 2; $i >= 0; $i -= 2) $swp .= substr($hex, $i, 2); return $swp; } ?> ---- Server IP: 85.214.154.209 Probable Submitter: 79.208.65.36 ---- Manual Page -- http://www.php.net/manual/en/function.ldap-get-values-len.php Edit -- https://master.php.net/note/edit/99403 Del: integrated -- https://master.php.net/note/delete/99403/integrated Del: useless -- https://master.php.net/note/delete/99403/useless Del: bad code -- https://master.php.net/note/delete/99403/bad+code Del: spam -- https://master.php.net/note/delete/99403/spam Del: non-english -- https://master.php.net/note/delete/99403/non-english Del: in docs -- https://master.php.net/note/delete/99403/in+docs Del: other reasons-- https://master.php.net/note/delete/99403 Reject -- https://master.php.net/note/reject/99403 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#171696) next »