private Uri GetOwaServiceUrl(IExchangePrincipal exchangePrincipal, IFrontEndLocator frontEndLocator)
 {
     if (exchangePrincipal.MailboxInfo.Location.ServerVersion >= Server.E15MinVersion && this.IsMultitenancyEnabled)
     {
         return(this.GetE15MultitenancyOwaServiceUrl(exchangePrincipal, frontEndLocator));
     }
     return(this.GetEnterpriseOrE14OwaServiceUrl(exchangePrincipal));
 }
Esempio n. 2
0
        private string GetSharingUrl(ADUser user, IFrontEndLocator frontEndLocator)
        {
            ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromADUser(user, null);

            if (exchangePrincipal.MailboxInfo.Location.ServerVersion >= Server.E15MinVersion && this.IsMultitenancyEnabled)
            {
                return(this.GetE15MultitenancySharingUrl(exchangePrincipal, frontEndLocator));
            }
            return(this.GetEnterpriseOrE14SharingUrl(exchangePrincipal));
        }
        public Uri GetOwaVdirUrl(IExchangePrincipal exchangePrincipal, IFrontEndLocator frontEndLocator)
        {
            Uri        owaServiceUrl = this.GetOwaServiceUrl(exchangePrincipal, frontEndLocator);
            UriBuilder uriBuilder    = new UriBuilder(owaServiceUrl);

            uriBuilder.Port   = -1;
            uriBuilder.Scheme = Uri.UriSchemeHttp;
            if (this.anonymousCalendarHostUrl != null)
            {
                uriBuilder.Host = this.anonymousCalendarHostUrl.Host;
            }
            return(uriBuilder.Uri);
        }
        public bool IsPublishingAvailable(IExchangePrincipal exchangePrincipal, IFrontEndLocator frontEndLocator)
        {
            bool result;

            try
            {
                this.GetOwaVdirUrl(exchangePrincipal, frontEndLocator);
                result = true;
            }
            catch (NoExternalOwaAvailableException)
            {
                result = false;
            }
            return(result);
        }
