Importing JPEG file to thumbnailPhoto in the Active Directory

Started by hienpham, January 15, 2015, 11:22:23 AM

Previous topic - Next topic

hienpham

Hi,
  We have thousands of JPEG files from the employee pictures that we want to import to the corresponding  thumbnailPhoto attribute. For that we need to resize those pictures and then do the import. We want to automate those steps using WinBatch.
Could you give me a hint about how to:
    1. to do the resize
    2. and do the import
We don't have any problem to get to the thumbnailPhoto attribute of the owner of the picture.
(BTW I have read the "Converting Active Directory Thumbnailphotos to File" WinBatch article, my goal is to do the inverse (put the picture in))

Thanks for any help.

JTaylor

I recommend using the ImageMagick COM interface for doing the resizing.  There is a native extender for Image manipulation but the quality of the results will be far inferior to ImageMagick.


Jim

td

One of many alternatives for resizing can be found here

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/Samples~from~Users+GDI~Image~Resize.txt

Adding a thumbnail is much like fetching one
Code (winbatch) Select

; Using our test server with a dummy account.
AdSIPath = "LDAP://shamrock/CN=BOB Smith,CN=Users,DC=jclass,DC=org"
objUser = ObjectGet(AdSIPath)

strJpg = "C:\bitmaps\intrepid_pic.jpg"  ; Your image goes here.
nSize = Filesize(strJpg) + 64
hJpg = BinaryAlloc(nSize)
BinaryRead( hJpg, strJpg )
BinaryOleType( hJpg, 103 , 0, 0, 0)
objUser.Put("thumbnailphoto", hJpg)
objUser.SetInfo
BinaryFree(hJpg)


The latter can be done with the ADSI extender as well. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

Here's a script snippet that adds a thumbnail photo using the ADSI extender

Code (winbatch) Select

AddExtender('wwads44i.dll',0,'wwads64i.dll')

InFile = 'c:\Bitmaps\MyIcon.jpg'  ; Your image.
UserPath = "LDAP://shamrock/CN=Bill Bates,CN=Users,DC=jclass,DC=org" ; Your user path.

; Load the image.
hIn = BinaryAlloc(FileSize(inFile)+128)
BinaryRead(hIn, InFile)
strHexPhoto = BinaryPeekHex(hIn, 0,BinaryEodGet(hIn))
BinaryFree(hIn)

; Add the image to the user account.
dssetproperty(UserPath," thumbnailphoto ", strHexPhoto)
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

hienpham

Thanks TD and JTaylor,
  WinBatch and your help make my job really easy.

Thanks so much.
hienpham