By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,224 Members | 1,120 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,224 IT Pros & Developers. It's quick & easy.

LDAP objectGUID problem

100+
P: 107
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:

Expand|Select|Wrap|Line Numbers
  1. $filter = "objectguid=$objectguid";
so after i've converted to hex i have a guid that looks something like this:

4e7c7075e7ace444af00b1162839257b

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
Aug 12 '08 #1
Share this Question
Share on Google+
1 Reply


100+
P: 107
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

Expand|Select|Wrap|Line Numbers
  1. $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:

Expand|Select|Wrap|Line Numbers
  1. function FormatGUID($hexGUID){
  2.  
  3.         $hexGUID = str_replace("-", "", $hexGUID);
  4.  
  5.         for ($i = 0; $i <= strlen($hexGUID)-2; $i = $i+2){
  6.  
  7.             $output .=  "\\".substr($hexGUID, $i, 2);
  8.  
  9.  
  10.         }
  11.  
  12.         return $output;
  13.  
  14.     }
  15.  
I've not tested this very much yet though, so beware!


Cheers
Sep 3 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.