[python-win32] Re: testing ADSI GUID buffer objects

Roger Upole rwupole at msn.com
Thu Jul 27 05:28:18 CEST 2006

David Primmer wrote:

>I am trying to write a unit test for a function that accepts a buffer 
>   object. As far as I can tell, buffer's cannot be directly represented 
> in code. How do I create the object for the test? (The buffer object comes
> through ADSI in an Active Directory query of the user GUID property).
> If I print the GUID property, it prints a Unicode encoded string of the 
> byte stream: u'8108fd1ac12c0d42924355c8d9987f19'. I don't believe this 
> is the 'native' representation. The function I'm trying to test 
> translates it to MS's hex format: '{38303138-6466-6131-6331-326330643432}'

A guid buffer returned from an ADSI query can be translated into a PyIID
object using pywintypes.IID(bufferobject, True).  The second parameter
to IID() indicates that the input shoud be treated as raw bytes.


More information about the Python-win32 mailing list