// Token: 0x06001AA0 RID: 6816 RVA: 0x00063DD4 File Offset: 0x00061FD4
        public GetPersonaPhoto(CallContext callContext, string personIdParam, string adObjectIdParam, string email, string singleSourceId, Microsoft.Exchange.Services.Core.Types.UserPhotoSize size) : base(callContext)
        {
            if (callContext == null)
            {
                throw new ArgumentNullException("callContext");
            }
            this.InitializeRequestTrackingInformation();
            this.InitializeTracers();
            OwsLogRegistry.Register("GetPersonaPhoto", typeof(PhotosLoggingMetadata), new Type[0]);
            this.perfLogger      = new PhotoRequestPerformanceLogger(base.CallContext.ProtocolLog, this.tracer);
            this.responseContext = callContext.CreateWebResponseContext();
            this.size            = size;
            this.tracer.TraceDebug <Microsoft.Exchange.Services.Core.Types.UserPhotoSize>((long)this.GetHashCode(), "size = {0}", this.size);
            this.email = email;
            this.tracer.TraceDebug <string>((long)this.GetHashCode(), "email = {0}", this.email);
            if (!string.IsNullOrEmpty(personIdParam))
            {
                try
                {
                    if (IdConverter.EwsIdIsConversationId(personIdParam))
                    {
                        this.personId = IdConverter.EwsIdToPersonId(personIdParam);
                        this.tracer.TraceDebug <PersonId>((long)this.GetHashCode(), "personId = {0}", this.personId);
                    }
                }
                catch (InvalidStoreIdException arg)
                {
                    this.tracer.TraceError <string, InvalidStoreIdException>((long)this.GetHashCode(), "Exception: InvalidStoreIdException. personIdParam = {0}. Exception: {1}", personIdParam, arg);
                }
            }
            Guid empty = Guid.Empty;

            if (!string.IsNullOrEmpty(adObjectIdParam) && Guid.TryParse(adObjectIdParam, out empty))
            {
                this.adObjectId = new ADObjectId(empty);
                this.tracer.TraceDebug <ADObjectId>((long)this.GetHashCode(), "adObjectId = {0}", this.adObjectId);
            }
            if (!string.IsNullOrEmpty(singleSourceId))
            {
                if (IdConverter.EwsIdIsActiveDirectoryObject(singleSourceId))
                {
                    this.adObjectId = IdConverter.EwsIdToADObjectId(singleSourceId);
                    this.tracer.TraceDebug <ADObjectId>((long)this.GetHashCode(), "adObjectId = {0}", this.adObjectId);
                    return;
                }
                this.contactId = IdConverter.EwsIdToMessageStoreObjectId(singleSourceId);
                this.tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "contactId = {0}", this.contactId);
            }
        }
