EN / USD
32
of 76
TEP , The Engineering Projects , Image

syedzainnasir

TEP , The Engineering Projects , Rating 7.5 7.5 / 10
TEP , The Engineering Projects , Icon Level: Moderator
TEP , The Engineering Projects , Icon Joined: 20 Mar 2022
TEP , The Engineering Projects , Icon Last Active: 2:21 PM
TEP , The Engineering Projects , Icon Location: TEP , The Engineering Projects , Flag
TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon
thumbnailPhoto not getting in case of Global Catalog
TEP , The Engineering Projects , Calender Question: 07-Mar-2017
TEP , The Engineering Projects , Category In: Microsoft Visual Studio Projects
I have created a AD forest that search for a user across all domains in the forest using its global catalog connection string.

I am trying to get thumbnailPhoto of AD user using c# code. But I did not get thumbnailPhoto property in result object even though it exist in AD.

I had verified the thumbnailPhoto prop in AD using powershell. Also I have verified it by getting using LDAP connection string. It both case I got the byte array.

Below is the code to get user and its properties and _configuration.GlobalCatalog returns the Global catalog connections string which is in format (GC://domain-name).
[code]public Task<ProfileImage> GetProfileImageByEmail(string email) { var filterQuery = ("mail=" + email); return Task.FromResult(GetProfileImageFromAD(filterQuery)); } private ProfileImage GetProfileImageFromAD(string filterQuery) { var result = GetADUserDetails(filterQuery); if (result == null) return null; if (result.Properties.Contains("thumbnailPhoto")) { var imageBytes = result.Properties["thumbnailPhoto"][0] as byte[]; if (imageBytes != null) { return new ProfileImage { Content = new MemoryStream(imageBytes), ContentType = "image/jpeg" }; } } return null; } private SearchResult GetADUserDetails(string filterQuery) { using (var userBinding = new DirectoryEntry(_configuration.GlobalCatalog)) { using (DirectorySearcher adSearch = new DirectorySearcher(userBinding)) { adSearch.ReferralChasing = ReferralChasingOption.All; adSearch.Filter = filterQuery; adSearch.PropertiesToLoad.Add("mail"); adSearch.PropertiesToLoad.Add("sn"); adSearch.PropertiesToLoad.Add("givenName"); adSearch.PropertiesToLoad.Add("thumbnailPhoto"); return adSearch.FindOne(); } } }[/code]
TEP , The Engineering Projects , Icon Answer: 0 TEP , The Engineering Projects , Icon Views: 150 TEP , The Engineering Projects , Icon Followers: 85
Small Bio
TEP , The Engineering Projects , Tags
PLC
Robot
STM32
Arduino
AI
ESP32
Ladder Logic
PLC Projects
Programming
Communicates STM32
PLC Projects
Communicates PLC
Font Style
Alignment
Indenting and Lists
Insert Media
Insert Items

Want to leave an answer!

Word Count :0 Draft Saved at 12:42 am.