Esempio n. 5
0
        public EncryptionResults Encrypt(IExchangePrincipal mailboxOwner, IRecipientSession recipientSession, ExternalUserCollection externalUserCollection, ValidRecipient[] recipients, string sender, string containerClass, string folderId, IFrontEndLocator frontEndLocator)
        {
            SharingDataType sharingDataType = SharingDataType.FromContainerClass(containerClass);

            if (sharingDataType == null || !sharingDataType.IsExternallySharable)
            {
                throw new ArgumentOutOfRangeException("containerClass");
            }
            ADUser aduser = DirectoryHelper.ReadADRecipient(mailboxOwner.MailboxInfo.MailboxGuid, mailboxOwner.MailboxInfo.IsArchive, recipientSession) as ADUser;

            if (aduser == null)
            {
                SharedFolderDataEncryption.Tracer.TraceError <SharedFolderDataEncryption, string>((long)this.GetHashCode(), "{0}: The Active Directory user was not found. Sender={1}.", this, sender);
                throw new ObjectNotFoundException(ServerStrings.ADUserNotFound);
            }
            ProxyAddress item = new SmtpProxyAddress(sender, false);

            if (!aduser.EmailAddresses.Contains(item))
            {
                SharedFolderDataEncryption.Tracer.TraceError <SharedFolderDataEncryption, string>((long)this.GetHashCode(), "{0}: The SMTP address was not found in the user AD object for this mailbox. Sender={1}.", this, sender);
                throw new ObjectNotFoundException(ServerStrings.ADUserNotFound);
            }
            SharingPolicy sharingPolicy = DirectoryHelper.ReadSharingPolicy(mailboxOwner.MailboxInfo.MailboxGuid, mailboxOwner.MailboxInfo.IsArchive, recipientSession);

            SharedFolderDataEncryption.Tracer.TraceDebug <SharedFolderDataEncryption, object>((long)this.GetHashCode(), "{0}: Sharing policy to be applied to this user: {1}", this, (sharingPolicy == null) ? "<null>" : sharingPolicy.Id);
            SharingPolicyAction sharingPolicyActions = SharedFolderDataEncryption.GetSharingPolicyActions(sharingDataType.StoreObjectType);

            SharedFolderDataRecipient[] externalIdentities = SharedFolderDataEncryption.GetExternalIdentities(externalUserCollection, recipients);
            List <InvalidRecipient>     list = new List <InvalidRecipient>();
            Dictionary <TokenTarget, List <SharedFolderDataRecipient> > dictionary = new Dictionary <TokenTarget, List <SharedFolderDataRecipient> >(externalIdentities.Length, SharedFolderDataEncryption.TokenTargetComparer);

            for (int i = 0; i < recipients.Length; i++)
            {
                SharedFolderDataRecipient item2          = externalIdentities[i];
                ValidRecipient            validRecipient = recipients[i];
                SmtpAddress smtpAddress = new SmtpAddress(validRecipient.SmtpAddress);
                string      domain      = smtpAddress.Domain;
                if (sharingPolicy == null || !sharingPolicy.IsAllowedForAnySharing(domain, sharingPolicyActions))
                {
                    SharedFolderDataEncryption.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Sharing policy does not allow user to share with domain {0}", domain);
                    list.Add(new InvalidRecipient(validRecipient.SmtpAddress, InvalidRecipientResponseCodeType.SystemPolicyBlocksSharingWithThisRecipient));
                }
                else
                {
                    SmtpAddress smtpAddress2 = new SmtpAddress(validRecipient.SmtpAddressForEncryption);
                    TokenTarget tokenTarget  = TargetUriResolver.Resolve(smtpAddress2.Domain, aduser.OrganizationId);
                    if (tokenTarget == null)
                    {
                        list.Add(new InvalidRecipient(validRecipient.SmtpAddress, InvalidRecipientResponseCodeType.RecipientOrganizationNotFederated));
                    }
                    else
                    {
                        List <SharedFolderDataRecipient> list2;
                        if (!dictionary.TryGetValue(tokenTarget, out list2))
                        {
                            list2 = new List <SharedFolderDataRecipient>(1);
                            dictionary.Add(tokenTarget, list2);
                        }
                        list2.Add(item2);
                    }
                }
            }
            List <EncryptedSharedFolderData> list3 = new List <EncryptedSharedFolderData>(dictionary.Count);
            SharedFolderData sharedFolderData      = new SharedFolderData();

            sharedFolderData.DataType          = sharingDataType.ExternalName;
            sharedFolderData.FolderId          = folderId;
            sharedFolderData.SharingUrl        = this.GetSharingUrl(aduser, frontEndLocator);
            sharedFolderData.FederationUri     = this.externalAuthentication.TokenValidator.TargetUri.ToString();
            sharedFolderData.SenderSmtpAddress = sender;
            DelegationTokenRequest delegationTokenRequest = new DelegationTokenRequest
            {
                FederatedIdentity = aduser.GetFederatedIdentity(),
                EmailAddress      = aduser.GetFederatedSmtpAddress(new SmtpAddress(sender)).ToString(),
                Offer             = Offer.SharingInviteMessage
            };
            SecurityTokenService securityTokenService = this.externalAuthentication.GetSecurityTokenService(aduser.OrganizationId);

            foreach (KeyValuePair <TokenTarget, List <SharedFolderDataRecipient> > keyValuePair in dictionary)
            {
                delegationTokenRequest.Target = keyValuePair.Key;
                sharedFolderData.Recipients   = keyValuePair.Value.ToArray();
                try
                {
                    RequestedToken requestedToken = securityTokenService.IssueToken(delegationTokenRequest);
                    list3.Add(this.Encrypt(requestedToken, sharedFolderData));
                }
                catch (WSTrustException ex)
                {
                    foreach (SharedFolderDataRecipient sharedFolderDataRecipient in sharedFolderData.Recipients)
                    {
                        list.Add(new InvalidRecipient(sharedFolderDataRecipient.SmtpAddress, SharedFolderDataEncryption.GetResponseCodeFromException(ex), ex.ToString()));
                    }
                }
            }
            return(new EncryptionResults(list3.ToArray(), list.ToArray()));
        }
        private Uri GetE15MultitenancyOwaServiceUrl(IExchangePrincipal exchangePrincipal, IFrontEndLocator frontEndLocator)
        {
            Uri       result = null;
            Exception ex     = null;

            try
            {
                result = frontEndLocator.GetOwaUrl(exchangePrincipal);
            }
            catch (ServerNotFoundException ex2)
            {
                ex = ex2;
            }
            catch (ADTransientException ex3)
            {
                ex = ex3;
            }
            catch (DataSourceOperationException ex4)
            {
                ex = ex4;
            }
            catch (DataValidationException ex5)
            {
                ex = ex5;
            }
            finally
            {
                if (ex != null)
                {
                    throw new NoExternalOwaAvailableException(ex);
                }
            }
            return(result);
        }
