// Token: 0x0600167E RID: 5758 RVA: 0x00066D2E File Offset: 0x00064F2E
 internal ADMailboxRecipient(IRecipientSession session, PropertyBag propertyBag) : base(session, propertyBag)
 {
 }
Ejemplo n.º 2
0
        internal MailTipsPermission Lookup(RecipientData recipientData)
        {
            if (this.ExternalClientContext == null)
            {
                this.tracer.TraceDebug <object, EmailAddress>((long)this.traceId, "{0}: InternalMailTipsPermission used for {1} because requester is not external", TraceContext.Get(), recipientData.EmailAddress);
                return(MailTipsPermission.AllAccess);
            }
            if (recipientData.IsEmpty)
            {
                this.tracer.TraceDebug <object, EmailAddress>((long)this.traceId, "{0}: InternalMailTipsPermission used for {1} because recipient did not resolve in AD", TraceContext.Get(), recipientData.EmailAddress);
                return(MailTipsPermission.AllAccess);
            }
            MailTipsPermission mailTipsPermission;

            if (this.permissionMap.TryGetValue(recipientData.OrganizationId, out mailTipsPermission))
            {
                return(mailTipsPermission);
            }
            OrganizationRelationship organizationRelationship = FreeBusyPermission.GetOrganizationRelationship(recipientData.OrganizationId, this.ExternalClientContext.EmailAddress.Domain);

            if (organizationRelationship == null || !organizationRelationship.Enabled)
            {
                this.tracer.TraceDebug <object, OrganizationId, string>((long)this.traceId, "{0}: No organization relationship found in organization {1} for domain {2}", TraceContext.Get(), recipientData.OrganizationId, this.ExternalClientContext.EmailAddress.Domain);
                return(MailTipsPermission.NoAccess);
            }
            bool requesterInAccessScope = false;

            if (organizationRelationship.MailTipsAccessScope == null)
            {
                requesterInAccessScope = true;
            }
            else if (organizationRelationship.MailTipsAccessEnabled && organizationRelationship.MailTipsAccessLevel != MailTipsAccessLevel.None)
            {
                IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(recipientData.OrganizationId), 127, "Lookup", "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\MailTips\\MailTipsPerRequesterPermissionMap.cs");
                ADGroup           adgroup = tenantOrRootOrgRecipientSession.Read(organizationRelationship.MailTipsAccessScope) as ADGroup;
                if (adgroup == null)
                {
                    this.tracer.TraceError <object, OrganizationId, ADObjectId>((long)this.traceId, "{0}: OrganizationRelationship for organization {1} has invalid MailTipsAccessScope {2} which cannot be resolved in ad as an ADGroup", TraceContext.Get(), recipientData.OrganizationId, organizationRelationship.MailTipsAccessScope);
                }
                else if (adgroup.ContainsMember(recipientData.Id, false))
                {
                    this.tracer.TraceDebug((long)this.traceId, "{0}: {1} is a member of MailTipsAccessScope {2} for OrganizationRelationship of organization {3}", new object[]
                    {
                        TraceContext.Get(),
                        recipientData.EmailAddress,
                        organizationRelationship.MailTipsAccessScope,
                        recipientData.OrganizationId
                    });
                    requesterInAccessScope = true;
                }
                else
                {
                    this.tracer.TraceDebug((long)this.traceId, "{0}: {1} is not a member of MailTipsAccessScope {2} for OrganizationRelationship of organization {3}", new object[]
                    {
                        TraceContext.Get(),
                        recipientData.EmailAddress,
                        organizationRelationship.MailTipsAccessScope,
                        recipientData.OrganizationId
                    });
                }
            }
            mailTipsPermission = new MailTipsPermission(organizationRelationship.MailTipsAccessEnabled, organizationRelationship.MailTipsAccessLevel, requesterInAccessScope);
            this.permissionMap[recipientData.OrganizationId] = mailTipsPermission;
            return(mailTipsPermission);
        }
 // Token: 0x060019D7 RID: 6615 RVA: 0x0006CEF6 File Offset: 0x0006B0F6
 internal ADMicrosoftExchangeRecipient(IRecipientSession session, string commonName, ADObjectId containerId)
 {
     this.m_Session = session;
     base.SetId(containerId.GetChildId("CN", commonName));
     base.SetObjectClass(this.MostDerivedObjectClass);
 }
Ejemplo n.º 4
0
 // Token: 0x060010A2 RID: 4258 RVA: 0x00044314 File Offset: 0x00042514
 public static void UpdateAndSaveTextMessgaingStateOnAdUser(TextMessagingAccount account, ADRecipient adRecipient, IRecipientSession adSession)
 {
     if (account == null)
     {
         throw new ArgumentNullException("account");
     }
     if (adRecipient == null)
     {
         throw new ArgumentNullException("adRecipient");
     }
     if (adSession == null)
     {
         throw new ArgumentNullException("adSession");
     }
     if (TextMessagingHelper.UpdateTextMessagingState(adRecipient.TextMessagingState, account.TextMessagingSettings.DeliveryPoints))
     {
         adSession.Save(adRecipient);
     }
 }
		public static void SendWelcomeMessageIfNeeded(MailboxSession originalSession)
		{
			if (!string.IsNullOrEmpty(originalSession.ClientInfoString) && (originalSession.ClientInfoString.Equals("Client=TeamMailbox;Action=SendWelcomeMessageToSiteMailbox;Interactive=False", StringComparison.OrdinalIgnoreCase) || originalSession.ClientInfoString.Equals("Client=TeamMailbox;Action=GetDiagnostics;Interactive=False", StringComparison.OrdinalIgnoreCase) || originalSession.ClientInfoString.Equals("Client=TeamMailbox;Action=Send_Notification", StringComparison.OrdinalIgnoreCase)))
			{
				return;
			}
			originalSession.Mailbox.Load(new PropertyDefinition[]
			{
				MailboxSchema.SiteMailboxInternalState
			});
			int? siteMailboxInternalState = originalSession.Mailbox.TryGetProperty(InternalSchema.SiteMailboxInternalState) as int?;
			if (siteMailboxInternalState != null)
			{
				if ((siteMailboxInternalState.Value & 1) == 1)
				{
					return;
				}
			}
			try
			{
				using (MailboxSession mailboxSession = MailboxSession.OpenAsAdmin(originalSession.MailboxOwner, originalSession.InternalCulture, "Client=TeamMailbox;Action=SendWelcomeMessageToSiteMailbox;Interactive=False"))
				{
					string internetMessageId = "ed590c4ca1674effa0067475ab2b93b2_" + mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress;
					using (MessageItem messageItem = MessageItem.CreateForDelivery(mailboxSession, mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox), internetMessageId, new ExDateTime?(ExDateTime.MinValue)))
					{
						messageItem.Recipients.Add(new Participant(mailboxSession.MailboxOwner.MailboxInfo.DisplayName, mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(), "SMTP"));
						messageItem.From = new Participant(mailboxSession.MailboxOwner);
						IRecipientSession recipientSession = null;
						TeamMailbox teamMailbox = TeamMailboxNotificationHelper.GetTeamMailbox(mailboxSession, out recipientSession);
						TeamMailboxNotificationHelper teamMailboxNotificationHelper = new TeamMailboxNotificationHelper(teamMailbox, recipientSession);
						messageItem.Subject = teamMailboxNotificationHelper.GetSubject(TeamMailboxNotificationType.Welcome);
						using (Stream stream = messageItem.Body.OpenWriteStream(new BodyWriteConfiguration(BodyFormat.TextHtml, Charset.Unicode)))
						{
							using (StreamWriter streamWriter = new StreamWriter(stream, Encoding.Unicode))
							{
								streamWriter.WriteLine(teamMailboxNotificationHelper.GetBody(TeamMailboxNotificationType.Welcome));
							}
						}
						messageItem.AutoResponseSuppress = AutoResponseSuppress.All;
						messageItem.InternetMessageId = internetMessageId;
						messageItem.PropertyBag[InternalSchema.SentTime] = ExDateTime.UtcNow;
						mailboxSession.Deliver(messageItem, ProxyAddress.Parse(ProxyAddressPrefix.Smtp.PrimaryPrefix, mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString()), RecipientItemType.To);
					}
					TeamMailboxNotificationHelper.UpdateWelcomeMessageSentState(siteMailboxInternalState, mailboxSession);
				}
			}
			catch (StoragePermanentException ex)
			{
				if (ex.InnerException != null && ex.InnerException is MapiExceptionDuplicateDelivery)
				{
					using (MailboxSession mailboxSession2 = MailboxSession.OpenAsAdmin(originalSession.MailboxOwner, originalSession.Culture, "Client=TeamMailbox;Action=SendWelcomeMessageToSiteMailbox;Interactive=False"))
					{
						TeamMailboxNotificationHelper.UpdateWelcomeMessageSentState(siteMailboxInternalState, mailboxSession2);
						goto IL_27D;
					}
					goto IL_27B;
					IL_27D:
					return;
				}
				IL_27B:
				throw;
			}
		}
