private static Persona GetPersonaFromADObject(ADRawEntry rawEntry) { if (rawEntry == null) { return(null); } ADObjectId adobjectId = rawEntry[ADObjectSchema.Id] as ADObjectId; if (adobjectId == null) { return(null); } Persona persona = new Persona(); persona.PersonaId = IdConverter.PersonaIdFromADObjectId(adobjectId.ObjectGuid); RecipientType recipientType = (RecipientType)rawEntry[ADRecipientSchema.RecipientType]; PersonType personType = ADRecipient.IsRecipientTypeDL(recipientType) ? PersonType.DistributionList : PersonType.Person; RecipientTypeDetails recipientTypeDetails = (RecipientTypeDetails)rawEntry[ADRecipientSchema.RecipientTypeDetails]; if (recipientTypeDetails == RecipientTypeDetails.GroupMailbox) { personType = PersonType.ModernGroup; } persona.PersonaType = PersonaTypeConverter.ToString(personType); object obj = rawEntry[ADRecipientSchema.DisplayName]; if (obj != null) { persona.DisplayName = (obj as string); } object obj2 = rawEntry[ADRecipientSchema.PrimarySmtpAddress]; if (obj2 != null) { persona.EmailAddress = new EmailAddressWrapper { Name = (persona.DisplayName ?? string.Empty), EmailAddress = obj2.ToString(), RoutingType = "SMTP", MailboxType = MailboxHelper.ConvertToMailboxType(personType).ToString() }; } object obj3 = rawEntry[ADUserSchema.RTCSIPPrimaryUserAddress]; if (obj3 != null) { persona.ImAddress = obj3.ToString(); } return(persona); }
private static Persona CreatePersonaFromDistributionListMember(MailboxSession session, DistributionListMember member, out bool isADMember) { isADMember = false; Participant participant = member.Participant; Persona persona = new Persona(); persona.DisplayName = participant.DisplayName; persona.ImAddress = participant.GetValueOrDefault <string>(ParticipantSchema.SipUri, null); persona.EmailAddress = new EmailAddressWrapper(); persona.EmailAddress.RoutingType = participant.RoutingType; persona.EmailAddress.EmailAddress = participant.EmailAddress; persona.EmailAddress.Name = participant.DisplayName; StoreParticipantOrigin storeParticipantOrigin = participant.Origin as StoreParticipantOrigin; bool flag = member.MainEntryId is ADParticipantEntryId; PersonType personType = PersonType.Unknown; if (storeParticipantOrigin != null) { personType = ((string.CompareOrdinal(participant.RoutingType, "MAPIPDL") == 0) ? PersonType.DistributionList : PersonType.Person); if (session != null) { persona.EmailAddress.ItemId = IdConverter.GetItemIdFromStoreId(storeParticipantOrigin.OriginItemId, new MailboxId(session)); } persona.EmailAddress.EmailAddressIndex = storeParticipantOrigin.EmailAddressIndex.ToString(); if (personType == PersonType.DistributionList) { persona.EmailAddress.MailboxType = MailboxHelper.MailboxTypeType.PrivateDL.ToString(); } else if (personType == PersonType.Person) { persona.EmailAddress.MailboxType = MailboxHelper.MailboxTypeType.Contact.ToString(); } } else if (flag) { isADMember = true; } else { persona.EmailAddress.MailboxType = MailboxHelper.MailboxTypeType.OneOff.ToString(); } persona.PersonaType = PersonaTypeConverter.ToString(personType); return(persona); }