use strict; use warnings; use Win32::OLE qw[in]; my $adspath = shift || die "Provide an adspath already\n"; { warn $adspath, "\n"; my $user = Win32::OLE->GetObject("LDAP://$adspath"); die "Oh dear\n" unless $user; $user->GetInfo; unless ( defined $user->{thumbnailPhoto} ) { warn "No thumbnail\n"; exit 0; } my $thumb = $user->{thumbnailPhoto}; { open my $piccy, '>:raw', 'piccy.jpg' or die "$!\n"; print $piccy $thumb; } } exit 0;