Esempio n. 7
0
 public InvitationNotification(MailboxSession session, VariantConfigurationSnapshot snapshot, IFrontEndLocator frontEndLocator) : base(session, snapshot, frontEndLocator)
 {
 }
Esempio n. 8
0
 protected abstract PerformInvitationResults InternalPerformInvitation(MailboxSession mailboxSession, SharingContext context, ValidRecipient[] recipients, IFrontEndLocator frontEndLocator);
Esempio n. 9
0
 internal PerformInvitationResults PerformInvitation(MailboxSession mailboxSession, SharingContext context, ValidRecipient[] recipients, IFrontEndLocator frontEndLocator)
 {
     return(this.sharingProviderHandler.PerformInvitation(mailboxSession, context, recipients, frontEndLocator));
 }
Esempio n. 10
0
        public static StoreObjectId OptUserIn(MailboxSession session, VariantConfigurationSnapshot snapshot, IFrontEndLocator frontEndLocator)
        {
            snapshot = ClutterUtilities.LoadSnapshotIfNeeded(session, snapshot);
            StoreObjectId storeObjectId = null;

            if (!session.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceClutterEnabled, false) || !session.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceClassificationEnabled, false))
            {
                using (MailboxSession mailboxSession = ClutterUtilities.OpenAdminSession(session))
                {
                    StoreObjectId storeObjectId2 = ClutterUtilities.SetClassificationEnabled(mailboxSession, true);
                    ClutterUtilities.AddClutterToFavorite(session);
                    ClutterUtilities.VerifyReadyVersionInCrumb(mailboxSession);
                    storeObjectId = session.RefreshDefaultFolder(DefaultFolderType.Clutter);
                    ClutterUtilities.RefreshInferenceProperties(session, true);
                    using (NotificationManager notificationManager = new NotificationManager(session, snapshot, frontEndLocator))
                    {
                        notificationManager.SendNotification(ClutterNotificationType.OptedIn, DefaultFolderType.Inbox);
                        notificationManager.ScheduleNotification(ClutterNotificationType.FirstReminder, 5, DayOfWeek.Monday);
                        notificationManager.CancelScheduledNotification(ClutterNotificationType.AutoEnablementNotice);
                        notificationManager.Save();
                    }
                    ExAssert.RetailAssert(mailboxSession.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceClutterEnabled, false), "InferenceClutterEnabled should have been set to true in admin session");
                    ExAssert.RetailAssert(mailboxSession.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceClassificationEnabled, false), "InferenceClassificationEnabled should have been set to true in admin session");
                    ExAssert.RetailAssert(storeObjectId2 != null, "Clutter folder id created in admin session should not be null");
                    ExAssert.RetailAssert(storeObjectId2.Equals(storeObjectId), "Clutter folder id created in admin session should equal the id created by refreshing the user session");
                    goto IL_FD;
                }
            }
            storeObjectId = ClutterUtilities.ValidateClutterFolder(session);
IL_FD:
            ExAssert.RetailAssert(session.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceClutterEnabled, false), "InferenceClutterEnabled should have been set to true in user session");
            ExAssert.RetailAssert(session.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceClassificationEnabled, false), "InferenceClassificationEnabled should have been set to true in user session");
            ExAssert.RetailAssert(storeObjectId != null, "Clutter folder could not be created");
            return(storeObjectId);
        }
        public SharingProvider GetProvider(SmtpAddress recipientAddress, ADRecipient adRecipient, IFrontEndLocator frontEndLocator)
        {
            SharingProvider     result;
            DetailLevelEnumType detailLevelEnumType;

            if (this.TryGetProvider(recipientAddress, adRecipient, frontEndLocator, out result, out detailLevelEnumType))
            {
                return(result);
            }
            throw new NoSharingHandlerFoundException(recipientAddress.ToString());
        }
 public NotificationManager(MailboxSession session, VariantConfigurationSnapshot snapshot, IFrontEndLocator frontEndLocator) : this(session, snapshot, frontEndLocator, null)
 {
 }
        protected override PerformInvitationResults InternalPerformInvitation(MailboxSession mailboxSession, SharingContext context, ValidRecipient[] recipients, IFrontEndLocator frontEndLocator)
        {
            PermissionLevel permissionLevel = this.GetPermissionLevel(context);
            FreeBusyAccess? freeBusy        = this.GetFreeBusy(context);

            using (FolderPermissionContext current = FolderPermissionContext.GetCurrent(mailboxSession, context))
            {
                foreach (ValidRecipient recipient in recipients)
                {
                    PermissionSecurityPrincipal principal = this.CreatePermissionSecurityPrincipal(recipient, mailboxSession.MailboxOwner);
                    current.AddOrChangePermission(principal, permissionLevel, freeBusy);
                }
            }
            return(new PerformInvitationResults(recipients));
        }