Ejemplo n.º 6
0
        public bool IsMemberOf(Guid adUserObjectGuid, RoutingAddress group)
        {
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(this.organizationId), 120, "IsMemberOf", "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\OrganizationConfiguration\\GroupsConfiguration.cs");

            return(this.IsMemberOf(tenantOrRootOrgRecipientSession, adUserObjectGuid, group));
        }
Ejemplo n.º 7
0
 // Token: 0x060011E6 RID: 4582 RVA: 0x0004B294 File Offset: 0x00049494
 public MailboxPhotoHandler(PhotosConfiguration configuration, string clientInfo, IMailboxPhotoReader reader, IRecipientSession recipientSession, ITracer upstreamTracer, IXSOFactory xsoFactory)
 {
     ArgumentValidator.ThrowIfNull("configuration", configuration);
     ArgumentValidator.ThrowIfNullOrEmpty("clientInfo", clientInfo);
     ArgumentValidator.ThrowIfNull("reader", reader);
     ArgumentValidator.ThrowIfNull("recipientSession", recipientSession);
     ArgumentValidator.ThrowIfNull("upstreamTracer", upstreamTracer);
     ArgumentValidator.ThrowIfNull("xsoFactory", xsoFactory);
     this.tracer           = ExTraceGlobals.UserPhotosTracer.Compose(upstreamTracer);
     this.configuration    = configuration;
     this.xsoFactory       = xsoFactory;
     this.reader           = reader;
     this.clientInfo       = clientInfo;
     this.recipientSession = recipientSession;
 }
 // Token: 0x06001405 RID: 5125 RVA: 0x00060029 File Offset: 0x0005E229
 internal StorageMiniRecipient(IRecipientSession session, PropertyBag propertyBag) : base(session, propertyBag)
 {
 }
        private Stream GetADPictureStream(string email, string routingType)
        {
            IRecipientSession recipientSession = Utilities.CreateADRecipientSession(ConsistencyMode.IgnoreInvalid, base.UserContext);

            byte[] array      = null;
            bool   flag       = string.Equals(email, base.UserContext.ExchangePrincipal.LegacyDn, StringComparison.OrdinalIgnoreCase);
            string stringHash = Utilities.GetStringHash(email);
            bool   flag2      = DisplayPictureUtility.IsInRecipientsNegativeCache(stringHash);

            if (!flag2 || flag)
            {
                ProxyAddress proxyAddress = null;
                try
                {
                    if (string.Equals(routingType, "EX", StringComparison.Ordinal))
                    {
                        proxyAddress = new CustomProxyAddress((CustomProxyAddressPrefix)ProxyAddressPrefix.LegacyDN, email, true);
                    }
                    else if (string.Equals(routingType, "SMTP", StringComparison.Ordinal))
                    {
                        proxyAddress = new SmtpProxyAddress(email, true);
                    }
                    if (proxyAddress != null)
                    {
                        if (Globals.ArePerfCountersEnabled)
                        {
                            OwaSingleCounters.SenderPhotosTotalLDAPCalls.Increment();
                        }
                        ADRawEntry adrawEntry = recipientSession.FindByProxyAddress(proxyAddress, new PropertyDefinition[]
                        {
                            ADRecipientSchema.ThumbnailPhoto
                        });
                        if (adrawEntry != null)
                        {
                            array = (adrawEntry[ADRecipientSchema.ThumbnailPhoto] as byte[]);
                        }
                    }
                    goto IL_10F;
                }
                catch (NonUniqueRecipientException ex)
                {
                    ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "GetADPictureStream: NonUniqueRecipientException was thrown by FindByProxyAddress: {0}", ex.Message);
                    throw new OwaEventHandlerException("Unable to retrieve recipient data.", LocalizedStrings.GetNonEncoded(-1953304495));
                }
            }
            if (Globals.ArePerfCountersEnabled)
            {
                OwaSingleCounters.SenderPhotosDataFromNegativeCacheCount.Increment();
            }
