示例#1
0
        protected override void InternalValidate()
        {
            base.InternalValidate();
            if (base.HasErrors)
            {
                return;
            }
            T      dataObject = this.DataObject;
            string hostName   = IisUtility.GetHostName(dataObject.MetabasePath);

            try
            {
                if (!new IisVersionValidCondition(hostName).Verify())
                {
                    Exception     exception   = new ArgumentException(Strings.ErrorIisVersionIsInvalid(hostName), "Server");
                    ErrorCategory category    = ErrorCategory.InvalidArgument;
                    T             dataObject2 = this.DataObject;
                    base.WriteError(exception, category, dataObject2.Identity);
                    return;
                }
            }
            catch (IOException innerException)
            {
                Exception     exception2  = new ArgumentException(Strings.ErrorCannotDetermineIisVersion(hostName), "Server", innerException);
                ErrorCategory category2   = ErrorCategory.InvalidArgument;
                T             dataObject3 = this.DataObject;
                base.WriteError(exception2, category2, dataObject3.Identity);
            }
            catch (InvalidOperationException innerException2)
            {
                Exception     exception3  = new ArgumentException(Strings.ErrorCannotDetermineIisVersion(hostName), "Server", innerException2);
                ErrorCategory category3   = ErrorCategory.InvalidArgument;
                T             dataObject4 = this.DataObject;
                base.WriteError(exception3, category3, dataObject4.Identity);
            }
            ExtendedProtection.Validate(this, this.DataObject);
            base.VerifyIsWithinScopes((IConfigurationSession)base.DataSession, this.DataObject, true, new DataAccessTask <T> .ADObjectOutOfScopeString(Strings.ErrorCannotSetVirtualDirectoryOutOfWriteScope));
            TaskLogger.LogExit();
        }
示例#2
0
        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();
        }