Esempio n. 14
0
        protected override PerformInvitationResults InternalPerformInvitation(MailboxSession mailboxSession, SharingContext context, ValidRecipient[] recipients, IFrontEndLocator frontEndLocator)
        {
            ExternalAuthentication current = ExternalAuthentication.GetCurrent();

            if (!current.Enabled)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: The organization is not federated for external sharing.", context.InitiatorSmtpAddress);
                return(new PerformInvitationResults(new InvalidSharingRecipientsException(ValidRecipient.ConvertToStringArray(recipients), new OrganizationNotFederatedException())));
            }
            SharedFolderDataEncryption sharedFolderDataEncryption = new SharedFolderDataEncryption(current);
            string text = StoreId.StoreIdToEwsId(mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid, context.FolderId);
            PerformInvitationResults result;

            using (ExternalUserCollection externalUsers = mailboxSession.GetExternalUsers())
            {
                PerformInvitationResults performInvitationResults = null;
                EncryptionResults        encryptionResults        = null;
                Exception ex = null;
                try
                {
                    encryptionResults = sharedFolderDataEncryption.Encrypt(mailboxSession.MailboxOwner, mailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid), externalUsers, recipients, context.InitiatorSmtpAddress, context.FolderClass, text, frontEndLocator);
                }
                catch (UserWithoutFederatedProxyAddressException ex2)
                {
                    ex = ex2;
                }
                catch (InvalidFederatedOrganizationIdException ex3)
                {
                    ex = ex3;
                }
                catch (StoragePermanentException ex4)
                {
                    ex = ex4;
                }
                if (ex != null)
                {
                    ExTraceGlobals.SharingTracer.TraceError <string, Exception>((long)this.GetHashCode(), "{0}: Error occurred when trying to encrypt. Exception = {1}", context.InitiatorSmtpAddress, ex);
                    result = new PerformInvitationResults(new InvalidSharingRecipientsException(ValidRecipient.ConvertToStringArray(recipients), ex));
                }
                else
                {
                    if (encryptionResults.InvalidRecipients != null && encryptionResults.InvalidRecipients.Length > 0)
                    {
                        InvalidSharingRecipientsException exception = new InvalidSharingRecipientsException(encryptionResults.InvalidRecipients);
                        if (encryptionResults.InvalidRecipients.Length == recipients.Length)
                        {
                            return(new PerformInvitationResults(exception));
                        }
                        performInvitationResults = new PerformInvitationResults(recipients, exception);
                        recipients = performInvitationResults.SucceededRecipients;
                    }
                    else
                    {
                        performInvitationResults = new PerformInvitationResults(recipients);
                    }
                    PermissionLevel permissionLevel = this.GetPermissionLevel(context);
                    FreeBusyAccess? freeBusy        = this.GetFreeBusy(context);
                    using (FolderPermissionContext current2 = FolderPermissionContext.GetCurrent(mailboxSession, context))
                    {
                        foreach (ValidRecipient validRecipient in recipients)
                        {
                            PermissionSecurityPrincipal principal = this.CreatePermissionSecurityPrincipal(validRecipient.SmtpAddress, externalUsers);
                            current2.AddOrChangePermission(principal, permissionLevel, freeBusy);
                            ExternalUser externalUser = externalUsers.FindReachUserWithOriginalSmtpAddress(new SmtpAddress(validRecipient.SmtpAddress));
                            if (externalUser != null)
                            {
                                current2.RemovePermission(new PermissionSecurityPrincipal(externalUser));
                            }
                        }
                    }
                    context.FolderEwsId = text;
                    context.EncryptedSharedFolderDataCollection = encryptionResults.EncryptedSharedFolderDataCollection;
                    result = performInvitationResults;
                }
            }
            return(result);
        }
