internal static PolicyConfiguration GetPolicyConfigurationFromAD(IConfigurationSession session, ADObjectId owaMailboxPolicyId)
        {
            OwaMailboxPolicy[] array            = session.Find <OwaMailboxPolicy>(owaMailboxPolicyId, QueryScope.Base, null, null, 1);
            OwaMailboxPolicy   owaMailboxPolicy = null;

            if (array != null && array.Length == 1)
            {
                owaMailboxPolicy = array[0];
            }
            if (owaMailboxPolicy == null)
            {
                ExTraceGlobals.PolicyConfigurationTracer.TraceError <ADObjectId>(0L, LocalizedStrings.GetNonEncoded(246332502), owaMailboxPolicyId);
                return(null);
            }
            PolicyConfiguration policyConfiguration = new PolicyConfiguration();

            policyConfiguration.PhoneticSupportEnabled = owaMailboxPolicy.PhoneticSupportEnabled;
            AttachmentPolicy.Level treatUnknownTypeAs = ConfigurationBase.AttachmentActionToLevel(new AttachmentBlockingActions?(owaMailboxPolicy.ActionForUnknownFileAndMIMETypes));
            AttachmentPolicy       attachmentPolicy   = new AttachmentPolicy(owaMailboxPolicy.BlockedFileTypes.ToArray(), owaMailboxPolicy.BlockedMimeTypes.ToArray(), owaMailboxPolicy.ForceSaveFileTypes.ToArray(), owaMailboxPolicy.ForceSaveMimeTypes.ToArray(), owaMailboxPolicy.AllowedFileTypes.ToArray(), owaMailboxPolicy.AllowedMimeTypes.ToArray(), treatUnknownTypeAs, owaMailboxPolicy.DirectFileAccessOnPublicComputersEnabled, owaMailboxPolicy.DirectFileAccessOnPrivateComputersEnabled, owaMailboxPolicy.ForceWebReadyDocumentViewingFirstOnPublicComputers, owaMailboxPolicy.ForceWebReadyDocumentViewingFirstOnPrivateComputers, owaMailboxPolicy.WebReadyDocumentViewingOnPublicComputersEnabled, owaMailboxPolicy.WebReadyDocumentViewingOnPrivateComputersEnabled, owaMailboxPolicy.WebReadyFileTypes.ToArray(), owaMailboxPolicy.WebReadyMimeTypes.ToArray(), owaMailboxPolicy.WebReadyDocumentViewingSupportedFileTypes.ToArray(), owaMailboxPolicy.WebReadyDocumentViewingSupportedMimeTypes.ToArray(), owaMailboxPolicy.WebReadyDocumentViewingForAllSupportedTypes);

            policyConfiguration.AttachmentPolicy      = attachmentPolicy;
            policyConfiguration.DefaultClientLanguage = owaMailboxPolicy.DefaultClientLanguage;
            policyConfiguration.LogonAndErrorLanguage = owaMailboxPolicy.LogonAndErrorLanguage;
            policyConfiguration.DefaultTheme          = owaMailboxPolicy.DefaultTheme;
            policyConfiguration.SetPhotoURL           = owaMailboxPolicy.SetPhotoURL;
            int segmentationBits  = (int)owaMailboxPolicy[OwaMailboxPolicySchema.ADMailboxFolderSet];
            int segmentationBits2 = (int)owaMailboxPolicy[OwaMailboxPolicySchema.ADMailboxFolderSet2];

            policyConfiguration.SegmentationFlags    = Utilities.SetSegmentationFlags(segmentationBits, segmentationBits2);
            policyConfiguration.OutboundCharset      = owaMailboxPolicy.OutboundCharset;
            policyConfiguration.UseGB18030           = owaMailboxPolicy.UseGB18030;
            policyConfiguration.UseISO885915         = owaMailboxPolicy.UseISO885915;
            policyConfiguration.InstantMessagingType = ((owaMailboxPolicy.InstantMessagingType != null) ? owaMailboxPolicy.InstantMessagingType.Value : InstantMessagingTypeOptions.None);
            return(policyConfiguration);
        }
        private OwaMailboxPolicy GetSettingsFromTenantConfig(OrganizationId orgId)
        {
            OwaMailboxPolicy defaultOwaMailboxPolicy = OwaSegmentationSettings.GetDefaultOwaMailboxPolicy(orgId);

            if (defaultOwaMailboxPolicy == null)
            {
                ExTraceGlobals.OwaSegmentationTracer.TraceDebug((long)this.GetHashCode(), "No OwaMailboxPolicy found in tenant config, doing fallback on to OWA vDir.");
            }
            return(defaultOwaMailboxPolicy);
        }
        private ADObjectId GetPolicyIdFromAD(OrganizationId key)
        {
            OwaMailboxPolicy defaultOwaMailboxPolicy = OwaSegmentationSettings.GetDefaultOwaMailboxPolicy(key);

            if (defaultOwaMailboxPolicy == null)
            {
                return(null);
            }
            return(defaultOwaMailboxPolicy.Id);
        }
 public static bool UpdateOwaMailboxPolicy(OrganizationId orgId, ADObjectId owaPolicyId, out ADObjectId newOwaPolicy)
 {
     newOwaPolicy = null;
     if (owaPolicyId == null)
     {
         OwaMailboxPolicy defaultOwaMailboxPolicy = OwaSegmentationSettings.GetDefaultOwaMailboxPolicy(orgId);
         if (defaultOwaMailboxPolicy != null)
         {
             newOwaPolicy = defaultOwaMailboxPolicy.Id;
             return(true);
         }
     }
     return(false);
 }
        internal static PolicyConfiguration GetPolicyConfigurationFromAD(IConfigurationSession session, ADObjectId owaMailboxPolicyId)
        {
            OwaMailboxPolicy[] array            = session.Find <OwaMailboxPolicy>(owaMailboxPolicyId, QueryScope.Base, null, null, 1);
            OwaMailboxPolicy   owaMailboxPolicy = null;

            if (array != null && array.Length == 1)
            {
                owaMailboxPolicy = array[0];
            }
            if (owaMailboxPolicy == null)
            {
                ExTraceGlobals.PolicyConfigurationTracer.TraceError <ADObjectId>(0L, "The mailbox policy {0} couldn't be found in Active Directory.", owaMailboxPolicyId);
                return(null);
            }
            return(PolicyConfiguration.CreatePolicyConfigurationFromOwaMailboxPolicy(owaMailboxPolicy));
        }
