protected override void UpdateDataObject(ADOwaVirtualDirectory dataObject) { if (dataObject.IsChanged(ADOwaVirtualDirectorySchema.LogonFormat) && (dataObject.LogonFormat == LogonFormats.FullDomain || dataObject.LogonFormat == LogonFormats.PrincipalName)) { dataObject.DefaultDomain = ""; } if (base.Fields.Contains("DefaultDomain")) { dataObject.DefaultDomain = this.DefaultDomain; } if (base.Fields.Contains("GzipLevel")) { if (dataObject.IsExchange2007OrLater || !this.IsMailboxRoleInstalled(dataObject)) { GzipLevel gzipLevel = base.GzipLevel; GzipLevel gzipLevel2 = dataObject.GzipLevel; dataObject.GzipLevel = base.GzipLevel; base.CheckGzipLevelIsNotError(dataObject.GzipLevel); } else { base.WriteError(new TaskException(Strings.OwaGzipCannotBeSetToLegacyVirtualDirectoryWhenMailboxRoleInstalled), ErrorCategory.NotSpecified, null); } } base.UpdateDataObject(dataObject); }
internal void CheckGzipLevelIsNotError(GzipLevel gzipLevel) { if (gzipLevel == GzipLevel.Error) { base.WriteError(new TaskException(Strings.GzipCannotBeSetToError), ErrorCategory.NotSpecified, null); } }
internal static void UpdateMetabase(ExchangeWebAppVirtualDirectory webAppVirtualDirectory, string metabasePath, bool enableAnonymous) { try { DirectoryEntry directoryEntry2; DirectoryEntry directoryEntry = directoryEntry2 = IisUtility.CreateIISDirectoryEntry(webAppVirtualDirectory.MetabasePath); try { ArrayList arrayList = new ArrayList(); if (webAppVirtualDirectory.DefaultDomain.Length > 0) { arrayList.Add(new MetabaseProperty("DefaultLogonDomain", webAppVirtualDirectory.DefaultDomain, true)); } else if (webAppVirtualDirectory.DefaultDomain == "") { directoryEntry.Properties["DefaultLogonDomain"].Clear(); } IisUtility.SetProperties(directoryEntry, arrayList); directoryEntry.CommitChanges(); IisUtility.SetAuthenticationMethod(directoryEntry, AuthenticationMethodFlags.None, true); IisUtility.SetAuthenticationMethod(directoryEntry, AuthenticationMethodFlags.Basic, webAppVirtualDirectory.BasicAuthentication); IisUtility.SetAuthenticationMethod(directoryEntry, AuthenticationMethodFlags.Digest, webAppVirtualDirectory.DigestAuthentication); IisUtility.SetAuthenticationMethod(directoryEntry, AuthenticationMethodFlags.WindowsIntegrated, webAppVirtualDirectory.WindowsAuthentication); IisUtility.SetAuthenticationMethod(directoryEntry, AuthenticationMethodFlags.LiveIdFba, webAppVirtualDirectory.LiveIdAuthentication); if (webAppVirtualDirectory.FormsAuthentication) { OwaIsapiFilter.EnableFba(directoryEntry); } else { OwaIsapiFilter.DisableFba(directoryEntry); } IisUtility.SetAuthenticationMethod(directoryEntry, MetabasePropertyTypes.AuthFlags.Anonymous, enableAnonymous); directoryEntry.CommitChanges(); } finally { if (directoryEntry2 != null) { ((IDisposable)directoryEntry2).Dispose(); } } GzipLevel gzipLevel = webAppVirtualDirectory.GzipLevel; string site = IisUtility.WebSiteFromMetabasePath(webAppVirtualDirectory.MetabasePath); Gzip.SetIisGzipLevel(site, GzipLevel.High); Gzip.SetVirtualDirectoryGzipLevel(webAppVirtualDirectory.MetabasePath, gzipLevel); } catch (IISGeneralCOMException ex) { if (ex.Code == -2147023174) { throw new IISNotReachableException(IisUtility.GetHostName(webAppVirtualDirectory.MetabasePath), ex.Message); } throw; } }
internal static void SetIisGzipLevel(string site, GzipLevel gzipLevel) { if (gzipLevel == GzipLevel.Off) { return; } string str = site + "/W3SVC"; bool flag = gzipLevel == GzipLevel.High; bool flag2 = true; bool flag3 = true; string[] array = new string[] { "htm", "html", "txt", "htc", "css", "js", "xsl", "docx", "doc", "xlsx", "xls", "pptx", "ppt", "mdb" }; string[] array2 = new string[] { "owa", "aspx", "eas" }; string[] array3 = new string[] { "ashx" }; int num = 10; int num2 = 3; bool flag4 = false; bool flag5 = false; bool flag6 = false; using (DirectoryEntry directoryEntry = IisUtility.CreateIISDirectoryEntry(str + "/Filters/Compression/gzip")) { if (gzipLevel == GzipLevel.High) { IisUtility.SetProperty(directoryEntry, "HCDoDynamicCompression", flag, true); } IisUtility.SetProperty(directoryEntry, "HCDoStaticCompression", flag2, true); IisUtility.SetProperty(directoryEntry, "HCDoOnDemandCompression", flag3, true); for (int i = 0; i < array.Length; i++) { IisUtility.SetProperty(directoryEntry, "HCFileExtensions", array[i], i == 0); } IList list = null; if (directoryEntry.Properties.Contains("HCScriptFileExtensions")) { list = directoryEntry.Properties["HCScriptFileExtensions"]; } for (int j = 0; j < array2.Length; j++) { bool flag7 = false; if (list != null) { for (int k = 0; k < list.Count; k++) { if (list[k] is string && string.Equals(array2[j], (string)list[k], StringComparison.OrdinalIgnoreCase)) { flag7 = true; break; } } } if (!flag7) { IisUtility.SetProperty(directoryEntry, "HCScriptFileExtensions", array2[j], false); } } if (list != null) { for (int l = 0; l < array3.Length; l++) { for (int m = 0; m < list.Count; m++) { if (list[m] is string && string.Equals(array3[l], (string)list[m], StringComparison.OrdinalIgnoreCase)) { list.Remove((string)list[m]); m = -1; } } } } IisUtility.SetProperty(directoryEntry, "HCOnDemandCompLevel", num, true); if (gzipLevel == GzipLevel.High) { IisUtility.SetProperty(directoryEntry, "HCDynamicCompressionLevel", num2, true); } directoryEntry.CommitChanges(); IisUtility.CommitMetabaseChanges(IisUtility.ServerFromWebSite(site)); } using (DirectoryEntry directoryEntry2 = IisUtility.CreateIISDirectoryEntry(str + "/Filters/Compression/Parameters")) { IisUtility.SetProperty(directoryEntry2, "HCSendCacheHeaders", flag4, true); IisUtility.SetProperty(directoryEntry2, "HCNoCompressionForHTTP10", flag5, true); IisUtility.SetProperty(directoryEntry2, "HCNoCompressionForProxies", flag6, true); directoryEntry2.CommitChanges(); IisUtility.CommitMetabaseChanges(IisUtility.ServerFromWebSite(site)); } }
internal static void SetVirtualDirectoryGzipLevel(string adsiVirtualDirectoryPath, GzipLevel gzipLevel) { using (DirectoryEntry directoryEntry = IisUtility.CreateIISDirectoryEntry(adsiVirtualDirectoryPath)) { bool flag = gzipLevel == GzipLevel.High; bool flag2 = gzipLevel == GzipLevel.Low || gzipLevel == GzipLevel.High; IisUtility.SetProperty(directoryEntry, "DoDynamicCompression", flag, true); IisUtility.SetProperty(directoryEntry, "DoStaticCompression", flag2, true); directoryEntry.CommitChanges(); IisUtility.CommitMetabaseChanges(IisUtility.ServerFromWebSite(IisUtility.WebSiteFromMetabasePath(directoryEntry.Path))); } }