Esempio n. 15
0
        protected override PerformInvitationResults InternalPerformInvitation(MailboxSession mailboxSession, SharingContext context, ValidRecipient[] recipients, IFrontEndLocator frontEndLocator)
        {
            if (recipients.Length != 1)
            {
                throw new InvalidOperationException("Only single recipient is allowed.");
            }
            ValidRecipient    validRecipient     = recipients[0];
            string            folderId           = context.FolderId.ToBase64String();
            ExternalUser      externalUser       = this.ApplyPermission(mailboxSession, new SmtpAddress(validRecipient.SmtpAddress), context);
            IRecipientSession adrecipientSession = mailboxSession.GetADRecipientSession(false, ConsistencyMode.FullyConsistent);
            ADUser            aduser             = (ADUser)adrecipientSession.Read(mailboxSession.MailboxOwner.ObjectId);
            string            text         = aduser.SharingAnonymousIdentities.FindExistingUrlId(SharingDataType.ReachCalendar.PublishResourceName, folderId);
            Uri         owaVdirUrl         = OwaAnonymousVdirLocater.Instance.GetOwaVdirUrl(mailboxSession.MailboxOwner, frontEndLocator);
            SmtpAddress primarySmtpAddress = mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress;
            ObscureUrl  obscureUrl         = ObscureUrl.CreatePublishReachCalendarUrl(owaVdirUrl.ToString(), mailboxSession.MailboxGuid, primarySmtpAddress.Domain, text, externalUser.Sid);

            if (string.IsNullOrEmpty(text))
            {
                aduser.SharingAnonymousIdentities.AddOrUpdate(SharingDataType.ReachCalendar.PublishResourceName, obscureUrl.Identity, folderId);
                adrecipientSession.Save(aduser);
            }
            context.BrowseUrl = obscureUrl.ToString() + ".html";
            context.ICalUrl   = obscureUrl.ToString() + ".ics";
            return(new PerformInvitationResults(recipients));
        }