Esempio n. 6
0
        internal ADObjectId GetDefaultOwaMailboxPolicyId(ADObject user)
        {
            ADObjectId     adobjectId     = null;
            OrganizationId organizationId = user.OrganizationId;

            if (!this.owaMailboxPolicyCache.TryGetValue(organizationId, out adobjectId))
            {
                OwaMailboxPolicy defaultOwaMailboxPolicy = OwaSegmentationSettings.GetDefaultOwaMailboxPolicy(organizationId);
                if (defaultOwaMailboxPolicy != null)
                {
                    adobjectId = defaultOwaMailboxPolicy.Id;
                }
                this.owaMailboxPolicyCache.Add(organizationId, adobjectId);
            }
            return(adobjectId);
        }
        private OwaMailboxPolicy GetSettingsFromOwaMailboxPolicy(IConfigurationSession configSession, ADObjectId owaMailboxPolicyId)
        {
            if (owaMailboxPolicyId == null)
            {
                ExTraceGlobals.OwaSegmentationTracer.TraceDebug((long)this.GetHashCode(), "No OwaMailboxPolicy applied for the user, doing fallback on to TenantConfig settings.");
                return(null);
            }
            ExTraceGlobals.OwaSegmentationTracer.TraceDebug <string>((long)this.GetHashCode(), "Reading OwaMailboxPolicy: DN={0} from AD.", owaMailboxPolicyId.DistinguishedName);
            OwaMailboxPolicy owaMailboxPolicy = configSession.Read <OwaMailboxPolicy>(owaMailboxPolicyId);

            if (owaMailboxPolicy != null)
            {
                return(owaMailboxPolicy);
            }
            ExTraceGlobals.OwaSegmentationTracer.TraceWarning <string>((long)this.GetHashCode(), "Error reading OwaMailboxPolicy: DN={0}; User settings may be incorrect.", owaMailboxPolicyId.DistinguishedName);
            return(null);
        }
        internal static PolicyConfiguration CreatePolicyConfigurationFromOwaMailboxPolicy(OwaMailboxPolicy owaMailboxPolicy)
        {
            if (owaMailboxPolicy == null)
            {
                return(null);
            }
            PolicyConfiguration   policyConfiguration = new PolicyConfiguration();
            AttachmentPolicyLevel treatUnknownTypeAs  = ConfigurationBase.AttachmentActionToPolicyLevel(new AttachmentBlockingActions?(owaMailboxPolicy.ActionForUnknownFileAndMIMETypes));
            AttachmentPolicy      attachmentPolicy    = new AttachmentPolicy(owaMailboxPolicy.BlockedFileTypes.ToArray(), owaMailboxPolicy.BlockedMimeTypes.ToArray(), owaMailboxPolicy.ForceSaveFileTypes.ToArray(), owaMailboxPolicy.ForceSaveMimeTypes.ToArray(), owaMailboxPolicy.AllowedFileTypes.ToArray(), owaMailboxPolicy.AllowedMimeTypes.ToArray(), treatUnknownTypeAs, owaMailboxPolicy.DirectFileAccessOnPublicComputersEnabled, owaMailboxPolicy.DirectFileAccessOnPrivateComputersEnabled, owaMailboxPolicy.ForceWacViewingFirstOnPublicComputers, owaMailboxPolicy.ForceWacViewingFirstOnPrivateComputers, owaMailboxPolicy.WacViewingOnPublicComputersEnabled, owaMailboxPolicy.WacViewingOnPrivateComputersEnabled, owaMailboxPolicy.ForceWebReadyDocumentViewingFirstOnPublicComputers, owaMailboxPolicy.ForceWebReadyDocumentViewingFirstOnPrivateComputers, owaMailboxPolicy.WebReadyDocumentViewingOnPublicComputersEnabled, owaMailboxPolicy.WebReadyDocumentViewingOnPrivateComputersEnabled, owaMailboxPolicy.WebReadyFileTypes.ToArray(), owaMailboxPolicy.WebReadyMimeTypes.ToArray(), owaMailboxPolicy.WebReadyDocumentViewingSupportedFileTypes.ToArray(), owaMailboxPolicy.WebReadyDocumentViewingSupportedMimeTypes.ToArray(), owaMailboxPolicy.WebReadyDocumentViewingForAllSupportedTypes);

            policyConfiguration.AttachmentPolicy = attachmentPolicy;
            int segmentationBits  = (int)owaMailboxPolicy[OwaMailboxPolicySchema.ADMailboxFolderSet];
            int segmentationBits2 = (int)owaMailboxPolicy[OwaMailboxPolicySchema.ADMailboxFolderSet2];

            policyConfiguration.SegmentationFlags    = ConfigurationBase.SetSegmentationFlags(segmentationBits, segmentationBits2);
            policyConfiguration.OutboundCharset      = owaMailboxPolicy.OutboundCharset;
            policyConfiguration.UseGB18030           = owaMailboxPolicy.UseGB18030;
            policyConfiguration.UseISO885915         = owaMailboxPolicy.UseISO885915;
            policyConfiguration.InstantMessagingType = ((owaMailboxPolicy.InstantMessagingType != null) ? owaMailboxPolicy.InstantMessagingType.Value : InstantMessagingTypeOptions.None);
            policyConfiguration.DefaultTheme         = owaMailboxPolicy.DefaultTheme;
            policyConfiguration.PlacesEnabled        = owaMailboxPolicy.PlacesEnabled;
            policyConfiguration.WeatherEnabled       = owaMailboxPolicy.WeatherEnabled;
            policyConfiguration.AllowCopyContactsToDeviceAddressBook = owaMailboxPolicy.AllowCopyContactsToDeviceAddressBook;
            policyConfiguration.AllowOfflineOn             = owaMailboxPolicy.AllowOfflineOn;
            policyConfiguration.RecoverDeletedItemsEnabled = owaMailboxPolicy.RecoverDeletedItemsEnabled;
            policyConfiguration.GroupCreationEnabled       = owaMailboxPolicy.GroupCreationEnabled;
            return(policyConfiguration);
        }