IL_10F:
            bool flag3 = array != null && array.Length > 0;

            if (flag)
            {
                base.UserContext.HasPicture = new bool?(flag3);
            }
            if (flag3)
            {
                if (Globals.ArePerfCountersEnabled)
                {
                    OwaSingleCounters.SenderPhotosTotalLDAPCallsWithPicture.Increment();
                }
                if (flag2)
                {
                    DisplayPictureUtility.RecipientsNegativeCache.Remove(stringHash);
                }
                return(new MemoryStream(array));
            }
            if (!flag2)
            {
                int num = DisplayPictureUtility.RecipientsNegativeCache.AddAndCount(stringHash, DateTime.UtcNow);
                if (Globals.ArePerfCountersEnabled)
                {
                    OwaSingleCounters.SenderPhotosNegativeCacheCount.RawValue = (long)num;
                }
            }
            return(new MemoryStream());
        }
        // Token: 0x0600108A RID: 4234 RVA: 0x00060890 File Offset: 0x0005EA90
        internal void GetMetricsForSingleGroup(IRecipientSession session, string groupDN, TypedHashSet calculatedGroups, Dictionary <string, object> parentGroupDictionary, IList <string> parentGroupList)
        {
            ADObjectId        id                = new ADObjectId(groupDN);
            ADRawEntry        group             = null;
            ADOperationResult adoperationResult = this.TryRunPerGroupADOperation(delegate
            {
                group = session.ReadADRawEntry(id, GroupMetricsGenerator.groupProperties);
            }, groupDN);

            if (!adoperationResult.Succeeded || group == null)
            {
                return;
            }
            ulong hash = GroupMetricsUtility.GetHash(group.Id.ObjectGuid);

            if (calculatedGroups.Contains(hash))
            {
                return;
            }
            int                  externalMemberCount = 0;
            HashSet <ulong>      allMemberHashes     = new HashSet <ulong>(2000);
            ADRecipientExpansion expander            = new ADRecipientExpansion(session, false);

            adoperationResult = this.TryRunPerGroupADOperation(delegate
            {
                if (GroupMetricsUtility.Fault == GroupMetricsFault.TransientExceptionInExpansion)
                {
                    throw new ADTransientException(new LocalizedString("Fault Injection"));
                }
                if (GroupMetricsUtility.Fault == GroupMetricsFault.InvalidCredentialExceptionInExpansion)
                {
                    throw new ADInvalidCredentialException(new LocalizedString("Fault Injection"));
                }
                if (GroupMetricsUtility.Fault == GroupMetricsFault.PermanentExceptionInExpansion)
                {
                    throw new DataSourceOperationException(new LocalizedString("Fault Injection"));
                }
                expander.Expand(group, delegate(ADRawEntry member, ExpansionType recipientExpansionType, ADRawEntry parent, ExpansionType parentExpansionType)
                {
                    this.RunData.ThrowIfShuttingDown();
                    if (recipientExpansionType == ExpansionType.GroupMembership)
                    {
                        return(ExpansionControl.Continue);
                    }
                    ulong hash2 = GroupMetricsUtility.GetHash(member.Id.ObjectGuid);
                    if (allMemberHashes.TryAdd(hash2) && this.IsExternal(member))
                    {
                        externalMemberCount++;
                    }
                    if (allMemberHashes.Count >= 1000)
                    {
                        return(ExpansionControl.Terminate);
                    }
                    if (recipientExpansionType != ExpansionType.None)
                    {
                        return(ExpansionControl.Skip);
                    }
                    return(ExpansionControl.Continue);
                }, (ExpansionFailure failure, ADRawEntry member, ExpansionType recipientExpansionType, ADRawEntry parent, ExpansionType parentExpansionType) => ExpansionControl.Continue);
            }, groupDN);
            if (!adoperationResult.Succeeded)
            {
                return;
            }
            MultiValuedProperty <ADObjectId> multiValuedProperty = group[ADRecipientSchema.MemberOfGroup] as MultiValuedProperty <ADObjectId>;

            foreach (ADObjectId adobjectId in multiValuedProperty)
            {
                string distinguishedName = adobjectId.DistinguishedName;
                if (!parentGroupDictionary.ContainsKey(distinguishedName))
                {
                    parentGroupDictionary.Add(distinguishedName, null);
                    parentGroupList.Add(distinguishedName);
                }
            }
            int count = allMemberHashes.Count;

            calculatedGroups.Add(hash);
            this.groupsExpanded++;
            int oldValue  = (int)group[ADGroupSchema.GroupMemberCount];
            int oldValue2 = (int)group[ADGroupSchema.GroupExternalMemberCount];

            if (this.ShouldSaveToAD(oldValue, count) || this.ShouldSaveToAD(oldValue2, externalMemberCount))
            {
                this.SaveGroupMetricsToAD(session, group, count, externalMemberCount);
            }
        }
        // Token: 0x06001094 RID: 4244 RVA: 0x000611B4 File Offset: 0x0005F3B4
        private bool GetMetricsForChangedGroups(GroupMetricsGeneratorTaskContext context)
        {
            string       text             = this.changedGroupListPath;
            TypedHashSet calculatedGroups = new TypedHashSet(20000);

            try
            {
                if (GroupMetricsUtility.Fault == GroupMetricsFault.UnreadableChangedGroupFile)
                {
                    text = this.tenantDirectory;
                }
                List <string> list = new List <string>();
                Dictionary <string, object> parentGroupDictionary           = new Dictionary <string, object>();
                IRecipientSession           tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(base.OrgId), 1316, "GetMetricsForChangedGroups", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\DirectoryProcessor\\GroupMetricsGenerator\\GroupMetricsGenerator.cs");
                using (StreamReader streamReader = new StreamReader(text))
                {
                    string text2;
                    if (context.LastProcessedGroupDistinguishedName != null)
                    {
                        while ((text2 = streamReader.ReadLine()) != null && text2 != context.LastProcessedGroupDistinguishedName)
                        {
                        }
                    }
                    DateTime utcNow = DateTime.UtcNow;
                    while ((text2 = streamReader.ReadLine()) != null)
                    {
                        this.GetMetricsForSingleGroup(tenantOrRootOrgRecipientSession, text2, calculatedGroups, parentGroupDictionary, list);
                        context.LastProcessedGroupDistinguishedName = text2;
                        if ((Utilities.TestForceYieldChunk && this.groupsExpanded > 2) || DateTime.UtcNow - utcNow > this.OneChunkTimeLimit)
                        {
                            break;
                        }
                        base.RunData.ThrowIfShuttingDown();
                    }
                    if (text2 == null)
                    {
                        context.AllChunksFinished = true;
                    }
                }
                for (int i = 0; i < list.Count; i++)
                {
                    string text2 = list[i];
                    this.GetMetricsForSingleGroup(tenantOrRootOrgRecipientSession, text2, calculatedGroups, parentGroupDictionary, list);
                }
                return(true);
            }
            catch (FileNotFoundException)
            {
                context.AllChunksFinished = true;
                return(true);
            }
            catch (IOException ex)
            {
                GroupMetricsGenerator.EventLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_UnableToReadChangedGroupList, null, new object[]
                {
                    this.GetOrganizationIdString(),
                    text,
                    ex.GetType().FullName,
                    ex.Message
                });
            }
            catch (UnauthorizedAccessException ex2)
            {
                GroupMetricsGenerator.EventLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_UnableToReadChangedGroupList, null, new object[]
                {
                    this.GetOrganizationIdString(),
                    text,
                    ex2.GetType().FullName,
                    ex2.Message
                });
            }
            catch (SecurityException ex3)
            {
                GroupMetricsGenerator.EventLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_UnableToReadChangedGroupList, null, new object[]
                {
                    this.GetOrganizationIdString(),
                    text,
                    ex3.GetType().FullName,
                    ex3.Message
                });
            }
            return(false);
        }