Esempio n. 16
0
 protected override PerformInvitationResults InternalPerformInvitation(MailboxSession mailboxSession, SharingContext context, ValidRecipient[] recipients, IFrontEndLocator frontEndLocator)
 {
     using (CalendarFolder calendarFolder = CalendarFolder.Bind(mailboxSession, context.FolderId, CalendarFolderSchema.ConsumerCalendarProperties))
     {
         Guid a = calendarFolder.ConsumerCalendarGuid;
         Guid consumerCalendarPrivateFreeBusyId = calendarFolder.ConsumerCalendarPrivateFreeBusyId;
         Guid consumerCalendarPrivateDetailId   = calendarFolder.ConsumerCalendarPrivateDetailId;
         if (a == Guid.Empty)
         {
             a = (calendarFolder.ConsumerCalendarGuid = Guid.NewGuid());
         }
         if (consumerCalendarPrivateFreeBusyId == Guid.Empty)
         {
             Guid guid = calendarFolder.ConsumerCalendarPrivateFreeBusyId = Guid.NewGuid();
         }
         if (consumerCalendarPrivateDetailId == Guid.Empty)
         {
             Guid guid2 = calendarFolder.ConsumerCalendarPrivateDetailId = Guid.NewGuid();
         }
         if (calendarFolder.IsDirty)
         {
             FolderSaveResult folderSaveResult = calendarFolder.Save();
             if (folderSaveResult.OperationResult != OperationResult.Succeeded)
             {
                 throw folderSaveResult.ToException(new LocalizedString("TODO: LOC: Failed to share the calendar."));
             }
         }
         context.FolderEwsId = a.ToString();
         context.MailboxId   = ((IUserPrincipal)mailboxSession.MailboxOwner).NetId.ToByteArray();
         context.FolderName  = (context.IsPrimary ? string.Format("TODO: LOC: {0}'s Calendar", context.InitiatorName) : calendarFolder.DisplayName);
         context.IsPrimary   = false;
     }
     return(new PerformInvitationResults(recipients));
 }
        private SharingPolicyDomain GetEffectiveCalendarSharingPolicy(string recipientDomain, IFrontEndLocator frontEndLocator)
        {
            SharingPolicyDomain sharingPolicyDomain  = null;
            SharingPolicyDomain sharingPolicyDomain2 = null;
            bool enabled = ExternalAuthentication.GetCurrent().Enabled;
            bool flag    = false;

            this.TraceDebug("External authentication enabled:{0}", new object[]
            {
                enabled
            });
            foreach (SharingPolicyDomain sharingPolicyDomain3 in this.SharingPolicy.Domains)
            {
                if (enabled)
                {
                    if (StringComparer.OrdinalIgnoreCase.Equals(sharingPolicyDomain3.Domain, recipientDomain))
                    {
                        this.TraceDebug("Found exact policy for domain {0}", new object[]
                        {
                            sharingPolicyDomain3.Domain
                        });
                        sharingPolicyDomain = sharingPolicyDomain3;
                    }
                    else if (sharingPolicyDomain == null && StringComparer.OrdinalIgnoreCase.Equals(sharingPolicyDomain3.Domain, "*"))
                    {
                        this.TraceDebug("Found asterisk policy", new object[0]);
                        sharingPolicyDomain = sharingPolicyDomain3;
                        flag = true;
                    }
                }
                if (StringComparer.OrdinalIgnoreCase.Equals(sharingPolicyDomain3.Domain, "Anonymous"))
                {
                    if (OwaAnonymousVdirLocater.Instance.IsPublishingAvailable(this.mailboxOwner, frontEndLocator))
                    {
                        this.TraceDebug("Found anonymous policy", new object[0]);
                        sharingPolicyDomain2 = sharingPolicyDomain3;
                    }
                    else
                    {
                        this.TraceDebug("Found anonymous policy but publishing is not allowed", new object[0]);
                    }
                }
            }
            if (flag && sharingPolicyDomain2 != null && PolicyAllowedDetailLevel.GetMaxAllowed(sharingPolicyDomain.Actions) <= PolicyAllowedDetailLevel.GetMaxAllowed(sharingPolicyDomain2.Actions))
            {
                this.TraceDebug("Override AsteriskPolicy with anonymous policy", new object[0]);
                sharingPolicyDomain = null;
            }
            if (sharingPolicyDomain != null)
            {
                if (TargetUriResolver.Resolve(recipientDomain, this.mailboxOwner.MailboxInfo.OrganizationId) != null)
                {
                    return(sharingPolicyDomain);
                }
                this.TraceDebug("Target domain '{0}' is not federated", new object[]
                {
                    recipientDomain
                });
            }
            return(sharingPolicyDomain2);
        }
 public NotificationManager(MailboxSession session, VariantConfigurationSnapshot snapshot, IFrontEndLocator frontEndLocator, UserConfiguration inferenceSettings)
 {
     this.session         = session;
     this.snapshot        = snapshot;
     this.frontEndLocator = frontEndLocator;
     if (inferenceSettings == null || inferenceSettings.GetDictionary() == null)
     {
         this.inferenceSettings     = ClutterUtilities.GetInferenceSettingsConfiguration(session);
         this.ownsInferenceSettings = true;
     }
     else
     {
         this.inferenceSettings     = inferenceSettings;
         this.ownsInferenceSettings = false;
     }
     this.localTimeZone = DateTimeHelper.GetUserTimeZoneOrUtc(this.session);
     this.MigrateNotificationType("ClutterReady", ClutterNotificationType.Invitation);
 }
        public bool TryGetProvider(SmtpAddress recipientAddress, ADRecipient adRecipient, IFrontEndLocator frontEndLocator, out SharingProvider provider, out DetailLevelEnumType detailLevel)
        {
            provider    = null;
            detailLevel = DetailLevelEnumType.AvailabilityOnly;
            bool result;

            try
            {
                if (this.mailboxOwner.GetConfiguration().DataStorage.XOWAConsumerSharing.Enabled)
                {
                    provider    = SharingProvider.SharingProviderConsumer;
                    detailLevel = DetailLevelEnumType.Editor;
                    result      = true;
                }
                else
                {
                    if (adRecipient != null)
                    {
                        if (adRecipient.IsValidSecurityPrincipal)
                        {
                            provider    = SharingProvider.SharingProviderInternal;
                            detailLevel = DetailLevelEnumType.Editor;
                            return(true);
                        }
                        if (DelegateUserCollection.IsCrossPremiseDelegateEnabled(this.mailboxOwner) && (adRecipient.RecipientType == RecipientType.User || adRecipient.RecipientType == RecipientType.UserMailbox || adRecipient.RecipientType == RecipientType.MailUser))
                        {
                            provider    = SharingProvider.SharingProviderInternal;
                            detailLevel = DetailLevelEnumType.Editor;
                            return(true);
                        }
                        if (adRecipient.RecipientType != RecipientType.User && adRecipient.RecipientType != RecipientType.UserMailbox && adRecipient.RecipientType != RecipientType.MailUser && adRecipient.RecipientType != RecipientType.Contact && adRecipient.RecipientType != RecipientType.MailContact)
                        {
                            return(false);
                        }
                    }
                    SharingPolicyDomain effectiveCalendarSharingPolicy = this.GetEffectiveCalendarSharingPolicy(recipientAddress.Domain, frontEndLocator);
                    this.TraceDebug("Policy found:{0}", new object[]
                    {
                        (effectiveCalendarSharingPolicy == null) ? "none" : effectiveCalendarSharingPolicy.Domain
                    });
                    int maxAllowed;
                    if (effectiveCalendarSharingPolicy != null && (maxAllowed = PolicyAllowedDetailLevel.GetMaxAllowed(effectiveCalendarSharingPolicy.Actions)) > 0)
                    {
                        detailLevel = (DetailLevelEnumType)maxAllowed;
                        if (effectiveCalendarSharingPolicy.Domain == "Anonymous")
                        {
                            provider = SharingProvider.SharingProviderPublishReach;
                        }
                        else
                        {
                            provider = SharingProvider.SharingProviderExternal;
                        }
                    }
                    result = (provider != null);
                }
            }
            finally
            {
                this.TraceDebug("MailboxOwner:{0},Recipient:{1},RecipientType:{2},Handler={2},DetailLevel={3}", new object[]
                {
                    this.mailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(),
                    recipientAddress,
                    (adRecipient == null) ? "none" : adRecipient.RecipientType.ToString(),
                    (provider == null) ? "none" : provider.Name,
                    detailLevel
                });
            }
            return(result);
        }
 public static void SendNotification(ClutterNotificationType notificationType, DefaultFolderType folder, MailboxSession session, VariantConfigurationSnapshot snapshot, IFrontEndLocator frontEndLocator)
 {
     NotificationManager.SendNotification(notificationType, folder, session, snapshot, frontEndLocator, null);
 }