Esempio n. 9
0
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            base.InternalValidate();
            if (base.Fields.IsModified(CASMailboxSchema.ActiveSyncMailboxPolicy))
            {
                if (this.ActiveSyncMailboxPolicy != null)
                {
                    MobileMailboxPolicy mobileMailboxPolicy = (MobileMailboxPolicy)base.GetDataObject <MobileMailboxPolicy>(this.ActiveSyncMailboxPolicy, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorMobileMailboxPolicyNotFound(this.ActiveSyncMailboxPolicy.ToString())), new LocalizedString?(Strings.ErrorMobileMailboxPolicyNotUnique(this.ActiveSyncMailboxPolicy.ToString())));
                    this.DataObject.ActiveSyncMailboxPolicy = (ADObjectId)mobileMailboxPolicy.Identity;
                }
                else
                {
                    this.DataObject.ActiveSyncMailboxPolicy = null;
                }
            }
            if (base.Fields.IsModified(CASMailboxSchema.OwaMailboxPolicy))
            {
                if (this.DataObject.ExchangeVersion.Equals(ExchangeObjectVersion.Exchange2007))
                {
                    base.WriteError(new ArgumentException(Strings.ErrorSetOWAMailboxPolicyToE12User), ErrorCategory.InvalidArgument, this.Identity);
                }
                if (this.OwaMailboxPolicy != null)
                {
                    OwaMailboxPolicy owaMailboxPolicy = (OwaMailboxPolicy)base.GetDataObject <OwaMailboxPolicy>(this.OwaMailboxPolicy, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorOwaMailboxPolicyNotFound(this.OwaMailboxPolicy.ToString())), new LocalizedString?(Strings.ErrorOwaMailboxPolicyNotUnique(this.OwaMailboxPolicy.ToString())));
                    this.DataObject.OwaMailboxPolicy = (ADObjectId)owaMailboxPolicy.Identity;
                }
                else
                {
                    this.DataObject.OwaMailboxPolicy = null;
                }
            }
            this.allowedDeviceIDs = this.DataObject.ActiveSyncAllowedDeviceIDs;
            this.blockedDeviceIDs = this.DataObject.ActiveSyncBlockedDeviceIDs;
            bool changed  = this.allowedDeviceIDs.Changed;
            bool changed2 = this.blockedDeviceIDs.Changed;

            if (changed || changed2)
            {
                List <string> list  = new List <string>();
                List <string> list2 = new List <string>();
                this.deviceIdListsChanged = true;
                foreach (string text in this.allowedDeviceIDs)
                {
                    foreach (string b in this.blockedDeviceIDs)
                    {
                        if (string.Equals(text, b, StringComparison.OrdinalIgnoreCase))
                        {
                            if (changed && changed2)
                            {
                                base.WriteError(new ErrorDeviceIdInBothLists(text), ErrorCategory.InvalidData, this.Identity);
                            }
                            else if (changed)
                            {
                                list2.Add(text);
                            }
                            else
                            {
                                list.Add(text);
                            }
                        }
                    }
                }
                if (list.Count > 0)
                {
                    foreach (string item in list)
                    {
                        this.allowedDeviceIDs.Remove(item);
                    }
                    this.DataObject.ActiveSyncAllowedDeviceIDs = this.allowedDeviceIDs;
                }
                if (list2.Count > 0)
                {
                    foreach (string item2 in list2)
                    {
                        this.blockedDeviceIDs.Remove(item2);
                    }
                    this.DataObject.ActiveSyncBlockedDeviceIDs = this.blockedDeviceIDs;
                }
            }
            TaskLogger.LogExit();
        }