Ejemplo n.º 12
0
 private static RpcAssociationReplicatorRunNowParameters Instantiate(List <MailboxLocatorType> locators, IRecipientSession adSession)
 {
     ArgumentValidator.ThrowIfNull("adSession", adSession);
     if (locators != null && locators.Count > 0)
     {
         List <IMailboxLocator> list = new List <IMailboxLocator>(locators.Count);
         for (int i = 0; i < locators.Count; i++)
         {
             list.Add(EwsAssociationDataConverter.Convert(locators[i], adSession));
         }
         return(new RpcAssociationReplicatorRunNowParameters
         {
             SlaveMailboxes = list
         });
     }
     return(new RpcAssociationReplicatorRunNowParameters());
 }
 public UnseenCountBrokerHandler(string subscriptionId, SubscriptionParameters parameters, IMailboxContext userContext, IRecipientSession adSession) : base(subscriptionId, parameters, userContext)
 {
     using (DisposeGuard disposeGuard = this.Guard())
     {
         this.adSession          = adSession;
         this.unseenItemNotifier = new UnseenItemNotifier(subscriptionId, userContext, null, null);
         this.unseenItemNotifier.RegisterWithPendingRequestNotifier();
         disposeGuard.Success();
     }
 }
Ejemplo n.º 14
0
        // Token: 0x06000B4A RID: 2890 RVA: 0x00048AC0 File Offset: 0x00046CC0
        private void UpdateSafeLists(MailboxSession mailboxSession)
        {
            ADObjectId adobjectId = (mailboxSession.MailboxOwner != null) ? mailboxSession.MailboxOwner.ObjectId : null;

            if (adobjectId == null)
            {
                JunkEmailOptionsCommiterAssistant.Tracer.TraceError <MailboxSession>((long)this.GetHashCode(), "can't determine owner of mailbox {0}", mailboxSession);
                return;
            }
            if (TemplateTenantConfiguration.IsTemplateTenant(mailboxSession.MailboxOwner.MailboxInfo.OrganizationId))
            {
                JunkEmailOptionsCommiterAssistant.Tracer.TraceDebug <string, Guid>((long)this.GetHashCode(), "Skipping mailbox {0} (GUID: {1}) because it belongs to a consumer tenant.", mailboxSession.MailboxOwner.MailboxInfo.DisplayName, mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid);
                return;
            }
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(mailboxSession.MailboxOwner.MailboxInfo.OrganizationId), 318, "UpdateSafeLists", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\JunkEmailOptions\\JunkEmailOptionsCommiterAssistant.cs");
            ADUser            aduser = tenantOrRootOrgRecipientSession.Read(adobjectId) as ADUser;

            if (aduser == null)
            {
                JunkEmailOptionsCommiterAssistant.Tracer.TraceError <ADObjectId>((long)this.GetHashCode(), "can't read user object {0} from AD.", adobjectId);
                return;
            }
            JunkEmailRule filteredJunkEmailRule = mailboxSession.FilteredJunkEmailRule;
            bool          flag  = false;
            bool          flag2 = false;
            bool          flag3 = false;

            byte[] array  = filteredJunkEmailRule.IsEnabled ? this.GetSafeSendersHash(filteredJunkEmailRule, out flag) : null;
            byte[] array2 = filteredJunkEmailRule.IsEnabled ? this.GetSafeRecipientsHash(filteredJunkEmailRule, out flag2) : null;
            byte[] array3 = filteredJunkEmailRule.IsEnabled ? this.GetBlockedSendersHash(filteredJunkEmailRule, out flag3) : null;
            bool   flag4  = false;

            if (!ArrayComparer <byte> .Comparer.Equals(array, aduser.SafeSendersHash))
            {
                aduser.SafeSendersHash = array;
                flag4 = true;
            }
            if (!ArrayComparer <byte> .Comparer.Equals(array2, aduser.SafeRecipientsHash))
            {
                aduser.SafeRecipientsHash = array2;
                flag4 = true;
            }
            if (!ArrayComparer <byte> .Comparer.Equals(array3, aduser.BlockedSendersHash))
            {
                aduser.BlockedSendersHash = array3;
                flag4 = true;
            }
            if (flag4)
            {
                JunkEmailOptionsCommiterAssistant.Tracer.TraceDebug <ADObjectId>((long)this.GetHashCode(), "Saving updated recipient object {0} to AD...", adobjectId);
                tenantOrRootOrgRecipientSession.Save(aduser);
                JunkEmailOptionsPerfCounters.TotalRecipientsUpdated.Increment();
                JunkEmailOptionsCommiterAssistant.Tracer.TraceDebug <ADObjectId>((long)this.GetHashCode(), "Recipient object {0} was successfully saved", adobjectId);
                if (flag || flag2 || flag3)
                {
                    JunkEmailOptionsPerfCounters.TotalPartialUpdates.Increment();
                }
            }
            Exception ex = null;

            try
            {
                if (flag4 || !filteredJunkEmailRule.AllRestrictionsLoaded)
                {
                    filteredJunkEmailRule.Save();
                }
            }
            catch (StoragePermanentException ex2)
            {
                ex = ex2;
            }
            catch (StorageTransientException ex3)
            {
                ex = ex3;
            }
            finally
            {
                if (ex != null)
                {
                    JunkEmailOptionsCommiterAssistant.EventLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_FailedToUpdateMailbox, null, new object[]
                    {
                        mailboxSession.MailboxGuid,
                        ex
                    });
                }
            }
        }
Ejemplo n.º 15
0
 public GroupConfiguration GetGroupInformation(IRecipientSession session, Guid group)
 {
     return(GroupsConfiguration.groupsResolver.Value.GetGroupInfo(session, group));
 }
Ejemplo n.º 16
0
 public DeleteUnifiedGroupTask(ADUser accessingUser, ExchangePrincipal accessingPrincipal, IRecipientSession adSession) : base(accessingUser, adSession)
 {
     this.accessingPrincipal = accessingPrincipal;
 }
Ejemplo n.º 17
0
 public bool IsMemberOf(IRecipientSession session, ADObjectId user, string group)
 {
     return(GroupsConfiguration.groupsResolver.Value.IsMemberOf(session, user, (RoutingAddress)group));
 }
