Showing results for 
Search instead for 
Did you mean: 

Getting thumbnailPhoto from Active Directory using LDAP

Go to solution


Using .NET and LDAP I'm able to obtain AD user info such as "displayName", "physicalDeliveryOfficeName", etc strings without issue. Using "thumbnailPhoto" I get a byte stream as expected, but I have not been able to convert this back into a picture. I have already tried using the PNG to LV It doesn't work in this instance. Any help would be appreciated. 






0 Kudos
Message 1 of 9

I have no experience with this and a quick search did not show clear documentation for what the format of the data is (I assume it's this and it doesn't seem to specify a format), but it does show an example where it says it does work:


                        byte[] data = user.Properties["thumbnailPhoto"].Value as byte[];

                        if (data != null)
                            using (MemoryStream s = new MemoryStream(data))
                                return Bitmap.FromStream(s);


So presumably you just need to find the MemoryStream and Bitmap classes and do the same code. With the Bitmap class, I assume you can convert it to a more friendly format (worst case, you could probably save it to a file and read that).

Try to take over the world!
Message 2 of 9

Hi reniam,


could you please downconvert your VI for LV2019? Thanks!

Best regards,

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 9

The PNG to LV VI of course expects a PNG byte stream. Depending how the picture is stored in Active Directory it might or might not be a PNG byte stream, but I doubt it is. You would need to look at the first few bytes in that byte array/string. It could be "BM" in which case it would be a Windows Bitmap or it could be JFIF or something similar, which would indicate a JPEG byte stream.


The .Net class Bitmap actually does this distinction internally and then invokes the according byte stream to image decoder, but in LabVIEW you do not have such a versatile "consume almost every image byte stream out there and try to figure out how to decode it".


It wouldn't be incredibly difficult to do to work for a few standard image types, but you can not imagine the amount of variations and different formats out there! It can never be made to work for all possible images and will then cause the standard complaint: "But I have here an image stream, why doesn't this function work?" Often it is easier to simply avoid the trouble, than having to deal with the consequences of having tried to solve it. 😁

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 9
Accepted by topic author reniam



In case anyone finds this thread in the future, this worked for me.





Message 5 of 9

What is the Employee ID?  Is the Windows user name?


George Zou
0 Kudos
Message 6 of 9

Hi reniam,


as I already asked for: can you please downconvert your VI to LV2019?

Best regards,

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 9

It's the SAM-Account-Name attribute to filter the forest of members on the domain. For us, this is the Employee ID. I spent a few minutes trying to get UserPrincipalName to work; id est "" without success.





0 Kudos
Message 8 of 9
0 Kudos
Message 9 of 9