Esempio n. 21
0
 public static void OptUserOut(MailboxSession session, VariantConfigurationSnapshot snapshot, IFrontEndLocator frontEndLocator)
 {
     snapshot = ClutterUtilities.LoadSnapshotIfNeeded(session, snapshot);
     if (session.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceClassificationEnabled, false))
     {
         using (MailboxSession mailboxSession = ClutterUtilities.OpenAdminSession(session))
         {
             ClutterUtilities.SetClassificationEnabled(mailboxSession, false);
             ClutterUtilities.RefreshInferenceProperties(session, true);
             using (NotificationManager notificationManager = new NotificationManager(session, snapshot, frontEndLocator))
             {
                 notificationManager.CancelScheduledNotifications();
                 notificationManager.Save();
             }
         }
     }
     ExAssert.RetailAssert(!session.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceClassificationEnabled, false), "InferenceClassificationEnabled should have been set to false in user session");
 }
 public static void SendNotification(ClutterNotificationType notificationType, DefaultFolderType folder, MailboxSession session, VariantConfigurationSnapshot snapshot, IFrontEndLocator frontEndLocator, UserConfiguration inferenceSettings)
 {
     using (NotificationManager notificationManager = new NotificationManager(session, snapshot, frontEndLocator, inferenceSettings))
     {
         notificationManager.SendNotification(notificationType, folder);
         notificationManager.Save();
     }
 }
 public AutoEnablementNotice(MailboxSession session, VariantConfigurationSnapshot snapshot, IFrontEndLocator frontEndLocator) : base(session, snapshot, frontEndLocator)
 {
 }
