note 46984 added to ref.ldap

From: Date: Fri, 29 Oct 2004 12:36:29 +0000
Subject: note 46984 added to ref.ldap
Groups: php.notes 
Request: Send a blank email to php-notes+get-79311@lists.php.net to get a copy of this message
Here are two small functions that enables you to convert a binary objectSID from Microsoft AD into a more usefull text version (formatted (S-1-5.....)). // Converts a little-endian hex-number to one, that 'hexdec' can convert function littleEndian($hex) { for ($x=strlen($hex)-2; $x >= 0; $x=$x-2) { $result .= substr($hex,$x,2); } return $result; } // Returns the textual SID function binSIDtoText($binsid) { $hex_sid=bin2hex($binsid); $rev = hexdec(substr($hex_sid,0,2)); // Get revision-part of SID $subcount = hexdec(substr($hex_sid,2,2)); // Get count of sub-auth entries $auth = hexdec(substr($hex_sid,4,12)); // SECURITY_NT_AUTHORITY $result = "$rev-$auth"; for ($x=0;$x < $subcount; $x++) { $subauth[$x] = hexdec(littleEndian(substr($hex_sid,16+($x*8),8))); // get all SECURITY_NT_AUTHORITY $result .= "-".$subauth[$x]; } return $result; } echo binSIDtoText($bin_sid); ---- Manual Page -- http://www.php.net/manual/en/ref.ldap.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46984 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46984&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46984&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46984&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46984&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46984&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46984&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+46984&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#79311) next »