backibaxter Posted January 3, 2012 Share Posted January 3, 2012 I'm making a connection to Active Directory using ADODB connection. I can read almost everything from this but some outputs are in an Octet format. For example objectSID is giving me only a ?. Is there somebody that knows how to read or convert this? I've found a converter function in ASP maybe someone can translate this to PHP? TXT_ObjectGUID = HexStrToDecStr(OctetToHexStr(objRecordSet.fields("objectSID"))) Function OctetToHexStr(arrbytOctet) ' Function to convert OctetString (byte array) to Hex string. Dim k OctetToHexStr = "" For k = 1 To Lenb(arrbytOctet) OctetToHexStr = OctetToHexStr _ & Right("0" & Hex(Ascb(Midb(arrbytOctet, k, 1))), 2) Next End Function Function HexStrToDecStr(strSid) ' Function to convert hex Sid to decimal (SDDL) Sid. Dim arrbytSid, lngTemp, j ReDim arrbytSid(Len(strSid)/2 - 1) For j = 0 To UBound(arrbytSid) arrbytSid(j) = CInt("&H" & Mid(strSid, 2*j + 1, 2)) Next HexStrToDecStr = "S-" & arrbytSid(0) & "-" _ & arrbytSid(1) & "-" & arrbytSid( lngTemp = arrbytSid(15) lngTemp = lngTemp * 256 + arrbytSid(14) lngTemp = lngTemp * 256 + arrbytSid(13) lngTemp = lngTemp * 256 + arrbytSid(12) HexStrToDecStr = HexStrToDecStr & "-" & CStr(lngTemp) lngTemp = arrbytSid(19) lngTemp = lngTemp * 256 + arrbytSid(18) lngTemp = lngTemp * 256 + arrbytSid(17) lngTemp = lngTemp * 256 + arrbytSid(16) HexStrToDecStr = HexStrToDecStr & "-" & CStr(lngTemp) lngTemp = arrbytSid(23) lngTemp = lngTemp * 256 + arrbytSid(22) lngTemp = lngTemp * 256 + arrbytSid(21) lngTemp = lngTemp * 256 + arrbytSid(20) HexStrToDecStr = HexStrToDecStr & "-" & CStr(lngTemp) lngTemp = arrbytSid(25) lngTemp = lngTemp * 256 + arrbytSid(24) HexStrToDecStr = HexStrToDecStr & "-" & CStr(lngTemp) End Function Quote Link to comment https://forums.phpfreaks.com/topic/254261-octet-to-decimal/ Share on other sites More sharing options...
silkfire Posted January 3, 2012 Share Posted January 3, 2012 It's called the octal numeral system, or base-8, not octet. And there's a function for this in php: octdec() Quote Link to comment https://forums.phpfreaks.com/topic/254261-octet-to-decimal/#findComment-1303632 Share on other sites More sharing options...
backibaxter Posted January 4, 2012 Author Share Posted January 4, 2012 Sorry I used the dutch word instead of the English one. When I use the octdec function, I get a 0. Quote Link to comment https://forums.phpfreaks.com/topic/254261-octet-to-decimal/#findComment-1304117 Share on other sites More sharing options...
requinix Posted January 4, 2012 Share Posted January 4, 2012 bin2hex Spoiler: "octet" was the right term. Quote Link to comment https://forums.phpfreaks.com/topic/254261-octet-to-decimal/#findComment-1304119 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.