Ejemplo n.º 18
0
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            try
            {
                base.ValidateRootFolders(this.SourceRootFolder, this.TargetRootFolder);
                bool wildcardedSearch = false;
                if (!string.IsNullOrEmpty(base.Name))
                {
                    base.ValidateName();
                    base.RequestName = base.Name;
                }
                else
                {
                    wildcardedSearch = true;
                    base.RequestName = "MailboxRestore";
                }
                this.targetUser = RequestTaskHelper.ResolveADUser(base.RecipSession, base.GCSession, base.ServerSettings, this.TargetMailbox, base.OptionalIdentityData, base.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), true);
                this.CheckForInvalidPublicFolderRestoreParameters();
                if (this.targetUser.HasLocalArchive && this.targetUser.RecipientType == RecipientType.MailUser && this.targetUser.Database == null && !this.TargetIsArchive)
                {
                    base.WriteError(new MissingArchiveParameterForRestorePermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.TargetMailbox);
                }
                if (this.targetUser.RecipientType != RecipientType.UserMailbox && (!this.TargetIsArchive || this.targetUser.RecipientType != RecipientType.MailUser))
                {
                    base.WriteError(new InvalidRecipientTypePermanentException(this.targetUser.ToString(), this.targetUser.RecipientType.ToString()), ErrorCategory.InvalidArgument, this.TargetMailbox);
                }
                if (this.TargetIsArchive && (this.targetUser.ArchiveGuid == Guid.Empty || this.targetUser.ArchiveDatabase == null))
                {
                    base.WriteError(new MailboxLacksArchivePermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.TargetIsArchive);
                }
                if (!this.TargetIsArchive && this.targetUser.Database == null)
                {
                    base.WriteError(new MailboxLacksDatabasePermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.TargetMailbox);
                }
                if (base.ParameterSetName.Equals("RemoteMailboxRestore"))
                {
                    if (!Guid.TryParse(this.SourceStoreMailbox.RawIdentity, out this.sourceMailboxGuid))
                    {
                        base.WriteError(new RecipientTaskException(Strings.ErrorParameterValueNotAllowed("SourceStoreMailbox")), ErrorCategory.InvalidArgument, this.SourceStoreMailbox);
                    }
                    if (!base.Fields.IsModified("AllowLegacyDNMismatch") || !this.AllowLegacyDNMismatch)
                    {
                        base.WriteError(new RecipientTaskException(Strings.ErrorParameterValueNotAllowed("AllowLegacyDNMismatch")), ErrorCategory.InvalidArgument, this.AllowLegacyDNMismatch);
                    }
                    base.Flags = (RequestFlags.CrossOrg | RequestFlags.Pull);
                    switch (this.RemoteRestoreType)
                    {
                    case RemoteRestoreType.RecoveryDatabase:
                        this.restoreFlags |= MailboxRestoreType.Recovery;
                        this.restoreFlags |= MailboxRestoreType.SoftDeleted;
                        break;

                    case RemoteRestoreType.DisconnectedMailbox:
                        this.restoreFlags |= MailboxRestoreType.SoftDeleted;
                        break;

                    case RemoteRestoreType.SoftDeletedRecipient:
                        this.restoreFlags |= MailboxRestoreType.SoftDeletedRecipient;
                        break;

                    default:
                        base.WriteError(new RecipientTaskException(Strings.ErrorParameterValueNotAllowed("RemoteRestoreType")), ErrorCategory.InvalidArgument, this.RemoteRestoreType);
                        break;
                    }
                }
                else
                {
                    base.Flags = (RequestFlags.IntraOrg | RequestFlags.Pull);
                    string          fqdn;
                    string          serverExchangeLegacyDn;
                    ADObjectId      adobjectId;
                    int             num;
                    MailboxDatabase mailboxDatabase = base.CheckDatabase <MailboxDatabase>(this.SourceDatabase, NewRequest <MailboxRestoreRequest> .DatabaseSide.Source, this.SourceDatabase, out fqdn, out serverExchangeLegacyDn, out adobjectId, out num);
                    if (mailboxDatabase.Recovery)
                    {
                        this.restoreFlags |= MailboxRestoreType.Recovery;
                    }
                    this.sourceDatabase            = mailboxDatabase.Id;
                    this.SourceStoreMailbox.Flags |= 1UL;
                    using (MapiSession mapiSession = new MapiAdministrationSession(serverExchangeLegacyDn, Fqdn.Parse(fqdn)))
                    {
                        using (MailboxStatistics mailboxStatistics = (MailboxStatistics)base.GetDataObject <MailboxStatistics>(this.SourceStoreMailbox, mapiSession, MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(mailboxDatabase), new LocalizedString?(Strings.ErrorStoreMailboxNotFound(this.SourceStoreMailbox.ToString(), this.SourceDatabase.ToString())), new LocalizedString?(Strings.ErrorStoreMailboxNotUnique(this.SourceStoreMailbox.ToString(), this.SourceDatabase.ToString()))))
                        {
                            MailboxState?disconnectReason = mailboxStatistics.DisconnectReason;
                            if (mailboxStatistics.MailboxType == StoreMailboxType.PublicFolderPrimary || mailboxStatistics.MailboxType == StoreMailboxType.PublicFolderSecondary)
                            {
                                this.restoreFlags |= MailboxRestoreType.PublicFolderMailbox;
                            }
                            bool flag = false;
                            if (disconnectReason == null && !mailboxDatabase.Recovery)
                            {
                                mapiSession.Administration.SyncMailboxWithDS(mailboxDatabase.Guid, mailboxStatistics.MailboxGuid);
                                using (MailboxStatistics mailboxStatistics2 = (MailboxStatistics)base.GetDataObject <MailboxStatistics>(this.SourceStoreMailbox, mapiSession, MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(mailboxDatabase), new LocalizedString?(Strings.ErrorStoreMailboxNotFound(this.SourceStoreMailbox.ToString(), this.SourceDatabase.ToString())), new LocalizedString?(Strings.ErrorStoreMailboxNotUnique(this.SourceStoreMailbox.ToString(), this.SourceDatabase.ToString()))))
                                {
                                    disconnectReason = mailboxStatistics2.DisconnectReason;
                                    if (disconnectReason == null)
                                    {
                                        if (this.targetUser.OrganizationId != null && this.targetUser.OrganizationId.OrganizationalUnit != null && VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.MultiTenancy.Enabled)
                                        {
                                            IRecipientSession recipientSession = CommonUtils.CreateRecipientSession(mailboxStatistics.ExternalDirectoryOrganizationId, null, null);
                                            ADRecipient       adrecipient      = this.TargetIsArchive ? recipientSession.FindByExchangeGuidIncludingArchive(mailboxStatistics.MailboxGuid) : recipientSession.FindByExchangeGuid(mailboxStatistics.MailboxGuid);
                                            flag = (adrecipient != null && adrecipient.RecipientSoftDeletedStatus != 0);
                                        }
                                        if (!this.IsPublicFolderMailboxRestore && !flag)
                                        {
                                            base.WriteError(new CannotRestoreConnectedMailboxPermanentException(this.SourceStoreMailbox.ToString()), ErrorCategory.InvalidArgument, this.SourceStoreMailbox);
                                        }
                                    }
                                }
                            }
                            if (flag)
                            {
                                this.restoreFlags |= MailboxRestoreType.SoftDeletedRecipient;
                            }
                            else if (disconnectReason != null)
                            {
                                if (disconnectReason != MailboxState.SoftDeleted)
                                {
                                    this.restoreFlags |= MailboxRestoreType.Disabled;
                                }
                                else
                                {
                                    this.restoreFlags |= MailboxRestoreType.SoftDeleted;
                                }
                            }
                            this.sourceMailboxGuid = mailboxStatistics.MailboxGuid;
                            this.sourceMailboxDN   = mailboxStatistics.LegacyDN;
                        }
                    }
                    if ((this.TargetIsArchive && this.sourceMailboxGuid == this.targetUser.ArchiveGuid && this.sourceDatabase.Equals(this.targetUser.ArchiveDatabase)) || (!this.TargetIsArchive && this.sourceMailboxGuid == this.targetUser.ExchangeGuid && this.sourceDatabase.Equals(this.targetUser.Database)))
                    {
                        base.WriteError(new CannotRestoreIntoSelfPermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.TargetMailbox);
                    }
                }
                if (this.restoreFlags.HasFlag(MailboxRestoreType.PublicFolderMailbox))
                {
                    if (this.targetUser.RecipientTypeDetails != RecipientTypeDetails.PublicFolderMailbox)
                    {
                        base.WriteError(new RecipientTaskException(Strings.ErrorCannotRestoreFromPublicToPrivateMailbox), ErrorCategory.InvalidArgument, this.SourceStoreMailbox);
                    }
                }
                else if (this.targetUser.RecipientTypeDetails == RecipientTypeDetails.PublicFolderMailbox)
                {
                    base.WriteError(new RecipientTaskException(Strings.ErrorCannotRestoreFromPrivateToPublicMailbox), ErrorCategory.InvalidArgument, this.SourceStoreMailbox);
                }
                base.RescopeToOrgId(this.targetUser.OrganizationId);
                if (base.ParameterSetName.Equals("RemoteMailboxRestore"))
                {
                    base.PerRecordReportEntries.Add(new ReportEntry(MrsStrings.ReportRequestAllowedMismatch(base.ExecutingUserIdentity)));
                }
                else
                {
                    base.ValidateLegacyDNMatch(this.sourceMailboxDN, this.targetUser, this.TargetMailbox);
                }
                ADObjectId mdbId         = null;
                ADObjectId mdbServerSite = null;
                this.LocateAndChooseMdb(null, this.TargetIsArchive ? this.targetUser.ArchiveDatabase : this.targetUser.Database, null, this.TargetMailbox, this.TargetMailbox, out mdbId, out mdbServerSite);
                base.MdbId         = mdbId;
                base.MdbServerSite = mdbServerSite;
                base.RequestName   = this.CheckRequestNameAvailability(base.RequestName, this.targetUser.Id, true, MRSRequestType.MailboxRestore, this.TargetMailbox, wildcardedSearch);
                base.InternalValidate();
            }
            finally
            {
                TaskLogger.LogExit();
            }
        }