Exemplo n.º 2
0
        private GetGroupResponse GetPDLData()
        {
            GetGroupResponse getGroupResponse = new GetGroupResponse();
            MailboxSession   mailboxIdentityMailboxSession = base.CallContext.SessionCache.GetMailboxIdentityMailboxSession();
            ItemId           sourceId     = this.itemId;
            IdAndSession     idAndSession = null;

            if (this.parentFolderid != null && this.parentFolderid.BaseFolderId != null)
            {
                IdAndSession idAndSession2 = base.GetIdAndSession(this.parentFolderid.BaseFolderId);
                if (idAndSession2 != null && idAndSession2.Session.IsPublicFolderSession)
                {
                    idAndSession = idAndSession2;
                }
            }
            if (IdConverter.EwsIdIsConversationId(this.itemId.Id))
            {
                try
                {
                    Persona persona;
                    if (idAndSession != null)
                    {
                        persona = Persona.LoadFromPersonaId(idAndSession.Session, null, this.itemId, Persona.FullPersonaShape, null, idAndSession.Id);
                    }
                    else
                    {
                        persona = Persona.LoadFromPersonIdWithGalAggregation(mailboxIdentityMailboxSession, IdConverter.EwsIdToPersonId(this.itemId.Id), Persona.FullPersonaShape, null);
                    }
                    if (persona.Attributions.Length > 0)
                    {
                        sourceId = persona.Attributions[0].SourceId;
                        for (int i = 1; i < persona.Attributions.Length; i++)
                        {
                            StoreId storeId = IdConverter.EwsIdToMessageStoreObjectId(persona.Attributions[i].SourceId.Id);
                            using (Item item = Item.Bind(mailboxIdentityMailboxSession, storeId, new PropertyDefinition[]
                            {
                                ContactSchema.PersonId
                            }))
                            {
                                item.OpenAsReadWrite();
                                item[ContactSchema.PersonId] = PersonId.CreateNew();
                                item.Save(SaveMode.NoConflictResolution);
                            }
                        }
                        RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLogger.Current, "UnlinkDupedPDLs", "Success");
                    }
                    else
                    {
                        ExTraceGlobals.GetGroupTracer.TraceError((long)this.hashCode, "ItemId is PersonaId but Persona has no linked contacts (attributions array is empty).");
                        RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLogger.Current, "UnlinkDupedPDLs", "Skipped");
                    }
                }
                catch (LocalizedException arg)
                {
                    ExTraceGlobals.GetGroupTracer.TraceError <LocalizedException>((long)this.hashCode, "Failed to unlink PDLs: {0}", arg);
                    RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLogger.Current, "UnlinkDupedPDLs", "Failed");
                }
            }
            IdAndSession idAndSession3 = base.IdConverter.ConvertItemIdToIdAndSessionReadOnly(sourceId);
            StoreSession storeSession;

            if (idAndSession != null)
            {
                storeSession = idAndSession.Session;
            }
            else
            {
                storeSession = ((idAndSession3.Session as MailboxSession) ?? base.CallContext.SessionCache.GetMailboxIdentityMailboxSession());
            }
            using (DistributionList distributionList = DistributionList.Bind(storeSession, idAndSession3.Id))
            {
                if (distributionList == null)
                {
                    this.WriteDebugTrace("No PDL was found");
                    return(getGroupResponse);
                }
                PersonId personId = (PersonId)distributionList[ContactSchema.PersonId];
                getGroupResponse.PersonaId = IdConverter.PersonaIdFromPersonId(storeSession.MailboxGuid, personId);
                if (!distributionList.GetValueOrDefault <bool>(ItemSchema.ConversationIndexTracking, false))
                {
                    try
                    {
                        distributionList.OpenAsReadWrite();
                        distributionList[ItemSchema.ConversationIndexTracking] = true;
                        distributionList.Save(SaveMode.NoConflictResolution);
                        RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLogger.Current, "SetConversationIndexTracking", "Success");
                    }
                    catch (LocalizedException arg2)
                    {
                        ExTraceGlobals.GetGroupTracer.TraceError <LocalizedException>((long)this.hashCode, "Failed to set ConversationIndexTracking on PDL: {0}", arg2);
                        RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLogger.Current, "SetConversationIndexTracking", "Failed");
                    }
                }
                if (!this.IsMembersInResultSet)
                {
                    return(getGroupResponse);
                }
                int count = distributionList.Count;
                getGroupResponse.MembersCount = count;
                this.WriteDebugTrace("Total PDL members count is " + count);
                if (this.paging.Offset < 0 || count <= this.paging.Offset)
                {
                    this.WriteDebugTrace(string.Format("Provided offset is out of range - members count is {0}, offset is {1}.", count, this.paging.Offset));
                    return(getGroupResponse);
                }
                distributionList.Sort(this.PDlMembersComparer);
                List <Persona>           list       = new List <Persona>();
                List <string>            list2      = new List <string>();
                Dictionary <string, int> dictionary = new Dictionary <string, int>();
                int num = Math.Min(count, this.paging.Offset + this.paging.MaxRows);
                for (int j = this.paging.Offset; j < num; j++)
                {
                    DistributionListMember distributionListMember = distributionList[j];
                    if (distributionListMember.Participant == null)
                    {
                        if (num < count)
                        {
                            num++;
                        }
                        getGroupResponse.MembersCount--;
                    }
                    else
                    {
                        bool    flag     = false;
                        Persona persona2 = GetGroupCommand.CreatePersonaFromDistributionListMember(mailboxIdentityMailboxSession, distributionListMember, out flag);
                        if (flag)
                        {
                            list2.Add(persona2.EmailAddress.EmailAddress);
                            dictionary.Add(persona2.EmailAddress.EmailAddress, list.Count);
                        }
                        list.Add(persona2);
                    }
                }
                if (list2.Count > 0)
                {
                    IRecipientSession     galscopedADRecipientSession = base.CallContext.ADRecipientSessionContext.GetGALScopedADRecipientSession(base.CallContext.EffectiveCaller.ClientSecurityContext);
                    Result <ADRawEntry>[] array = galscopedADRecipientSession.FindByLegacyExchangeDNs(list2.ToArray(), new PropertyDefinition[]
                    {
                        ADObjectSchema.Id,
                        ADRecipientSchema.DisplayName,
                        ADRecipientSchema.PrimarySmtpAddress,
                        ADRecipientSchema.RecipientType,
                        ADRecipientSchema.RecipientTypeDetails,
                        ADRecipientSchema.LegacyExchangeDN
                    });
                    foreach (Result <ADRawEntry> result in array)
                    {
                        if (result.Data != null)
                        {
                            Persona personaFromADObject = GetGroupCommand.GetPersonaFromADObject(result.Data);
                            string  key = result.Data[ADRecipientSchema.LegacyExchangeDN] as string;
                            int     num2;
                            if (dictionary.ContainsKey(key) && dictionary.TryGetValue(key, out num2) && num2 >= 0)
                            {
                                list[num2] = personaFromADObject;
                            }
                        }
                    }
                }
                list.Sort(this.PersonaComparer);
                Persona[] array3 = new Persona[list.Count];
                list.CopyTo(0, array3, 0, list.Count);
                getGroupResponse.Members = array3;
                this.WriteDebugTrace("PDL members count loaded in the response is " + getGroupResponse.Members.Length);
            }
            return(getGroupResponse);
        }