Page 1 of 1

PHP help: how do I express a series of binary values as a number?

Posted: Tue May 01, 2007 1:10 pm
by AndyHolyer
I'm porting FrontEndUsers over to use our Active Directory server rather than the database, and I need a value for User ID.

I've found an ideal candidate: msexchmailboxguid, which is indeed unique for each user. However I've hit a problem: this attribute is a series of 16 hex bytes. PHP seems to insist on interpreting this value as a 16-character string, (which come out looking like this:  )¦§ð”MûE³rèm.), and without an asc() function I don't see how I can decompose this and turn it back into a number. Anyone got any suggestions?

Thanks in advance, Andy

Re: PHP help: how do I express a series of binary values as a number?

Posted: Tue May 01, 2007 3:40 pm
by Dee
Have you tried casting it to integer?

Code: Select all

(int) $bar
Regards,
D

Re: PHP help: how do I express a series of binary values as a number?

Posted: Wed May 02, 2007 7:43 am
by AndyHolyer
Dee wrote: Have you tried casting it to integer?

Code: Select all

(int) $bar
Regards,
D
Yes, I get 0, since it still treats it as a string.

I did eventually find the solution:

bin2hex gets me a hex string, which I can then pass to base_convert to get me an (absolutely huge) decimal number. I'm really glad that php no longer restricts itself to the advertised 32 bits maximim size. Though lord alone knows why M$ think they need quite such a huge identifier - so that every atom on the planet can have its own email address?