LDAP objectGUID problem

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

    LDAP objectGUID problem

    Hey,

    Im creating an intranet and when a user logs on I use the Active Directory to validate their logon, then store the objectGUID in a session variable, which I first convert to hex using bin2hex()

    My question is, how do I then use it to query the active directory for group membership etc, I dont seem to be able to get it in the correct format to use something like:

    Code:
    $filter = "objectguid=$objectguid";
    so after i've converted to hex i have a guid that looks something like this:

    4e7c7075e7ace44 4af00b116283925 7b

    Apparently the data type is a 128bit octal string. (16 bytes)... whatever that is!
    I've tried using unpack(), but im not sure that even if i manage to convert it into binary I can even use this kind of data with ldap_search()


    Any help appreciated!

    Thanks

    Andy
  • theS70RM
    New Member
    • Jul 2007
    • 107

    #2
    ok, for anyone interested I found how to do this.

    All you need to do when retrieving the objectguid is convert it to hex with

    Code:
    $hex_guid = bin2hex($binary_guid);
    then to get it into a format to query the active directory there needs to be an escape character every 2 characters like:

    4e\7c\70\75\e7\ ac\e4\44\af\00\ b1\16\28\39\25\ 7b

    heres the function i use:

    Code:
    function FormatGUID($hexGUID){
    		
    		$hexGUID = str_replace("-", "", $hexGUID);
    						
    		for ($i = 0; $i <= strlen($hexGUID)-2; $i = $i+2){
    			
    			$output .=  "\\".substr($hexGUID, $i, 2);
    				
    		
    		}
    
    		return $output;
    			
    	}
    I've not tested this very much yet though, so beware!


    Cheers

    Comment

    Working...