Forum Discussion
APM variable Assign Convert from HEX to original Format
Hi,
You can try this decoding code (you did not convert hex to unsigned integer in revision, countSubAuths and authority)
# Sample binary SID
set attr_objectSid 0x01050000000000050d000000653937086239386436083764370866383205016506630238060000
#set attr_objectSid [mcget {session.ldap.last.attr.objectSid}]
if { [string range $attr_objectSid 0 1 ] == "0x" } {
set objectSid [binary format H* [string range $attr_objectSid 2 end]]
# Exctract static data
# - Revision (1 byte --> c )
# - countSubAuths (1 byte --> c )
# - authorityhex (48 bits Big Indian --> H12 ; binary scan only supports 1/2/4/8 bytes so a converstion to Hex is required)
binary scan $objectSid ccH12 revision countSubAuths authorityhex
# Convert signed values to unsigned
set revision [expr {$revision & 0xff}]
set countSubAuths [expr {$countSubAuths & 0xff}]
# Convert authorityhex to unsigned Integer
scan $authorityhex {%x} authority
# Extract Sub authorities
# - subauth : List of Sub authorities (4 bytes Little Indian --> i )
binary scan $objectSid @8i${countSubAuths} subauth
# Build a list of SID Elements
set result [list "S" $revision $authority]
foreach val $subauth {
# Insert each Sub authority value as unsigned value
lappend result [expr {$val & 0xffffffff}]
}
# Return joined SID Elements list with dash separator
puts [join $result "-"]
#return [join $result "-"]
}
- ebengFeb 24, 2022
Nimbostratus
Hi mate,
can you check your code, it seems to be all pasted in one line now, cant get it to work 😞
What about if we need to have the ObjectGUID as well?
when we need to convert the base64, which the F5-retrieves, with an LDAP-search we do the following:
echo <<>>|base64 -d -i|hexdump -e '1/1 " %02x"'|awk '{print $4$3$2$1"-"$6$5"-"$8$7"-"$9$10"-"$11$12$13$14$15$16}'Any how we can do this? within the APM policy?
I would like to get the ObjectGUID, as shown in the AD, to use it in the APM.
any help would be appreciated.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
