protected override void DeleteFromMetabase() { if (string.IsNullOrEmpty(base.DataObject.MetabasePath)) { string webSiteRoot = IisUtility.CreateAbsolutePath(IisUtility.AbsolutePathType.WebSiteRoot, this.Identity.Server, IisUtility.FindWebSiteRootPath(this.Identity.Name, this.Identity.Server), null); string virtualDirectoryName = "Microsoft-Server-ActiveSync"; DeleteVirtualDirectory.DeleteFromMetabase(webSiteRoot, virtualDirectoryName, this.ChildVirtualDirectoryNames); return; } base.DeleteFromMetabase(); }
internal static void RemoveFilters(string hostName) { string iisDirectoryEntryPath = IisUtility.CreateAbsolutePath(IisUtility.AbsolutePathType.WebServicesRoot, hostName, null, null); using (DirectoryEntry directoryEntry = IisUtility.CreateIISDirectoryEntry(iisDirectoryEntryPath)) { foreach (object obj in directoryEntry.Children) { DirectoryEntry directoryEntry2 = (DirectoryEntry)obj; if (directoryEntry2.SchemaClassName == "IIsWebServer") { OwaIsapiFilter.RemoveFilter(directoryEntry2.Path); } } } }
protected override void InternalValidate() { object[] array = new object[1]; object[] array2 = array; int num = 0; T dataObject = this.DataObject; array2[num] = dataObject.Identity; TaskLogger.LogEnter(array); base.InternalValidate(); if (base.HasErrors) { return; } string fqdn = base.OwningServer.Fqdn; string text = base.Name.ToString(); if (string.IsNullOrEmpty(this.WebSiteName)) { if (this.Role == VirtualDirectoryRole.ClientAccess) { this.WebSiteName = IisUtility.GetWebSiteName(IisUtility.CreateAbsolutePath(IisUtility.AbsolutePathType.WebSiteRoot, fqdn, "/W3SVC/1/ROOT", null)); this.ApplicationRoot = "/W3SVC/1/ROOT"; } else { this.WebSiteName = "Exchange Back End"; } } if (string.Empty.Equals(this.AppPoolId)) { Exception exception = new ArgumentException(Strings.ErrorAppPoolIdCannotBeEmpty, "AppPoolId"); ErrorCategory category = ErrorCategory.InvalidArgument; T dataObject2 = this.DataObject; base.WriteError(exception, category, dataObject2.Identity); } try { if (!new IisVersionValidCondition(fqdn).Verify()) { Exception exception2 = new ArgumentException(Strings.ErrorIisVersionIsInvalid(fqdn), "Server"); ErrorCategory category2 = ErrorCategory.InvalidArgument; T dataObject3 = this.DataObject; base.WriteError(exception2, category2, dataObject3.Identity); } } catch (IOException innerException) { Exception exception3 = new ArgumentException(Strings.ErrorCannotDetermineIisVersion(fqdn), "Server", innerException); ErrorCategory category3 = ErrorCategory.InvalidArgument; T dataObject4 = this.DataObject; base.WriteError(exception3, category3, dataObject4.Identity); } catch (InvalidOperationException innerException2) { Exception exception4 = new ArgumentException(Strings.ErrorCannotDetermineIisVersion(fqdn), "Server", innerException2); ErrorCategory category4 = ErrorCategory.InvalidArgument; T dataObject5 = this.DataObject; base.WriteError(exception4, category4, dataObject5.Identity); } try { if (!new WebSiteExistsCondition(fqdn, this.WebSiteName).Verify()) { Exception exception5 = new ArgumentException(Strings.ErrorWebSiteNotExists(this.WebSiteName, fqdn), "WebSiteName"); ErrorCategory category5 = ErrorCategory.InvalidArgument; T dataObject6 = this.DataObject; base.WriteError(exception5, category5, dataObject6.Identity); } if (string.IsNullOrEmpty(this.ApplicationRoot)) { this.ApplicationRoot = IisUtility.FindWebSiteRootPath(this.WebSiteName, fqdn); } } catch (IisUtilityCannotDisambiguateWebSiteException innerException3) { Exception exception6 = new ArgumentException(Strings.ErrorWebsiteAmbiguousInIIS(this.WebSiteName, fqdn), "WebSiteName", innerException3); ErrorCategory category6 = ErrorCategory.InvalidArgument; T dataObject7 = this.DataObject; base.WriteError(exception6, category6, dataObject7.Identity); } T dataObject8 = this.DataObject; T dataObject9 = this.DataObject; dataObject8.SetId(new ADObjectId(dataObject9.Server.DistinguishedName).GetDescendantId("Protocols", "HTTP", new string[] { string.Format("{0} ({1})", base.Name, this.WebSiteName) })); if (this.FailOnVirtualDirectoryADObjectAlreadyExists()) { IConfigDataProvider dataSession = base.DataSession; T dataObject10 = this.DataObject; if (dataSession.Read <T>(dataObject10.Identity) != null) { string virtualDirectoryName = text; T dataObject11 = this.DataObject; Exception exception7 = new ArgumentException(Strings.ErrorVirtualDirectoryADObjectAlreadyExists(virtualDirectoryName, dataObject11.DistinguishedName), "VirtualDirectoryName"); ErrorCategory category7 = ErrorCategory.InvalidArgument; T dataObject12 = this.DataObject; base.WriteError(exception7, category7, dataObject12.Identity); } } if (this.FailOnVirtualDirectoryAlreadyExists() && new VirtualDirectoryExistsCondition(fqdn, this.WebSiteName, text).Verify()) { Exception exception8 = new ArgumentException(Strings.ErrorVirtualDirectoryAlreadyExists(text, this.WebSiteName, fqdn), "VirtualDirectoryName"); ErrorCategory category8 = ErrorCategory.InvalidArgument; T dataObject13 = this.DataObject; base.WriteError(exception8, category8, dataObject13.Identity); } T dataObject14 = this.DataObject; dataObject14.MetabasePath = string.Format("IIS://{0}{1}/{2}", fqdn, IisUtility.FindWebSiteRootPath(this.WebSiteName, fqdn), text); ExtendedProtection.Validate(this, this.DataObject); TaskLogger.LogExit(); }
internal string GetAbsolutePath(IisUtility.AbsolutePathType pathType) { string fqdn = base.OwningServer.Fqdn; return(IisUtility.CreateAbsolutePath(pathType, fqdn, IisUtility.FindWebSiteRootPath(this.WebSiteName, fqdn), base.Name.ToString())); }
protected override IConfigurable PrepareDataObject() { TaskLogger.LogEnter(); ADOabVirtualDirectory adoabVirtualDirectory = (ADOabVirtualDirectory)base.PrepareDataObject(); adoabVirtualDirectory.RequireSSL = this.RequireSSL; this.serverFQDN = base.OwningServer.Fqdn; string text; if (string.IsNullOrEmpty(base.WebSiteName)) { if (base.Role == VirtualDirectoryRole.ClientAccess) { text = IisUtility.GetWebSiteName(IisUtility.CreateAbsolutePath(IisUtility.AbsolutePathType.WebSiteRoot, this.serverFQDN, "/W3SVC/1/ROOT", null)); } else { text = "Exchange Back End"; } } else { text = base.WebSiteName; } ADOabVirtualDirectory[] array = ((IConfigurationSession)base.DataSession).Find <ADOabVirtualDirectory>(base.OwningServer.Id, QueryScope.SubTree, null, null, 0); if (array != null && array.Length != 0) { ADOabVirtualDirectory[] array2 = array; int i = 0; while (i < array2.Length) { ADOabVirtualDirectory adoabVirtualDirectory2 = array2[i]; string webSiteRootPath = null; string text2 = null; try { IisUtility.ParseApplicationRootPath(adoabVirtualDirectory2.MetabasePath, ref webSiteRootPath, ref text2); } catch (IisUtilityInvalidApplicationRootPathException ex) { base.WriteWarning(ex.Message); goto IL_24E; } goto IL_D6; IL_24E: i++; continue; IL_D6: string webSiteName = IisUtility.GetWebSiteName(webSiteRootPath); if (string.Compare(webSiteName, text, false) == 0) { try { if (DirectoryEntry.Exists(adoabVirtualDirectory2.MetabasePath)) { if (!this.Recovery) { base.WriteError(new InvalidOperationException(Strings.ErrorOabVirtualDirectoryAlreadyExists(adoabVirtualDirectory2.Identity.ToString(), text, this.serverFQDN)), ErrorCategory.InvalidOperation, this.DataObject.Identity); } else { base.WriteError(new InvalidOperationException(Strings.ErrorOabVirtualDirectoryAlreadyExistsWithRecovery(adoabVirtualDirectory2.Identity.ToString(), text, this.serverFQDN)), ErrorCategory.InvalidOperation, this.DataObject.Identity); } } else if (!this.Recovery) { base.WriteError(new InvalidOperationException(Strings.ErrorOabVirtualDirectoryADObjectAlreadyExists(adoabVirtualDirectory2.Identity.ToString(), text, this.serverFQDN)), ErrorCategory.InvalidOperation, this.DataObject.Identity); } else { array[0].CopyChangesFrom(adoabVirtualDirectory); adoabVirtualDirectory = adoabVirtualDirectory2; adoabVirtualDirectory.SetId(new ADObjectId(adoabVirtualDirectory.Server.DistinguishedName).GetDescendantId("Protocols", "HTTP", new string[] { string.Format("{0} ({1})", this.Name, base.WebSiteName) })); adoabVirtualDirectory.MetabasePath = string.Format("IIS://{0}{1}/{2}", this.serverFQDN, IisUtility.FindWebSiteRootPath(base.WebSiteName, this.serverFQDN), this.Name); } } catch (COMException exception) { base.WriteError(exception, ErrorCategory.ReadError, null); } goto IL_24E; } goto IL_24E; } } if (new VirtualDirectoryExistsCondition(this.serverFQDN, text, this.Name).Verify()) { base.WriteError(new InvalidOperationException(Strings.ErrorOabVirtualDirectoryIISObjectAlreadyExists(string.Format("{0}\\{1}", text, this.Name), text, this.serverFQDN)), ErrorCategory.InvalidOperation, this.DataObject.Identity); } this.isExistingFolder = true; this.isLocalServer = this.IsLocalServer(); if (string.IsNullOrEmpty(base.Path)) { base.Path = System.IO.Path.Combine(base.OwningServer.InstallPath.PathName, (base.Role == VirtualDirectoryRole.ClientAccess) ? "FrontEnd\\HttpProxy\\OAB" : "ClientAccess\\OAB"); } else { LocalLongFullPath localLongFullPath = null; try { localLongFullPath = LocalLongFullPath.Parse(base.Path); } catch (ArgumentException ex2) { base.WriteError(new ArgumentException(new LocalizedString(ex2.Message.ToString()), "Path"), ErrorCategory.InvalidArgument, base.OwningServer.Identity); return(null); } base.Path = localLongFullPath.PathName; } if (base.Role == VirtualDirectoryRole.ClientAccess && adoabVirtualDirectory.InternalUrl == null) { if (this.isLocalServer) { adoabVirtualDirectory.InternalUrl = new Uri(string.Format("http://{0}/{1}", ComputerInformation.DnsFullyQualifiedDomainName, "OAB")); } else { base.WriteError(new ArgumentException(Strings.ErrorMissingInternalUrlInRemoteScenario, "InternalUrl"), ErrorCategory.InvalidArgument, base.OwningServer.Identity); } } TaskLogger.LogExit(); return(adoabVirtualDirectory); }