Exemplo n.º 1
0
        // Token: 0x06001150 RID: 4432 RVA: 0x00047CE8 File Offset: 0x00045EE8
        public PhotoMetadata Read(IRecipientSession session, ADObjectId recipientId, Stream output)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (recipientId == null)
            {
                throw new ArgumentNullException("recipientId");
            }
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            ADRecipient adrecipient = this.FindRecipient(session, recipientId);

            if (adrecipient.ThumbnailPhoto == null || adrecipient.ThumbnailPhoto.Length == 0)
            {
                this.tracer.TraceDebug <ADObjectId>((long)this.GetHashCode(), "AD photo reader: user {0} does NOT have a photo in AD.", recipientId);
                throw new ADNoSuchObjectException(Strings.ADUserNoPhoto(recipientId));
            }
            output.Write(adrecipient.ThumbnailPhoto, 0, adrecipient.ThumbnailPhoto.Length);
            string contentType;

            using (MemoryStream memoryStream = new MemoryStream(adrecipient.ThumbnailPhoto))
            {
                contentType = this.sniffer.FindMimeFromData(memoryStream);
            }
            return(new PhotoMetadata
            {
                Length = (long)adrecipient.ThumbnailPhoto.Length,
                ContentType = contentType
            });
        }