|Perl: the Markov chain saw|
Importing a jpeg into an AD attribute with Win32::OLEby bingos (Vicar)
|on Jul 12, 2011 at 15:53 UTC||Need Help??|
bingos has asked for the
wisdom of the Perl Monks concerning the following question:
Hello, I am having trouble with updating the thumbnailPhoto Active Directory attribute using the ADSI interface through Win32::OLE
I have been able to add photos using an Active Directory Users and Computers extension to individual user accounts, but I would like to have a way of doing 'bulk' imports. And of course my language of choice is perl for doing this.
The thumbnailPhoto attribute is an 'octet string' and I don't believe I've tried to manipulate this type of attribute before, though, I have retrieved values from them without any problems.
First off, I thought I would try and export images that had been previously imported:
This works fine to retrieve a 'piccy' and I had a JPEG file I could open and admire.
Buoyed up by the success of this, I tried this:
This ends up with 'ÿØÿà' in the attribute.
I tried various things, including:
The above seemed to either have no effect (Variant) or put garbage in the attribute
I found VBScript code that seemed to use a byte array to assign to the attribute:
I have an idea what a byte array is, but not how to coerce one from the contents of a Perl scalar. So I am stuck and would be grateful of any advice.
Many thanks in advance.