w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Python LDAP converting objectGUID to hex string and back
def guid2hexstring(val):
    s = ['\%02X' % ord(x) for x in val]
    return ''.join(s)

guid = ldapobject.get('objectGUID', [''])[0] #
guid2string(guid).replace("\", "") # '496772AF62194D45B2503963FBA0E277'

#and back to a value you can use in an ldap search filter

guid = ''.join(['\%s' % guid[i:i+2] for i in range(0, len(guid), 2)]) #

searchfilter = ('(objectGUID=%s)' % guid)

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.