Esempio n. 24
0
        private string GetE15MultitenancySharingUrl(ExchangePrincipal exchangePrincipal, IFrontEndLocator frontEndLocator)
        {
            SharedFolderDataEncryption.Tracer.TraceDebug <ExchangePrincipal>((long)this.GetHashCode(), "Entering GetE15MultitenancySharingUrl for mailbox {0}", exchangePrincipal);
            Uri       uri = null;
            Exception ex  = null;

            try
            {
                uri = frontEndLocator.GetWebServicesUrl(exchangePrincipal);
            }
            catch (ServerNotFoundException ex2)
            {
                ex = ex2;
            }
            catch (ADTransientException ex3)
            {
                ex = ex3;
            }
            catch (DataSourceOperationException ex4)
            {
                ex = ex4;
            }
            catch (DataValidationException ex5)
            {
                ex = ex5;
            }
            finally
            {
                if (ex != null)
                {
                    throw new NoExternalEwsAvailableException(ex);
                }
            }
            string text = uri.ToString();

            SharedFolderDataEncryption.Tracer.TraceDebug <string>((long)this.GetHashCode(), "GetE15MultitenancySharingUrl - EWS url '{0}'", text);
            string text2 = EwsWsSecurityUrl.Fix(text);

            SharedFolderDataEncryption.Tracer.TraceDebug <string>((long)this.GetHashCode(), "GetE15MultitenancySharingUrl - fixed EWS url '{0}'", text2);
            return(text2);
        }
Esempio n. 25
0
 internal PerformInvitationResults PerformInvitation(MailboxSession mailboxSession, SharingContext context, ValidRecipient[] recipients, IFrontEndLocator frontEndLocator)
 {
     Util.ThrowOnNullArgument(mailboxSession, "mailboxSession");
     Util.ThrowOnNullArgument(context, "context");
     Util.ThrowOnNullArgument(recipients, "recipients");
     Util.ThrowOnNullArgument(frontEndLocator, "frontEndLocator");
     if (recipients.Length == 0)
     {
         return(PerformInvitationResults.Ignored);
     }
     if (!context.SharingMessageType.IsInvitationOrAcceptOfRequest)
     {
         return(PerformInvitationResults.Ignored);
     }
     return(this.InternalPerformInvitation(mailboxSession, context, recipients, frontEndLocator));
 }
Esempio n. 26
0
        public EncryptionResults Encrypt(IExchangePrincipal mailboxOwner, ExternalUserCollection externalUserCollection, string[] recipients, string sender, string containerClass, string folderId, IFrontEndLocator frontEndLocator, string domainController = null)
        {
            IRecipientSession session = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(domainController, true, ConsistencyMode.IgnoreInvalid, null, mailboxOwner.MailboxInfo.OrganizationId.ToADSessionSettings(), ConfigScopes.TenantSubTree, 121, "Encrypt", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Sharing\\SharedFolderDataEncryption.cs");

            ValidRecipient[] recipients2 = Array.ConvertAll <string, ValidRecipient>(recipients, (string recipient) => new ValidRecipient(recipient, session.FindByProxyAddress(new SmtpProxyAddress(recipient, false))));
            return(this.Encrypt(mailboxOwner, session, externalUserCollection, recipients2, sender, containerClass, folderId, frontEndLocator));
        }
Esempio n. 27
0
 protected ClutterNotification(MailboxSession session, VariantConfigurationSnapshot snapshot, IFrontEndLocator frontEndLocator)
 {
     ArgumentValidator.ThrowIfNull("session", session);
     ArgumentValidator.ThrowIfNull("snapshot", snapshot);
     if (frontEndLocator == null)
     {
         InferenceDiagnosticsLog.Log("ClutterNotification.ctor", "FrontEndLocator was not provided (it must be dependency injected). Using default OWA path.");
     }
     this.Session         = session;
     this.Snapshot        = snapshot;
     this.FrontEndLocator = frontEndLocator;
     this.Culture         = ClutterNotification.GetPreferredCulture(this.Session);
 }
 protected override PerformInvitationResults InternalPerformInvitation(MailboxSession mailboxSession, SharingContext context, ValidRecipient[] recipients, IFrontEndLocator frontEndLocator)
 {
     using (Folder folder = Folder.Bind(mailboxSession, context.FolderId))
     {
         context.PopulateUrls(folder);
     }
     return(new PerformInvitationResults(recipients));
 }