Ejemplo n.º 19
0
 public bool IsMemberOf(IRecipientSession session, Guid adUserObjectGuid, RoutingAddress group)
 {
     return(GroupsConfiguration.groupsResolver.Value.IsMemberOf(session, adUserObjectGuid, group));
 }
Ejemplo n.º 20
0
 // Token: 0x0600096D RID: 2413 RVA: 0x00037346 File Offset: 0x00035546
 internal void SetRecipientSessionForTesting(IRecipientSession recipientSession)
 {
     this.recipientSession = recipientSession;
 }
Ejemplo n.º 21
0
        // Token: 0x060010A1 RID: 4257 RVA: 0x0004423C File Offset: 0x0004243C
        public static void SaveTextMessagingAccount(TextMessagingAccount account, VersionedXmlDataProvider storeDataProvider, ADRecipient adRecipient, IRecipientSession adSession)
        {
            if (account == null)
            {
                throw new ArgumentNullException("account");
            }
            if (storeDataProvider == null)
            {
                throw new ArgumentNullException("storeDataProvider");
            }
            if (adRecipient == null)
            {
                throw new ArgumentNullException("adRecipient");
            }
            if (adSession == null)
            {
                throw new ArgumentNullException("adSession");
            }
            bool notificationPhoneNumberVerified = account.NotificationPhoneNumberVerified;
            bool dupIdentitiesExist = false;

            account.TextMessagingSettings.DeliveryPoints.Sort(delegate(DeliveryPoint x, DeliveryPoint y)
            {
                if (x.Identity == y.Identity)
                {
                    dupIdentitiesExist = true;
                }
                return(x.Identity.CompareTo(y.Identity));
            });
            if (dupIdentitiesExist)
            {
                int num = 0;
                while (account.TextMessagingSettings.DeliveryPoints.Count > num)
                {
                    account.TextMessagingSettings.DeliveryPoints[num].Identity = (byte)num;
                    num++;
                }
            }
            TextMessagingHelper.UpdateTextMessagingState(adRecipient.TextMessagingState, account.TextMessagingSettings.DeliveryPoints);
            storeDataProvider.Save(account);
            adSession.Save(adRecipient);
        }
