Active Directory SID problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • theS70RM
    New Member
    • Jul 2007
    • 107

    Active Directory SID problem

    Im trying to return the SID for all users in our active directory

    The problem is that they all return the same!

    Our active directory runs in a Windows 2000 native functional level, would this affect it?

    I can get any other details from it just not the SID.

    the value returned is obviously in binary, and displays as some strange character on the page, and its the same character for every user. I then convert the binary to plain text using the following function:


    Code:
    		
    // 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));    
    	$subcount = hexdec(substr($hex_sid,2,2)); 
    	$auth = hexdec(substr($hex_sid,4,12));  
    	$result = "$rev-$auth";
    	for ($x=0;$x < $subcount; $x++) {
    		$subauth[$x] = hexdec($this->littleEndian(substr($hex_sid,16+($x*8),8)));  
    		$result .= "-".$subauth[$x];
    	}
    
    	return $result;
    }
    They all get returned from this as "1-0-0-0-0-0-0"

    I dont think the conversion function is the problem here as all the SID's look the same before!


    Can anyone help!?!?!


    thanks


    Andy
  • theS70RM
    New Member
    • Jul 2007
    • 107

    #2
    on reflection,m maybe i should be using the objectguid rather than objectsid. Im using it as a unique identifier in a database to expand on the information already stored in the active directory.

    From what I've just read the GUID will remain constant throughout the life of the object, but the SID can change if the object is moved to a different domain for example.

    Anyone got any input on this??


    Cheers

    Comment

    Working...