public void ImportPicsToAd(Dictionary <string, ImportExportRecord> peopleToImport) { foreach (var upn in peopleToImport.Keys) { var upnIdentifier = new UpnIdentifier(upn); var picture = peopleToImport[upn].PhotoLocation; if (string.IsNullOrEmpty(picture)) { // skip Logger.Info($"Skipping photo import for {upn}, as photo location was invalid"); continue; } Stream photoStream; Logger.Info($"Importing photo for {upn}, {picture}"); try { photoStream = File.OpenRead(picture); } catch (Exception e) { Logger.Error($"Couldn't read photo from disk: {picture}, Message: {e.Message}. Skipping"); continue; } try { _ad.UpdateAttribute(upnIdentifier, ActiveDirectoryClient.AdPhotoAttribute, photoStream); } catch (Exception e) { Logger.Error($"Problem updating AD for {upn}: {e.Message}. Skipping"); } } }