Ejemplo n.º 22
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     try
     {
         base.InternalValidate();
         if (!base.HasErrors)
         {
             if (MobileDeviceTaskHelper.IsRunningUnderMyOptionsRole(this, base.TenantGlobalCatalogSession, base.SessionSettings))
             {
                 ADObjectId id;
                 if (!base.TryGetExecutingUserId(out id))
                 {
                     throw new ExecutingUserPropertyNotFoundException("executingUserid");
                 }
                 if (!this.DataObject.Id.Parent.Parent.Equals(id))
                 {
                     base.WriteError(new LocalizedException(Strings.ErrorObjectNotFound(this.Identity.ToString())), ErrorCategory.InvalidArgument, null);
                 }
             }
             IRecipientSession  recipientSession = this.CreateTenantGlobalCatalogSession(base.SessionSettings);
             Exception          ex        = null;
             MailboxIdParameter mailboxId = this.Identity.GetMailboxId();
             if (mailboxId == null && this.DataObject != null)
             {
                 this.Identity = new MobileDeviceIdParameter(this.DataObject);
                 mailboxId     = this.Identity.GetMailboxId();
             }
             if (mailboxId == null)
             {
                 base.WriteError(new LocalizedException(Strings.ErrorObjectNotFound(this.Identity.ToString())), ErrorCategory.InvalidArgument, null);
             }
             ADUser adObject = null;
             this.principal = MobileDeviceTaskHelper.GetExchangePrincipal(base.SessionSettings, recipientSession, mailboxId, "Clear-MobileDevice", out ex, out adObject);
             if (ex != null)
             {
                 base.WriteError(ex, ErrorCategory.InvalidArgument, null);
             }
             IList <LocalizedString> list = null;
             ADObjectId adobjectId        = null;
             base.TryGetExecutingUserId(out adobjectId);
             this.validatedAddresses = MobileDeviceTaskHelper.ValidateAddresses(recipientSession, adobjectId, this.NotificationEmailAddresses, out list);
             if (list != null)
             {
                 foreach (LocalizedString text in list)
                 {
                     this.WriteWarning(text);
                 }
             }
             base.VerifyIsWithinScopes((IDirectorySession)base.DataSession, adObject, true, new DataAccessTask <MobileDevice> .ADObjectOutOfScopeString(Strings.ErrorCannotChangeMailboxOutOfWriteScope));
             if (adobjectId != null)
             {
                 ExchangePrincipal exchangePrincipal = MobileDeviceTaskHelper.GetExchangePrincipal(base.SessionSettings, recipientSession, new MailboxIdParameter(adobjectId), "Clear-MobileDevice", out ex);
                 if (ex != null)
                 {
                     base.WriteWarning(ex.ToString());
                 }
                 if (exchangePrincipal != null)
                 {
                     this.wipeRequestorSMTP = exchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString();
                 }
                 else
                 {
                     this.wipeRequestorSMTP = null;
                 }
             }
         }
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
        public void AddAttachment(Attachment attachment, IRecipientSession adRecipientSession)
        {
            bool     flag     = false;
            MimePart mimePart = attachment.MimePart;
            Header   header   = null;

            if (mimePart != null)
            {
                header = mimePart.Headers.FindFirst("X-MS-Exchange-Organization-Approval-AttachToApprovalRequest");
            }
            string text;

            if (header != null && header.TryGetValue(out text))
            {
                if (text.Equals("Never"))
                {
                    return;
                }
                if (text.Equals("AsMessage"))
                {
                    flag = true;
                }
            }
            if (flag)
            {
                using (Stream contentReadStream = attachment.GetContentReadStream())
                {
                    using (ItemAttachment itemAttachment = (ItemAttachment)this.messageItem.AttachmentCollection.Create(AttachmentType.EmbeddedMessage))
                    {
                        using (Item item = itemAttachment.GetItem())
                        {
                            ItemConversion.ConvertAnyMimeToItem(item, contentReadStream, new InboundConversionOptions(Components.Configuration.FirstOrgAcceptedDomainTable.DefaultDomainName)
                            {
                                UserADSession = adRecipientSession
                            });
                            item[MessageItemSchema.Flags] = MessageFlags.None;
                            item.Save(SaveMode.NoConflictResolution);
                            string valueOrDefault = item.GetValueOrDefault <string>(ItemSchema.Subject);
                            if (!string.IsNullOrEmpty(valueOrDefault))
                            {
                                itemAttachment[AttachmentSchema.DisplayName] = valueOrDefault;
                            }
                            itemAttachment.Save();
                        }
                    }
                    return;
                }
            }
            using (StreamAttachment streamAttachment = (StreamAttachment)this.messageItem.AttachmentCollection.Create(AttachmentType.Stream))
            {
                streamAttachment.FileName = attachment.FileName;
                using (Stream contentStream = streamAttachment.GetContentStream())
                {
                    using (Stream contentReadStream2 = attachment.GetContentReadStream())
                    {
                        ApprovalProcessor.CopyStream(contentReadStream2, contentStream, this.Buffer);
                    }
                    contentStream.Flush();
                }
                streamAttachment.Save();
            }
        }
Ejemplo n.º 24
0
        internal static void SetPreferredCulture(IExchangePrincipal exchangePrincipal, IEnumerable <CultureInfo> preferredCultures, IRecipientSession recipientSession)
        {
            ADUser aduser = recipientSession.Read(exchangePrincipal.ObjectId) as ADUser;

            if (aduser != null)
            {
                aduser.Languages.Clear();
                foreach (CultureInfo item in preferredCultures)
                {
                    aduser.Languages.Add(item);
                }
                recipientSession.Save(aduser);
            }
        }
Ejemplo n.º 25
0
        internal static MultiValuedProperty <string> ConvertSourceMailboxesCollection(IEnumerable <RecipientIdParameter> recipientIds, bool inplaceHoldEnabled, Func <RecipientIdParameter, ADRecipient> recipientGetter, IRecipientSession recipientSession, Task.TaskErrorLoggingDelegate writeErrorDelegate, Action <LocalizedString> writeWarningDelegate, Func <LocalizedString, bool> shouldContinueDelegate)
        {
            MultiValuedProperty <string> results = null;

            if (recipientIds != null)
            {
                RecipientType[] source = new RecipientType[]
                {
                    RecipientType.UserMailbox,
                    RecipientType.Group,
                    RecipientType.MailUniversalDistributionGroup,
                    RecipientType.MailUniversalSecurityGroup,
                    RecipientType.MailNonUniversalGroup,
                    RecipientType.DynamicDistributionGroup
                };
                bool flag = false;
                foreach (RecipientIdParameter arg in recipientIds)
                {
                    if (results == null)
                    {
                        results = new MultiValuedProperty <string>();
                    }
                    ADRecipient       adrecipient     = recipientGetter(arg);
                    string            text            = null;
                    ADSessionSettings sessionSettings = adrecipient.OrganizationId.ToADSessionSettings();
                    if (Utils.IsPublicFolderMailbox(adrecipient))
                    {
                        writeErrorDelegate(new MailboxSearchTaskException(Strings.ErrorInvalidRecipientTypeDetails(adrecipient.ToString())), ErrorCategory.InvalidArgument, null);
                    }
                    else if (Utils.IsValidMailboxType(adrecipient))
                    {
                        if (adrecipient.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2012) && !RemoteMailbox.IsRemoteMailbox(adrecipient.RecipientTypeDetails) && ExchangePrincipal.FromADUser(sessionSettings, (ADUser)adrecipient, RemotingOptions.AllowCrossSite).MailboxInfo.Location.ServerVersion < Server.E15MinVersion)
                        {
                            writeErrorDelegate(new MailboxSearchTaskException(Strings.SourceMailboxMustBeE15OrLater(adrecipient.DisplayName)), ErrorCategory.InvalidArgument, null);
                        }
                        text = adrecipient.LegacyExchangeDN;
                    }
                    else if (source.Contains(adrecipient.RecipientType))
                    {
                        if (inplaceHoldEnabled)
                        {
                            if (!flag)
                            {
                                if (shouldContinueDelegate(Strings.ShouldContinueToExpandGroupsForHold))
                                {
                                    flag = true;
                                }
                                else
                                {
                                    writeErrorDelegate(new MailboxSearchTaskException(Strings.GroupsIsNotAllowedForHold(adrecipient.DisplayName)), ErrorCategory.InvalidArgument, null);
                                }
                            }
                            bool invalidTypeSkipped                   = false;
                            bool oldVersionMailboxSkipped             = false;
                            ADRecipientExpansion adrecipientExpansion = new ADRecipientExpansion(new PropertyDefinition[]
                            {
                                ADRecipientSchema.LegacyExchangeDN,
                                ADRecipientSchema.RecipientTypeDetailsValue,
                                ADObjectSchema.ExchangeVersion
                            }, adrecipient.OrganizationId);
                            adrecipientExpansion.Expand(adrecipient, delegate(ADRawEntry expandedRecipient, ExpansionType expansionType, ADRawEntry parent, ExpansionType parentType)
                            {
                                if (expansionType == ExpansionType.GroupMembership)
                                {
                                    return(ExpansionControl.Continue);
                                }
                                if (Utils.IsValidMailboxType(expandedRecipient))
                                {
                                    ExchangeObjectVersion exchangeObjectVersion = (ExchangeObjectVersion)expandedRecipient[ADObjectSchema.ExchangeVersion];
                                    string text2 = (string)expandedRecipient[ADRecipientSchema.LegacyExchangeDN];
                                    if (!oldVersionMailboxSkipped && exchangeObjectVersion.IsOlderThan(ExchangeObjectVersion.Exchange2012) && !RemoteMailbox.IsRemoteMailbox((RecipientTypeDetails)expandedRecipient[ADRecipientSchema.RecipientTypeDetails]) && ExchangePrincipal.FromLegacyDN(sessionSettings, text2).MailboxInfo.Location.ServerVersion < Server.E15MinVersion)
                                    {
                                        oldVersionMailboxSkipped = true;
                                        writeWarningDelegate(Strings.OldVersionMailboxSkipped);
                                    }
                                    if (!results.Contains(text2))
                                    {
                                        results.Add(text2);
                                    }
                                }
                                else if (!invalidTypeSkipped)
                                {
                                    invalidTypeSkipped = true;
                                    writeWarningDelegate(Strings.SkippingInvalidTypeInGroupExpansion);
                                }
                                return(ExpansionControl.Skip);
                            }, delegate(ExpansionFailure failure, ADRawEntry expandedRecipient, ExpansionType expansionType, ADRawEntry parent, ExpansionType parentType)
                            {
                                TaskLogger.Trace("Skipping invalid AD entry {0} because of failure: {1}", new object[]
                                {
                                    expandedRecipient,
                                    failure
                                });
                                return(ExpansionControl.Skip);
                            });
                        }
                        else
                        {
                            text = adrecipient.LegacyExchangeDN;
                        }
                    }
                    else
                    {
                        writeErrorDelegate(new MailboxSearchTaskException(Strings.ErrorInvalidRecipientType(adrecipient.ToString(), adrecipient.RecipientType.ToString())), ErrorCategory.InvalidArgument, null);
                    }
                    if (text != null && !results.Contains(text))
                    {
                        results.Add(text);
                    }
                    if (results.Count > Utils.MaxNumberOfMailboxesInSingleHold)
                    {
                        writeErrorDelegate(new MailboxSearchTaskException(Strings.ErrorTooManyMailboxesInSingleHold(Utils.MaxNumberOfMailboxesInSingleHold)), ErrorCategory.InvalidArgument, null);
                    }
                }
                if (results != null)
                {
                    uint discoveryMaxMailboxes = SearchUtils.GetDiscoveryMaxMailboxes(recipientSession);
                    if ((long)results.Count > (long)((ulong)discoveryMaxMailboxes) && !shouldContinueDelegate(Strings.ShouldContinueMoreMailboxesThanMaxSearch(results.Count, discoveryMaxMailboxes)))
                    {
                        writeErrorDelegate(new MailboxSearchTaskException(Strings.ErrorTaskCancelledBecauseMoreMailboxesThanSearchSupported), ErrorCategory.InvalidArgument, null);
                    }
                }
            }
            return(results);
        }
Ejemplo n.º 26
0
        public GroupConfiguration GetGroupInformation(string group)
        {
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(this.organizationId), 58, "GetGroupInformation", "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\OrganizationConfiguration\\GroupsConfiguration.cs");

            return(this.GetGroupInformation(tenantOrRootOrgRecipientSession, group));
        }
 // Token: 0x060019D6 RID: 6614 RVA: 0x0006CEEC File Offset: 0x0006B0EC
 internal ADMicrosoftExchangeRecipient(IRecipientSession session, PropertyBag propertyBag) : base(session, propertyBag)
 {
 }
Ejemplo n.º 28
0
 public GroupConfiguration GetGroupInformation(IRecipientSession session, string group)
 {
     return(GroupsConfiguration.groupsResolver.Value.GetGroupInfo(session, (RoutingAddress)group));
 }
Ejemplo n.º 29
0
        internal static void FillDisplayNames(List <MessageTrackingSearchResult> results, IRecipientSession recipSession)
        {
            BulkRecipientLookupCache bulkRecipientLookupCache = new BulkRecipientLookupCache(100);

            foreach (MessageTrackingSearchResult messageTrackingSearchResult in results)
            {
                IEnumerable <string> addresses = from address in messageTrackingSearchResult.RecipientAddresses
                                                 select address.ToString();

                messageTrackingSearchResult.RecipientDisplayNames = bulkRecipientLookupCache.Resolve(addresses, recipSession).ToArray <string>();
            }
        }
        public AggregationSubscriptionDataProvider CreateSubscriptionDataProvider(AggregationType aggregationType, AggregationTaskType taskType, IRecipientSession session, ADUser adUser)
        {
            if (aggregationType <= AggregationType.Migration)
            {
                if (aggregationType != AggregationType.Aggregation && aggregationType != AggregationType.Migration)
                {
                    goto IL_33;
                }
            }
            else
            {
                if (aggregationType == AggregationType.PeopleConnection)
                {
                    return(new ConnectSubscriptionDataProvider(taskType, session, adUser));
                }
                if (aggregationType != AggregationType.All)
                {
                    goto IL_33;
                }
            }
            return(new AggregationSubscriptionDataProvider(taskType, session, adUser));

IL_33:
            throw new InvalidOperationException("Invalid Aggregation Type:" + aggregationType);
        }