protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     this.Clear();
     base.InternalValidate();
     this.CheckRbac();
     if (base.IsInherited)
     {
         return;
     }
     if (base.ParameterSetName == "Owner")
     {
         return;
     }
     if (base.Instance.AccessRights == null && base.Instance.ExtendedRights == null)
     {
         base.WriteError(new MustSpecifyEitherAccessOrExtendedRightsException(), ErrorCategory.InvalidData, null);
     }
     if (base.ParameterSetName == "Instance")
     {
         if (base.Instance.User == null)
         {
             base.WriteError(new ArgumentException(Strings.ErrorUserNull, "User"), ErrorCategory.InvalidArgument, null);
         }
         if (base.Instance.AccessRights == null || base.Instance.AccessRights.Length == 0)
         {
             base.WriteError(new ArgumentException(Strings.ErrorAccessRightsEmpty, "AccessRights"), ErrorCategory.InvalidArgument, null);
         }
         this.genericAll = this.IsGenericAllAccessRight(base.Instance);
     }
     else
     {
         bool flag  = false;
         bool flag2 = false;
         if (base.Instance.AccessRights != null)
         {
             foreach (ActiveDirectoryRights activeDirectoryRights in base.Instance.AccessRights)
             {
                 if (activeDirectoryRights == ActiveDirectoryRights.GenericAll)
                 {
                     this.genericAll = true;
                     break;
                 }
                 if (activeDirectoryRights == ActiveDirectoryRights.CreateChild || activeDirectoryRights == ActiveDirectoryRights.DeleteChild)
                 {
                     flag2 = true;
                 }
                 else if (activeDirectoryRights == ActiveDirectoryRights.ReadProperty || activeDirectoryRights == ActiveDirectoryRights.WriteProperty || activeDirectoryRights == ActiveDirectoryRights.Self)
                 {
                     flag = true;
                 }
             }
             if (this.genericAll && base.Instance.AccessRights.Length > 1)
             {
                 base.WriteError(new ArgumentException(Strings.ErrorGenericAllCannotbeUsedWithOtherAccessRights, "AccessRights"), ErrorCategory.InvalidArgument, null);
             }
         }
         if (!this.genericAll && base.Instance.ChildObjectTypes != null && !flag2 && !flag)
         {
             base.WriteError(new ArgumentException(Strings.ErrorChildObjectTypeParameter, "ChildObjectTypes"), ErrorCategory.InvalidArgument, null);
         }
         if (!this.genericAll && base.Instance.Properties != null && !flag)
         {
             base.WriteError(new ArgumentException(Strings.ErrorPropertyParameter, "Properties"), ErrorCategory.InvalidArgument, null);
         }
     }
     if (base.Instance.ExtendedRights != null)
     {
         for (int j = 0; j < base.Instance.ExtendedRights.Length; j++)
         {
             if (string.Compare(base.Instance.ExtendedRights[j].RawIdentity, "all", StringComparison.InvariantCultureIgnoreCase) == 0)
             {
                 this.allExtendedRightsSpecified = true;
                 break;
             }
             this.extendedRight.Add((ExtendedRight)base.GetDataObject <ExtendedRight>(base.Instance.ExtendedRights[j], base.ReadOnlyConfigurationSession, null, new LocalizedString?(Strings.ErrorExtendedRightNotFound(base.Instance.ExtendedRights[j].ToString())), new LocalizedString?(LocalizedString.Empty)));
         }
     }
     if (base.Instance.ChildObjectTypes != null)
     {
         for (int k = 0; k < base.Instance.ChildObjectTypes.Length; k++)
         {
             this.childObjectType.Add((ADSchemaClassObject)base.GetDataObject <ADSchemaClassObject>(base.Instance.ChildObjectTypes[k], base.ReadOnlyConfigurationSession, null, new LocalizedString?(Strings.ErrorChildObjectTypeNotFound(base.Instance.ChildObjectTypes[k].ToString())), new LocalizedString?(Strings.ErrorChildObjectTypeNotUnique(base.Instance.ChildObjectTypes[k].ToString()))));
         }
     }
     if (base.Instance.Properties != null)
     {
         for (int l = 0; l < base.Instance.Properties.Length; l++)
         {
             IEnumerable <ADSchemaAttributeObject> objects = base.Instance.Properties[l].GetObjects <ADSchemaAttributeObject>(null, base.ReadOnlyConfigurationSession);
             using (IEnumerator <ADSchemaAttributeObject> enumerator = objects.GetEnumerator())
             {
                 if (enumerator.MoveNext())
                 {
                     ADSchemaAttributeObject item = enumerator.Current;
                     if (enumerator.MoveNext())
                     {
                         base.WriteError(new ManagementObjectAmbiguousException(Strings.ErrorPropertyTypeNotUnique(base.Instance.Properties[l].ToString())), ErrorCategory.InvalidData, null);
                     }
                     else
                     {
                         this.propertyType.Add(item);
                     }
                 }
                 else
                 {
                     ExtendedRightIdParameter extendedRightIdParameter = ExtendedRightIdParameter.Parse(base.Instance.Properties[l].RawIdentity);
                     this.propertyType.Add((ExtendedRight)base.GetDataObject <ExtendedRight>(extendedRightIdParameter, base.ReadOnlyConfigurationSession, null, new LocalizedString?(Strings.ErrorPropertyTypeNotFound(extendedRightIdParameter.ToString())), new LocalizedString?(Strings.ErrorPropertyTypeNotUnique(extendedRightIdParameter.ToString()))));
                 }
             }
         }
     }
     if (base.Instance.InheritedObjectType != null)
     {
         this.inheritedObjectType = (ADSchemaClassObject)base.GetDataObject <ADSchemaClassObject>(base.Instance.InheritedObjectType, base.ReadOnlyConfigurationSession, null, new LocalizedString?(Strings.ErrorInheritedObjectTypeNotFound(base.Instance.InheritedObjectType.ToString())), new LocalizedString?(Strings.ErrorInheritedObjectTypeNotUnique(base.Instance.InheritedObjectType.ToString())));
     }
     TaskLogger.LogExit();
 }
示例#2
0
        protected override void PopulateCalculatedProperties()
        {
            base.PopulateCalculatedProperties();
            TaskLogger.Trace("Resolving InheritedObjectType", new object[0]);
            IConfigurationSession session = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 175, "PopulateCalculatedProperties", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\permission\\ADAcePresentationObject.cs");

            if (base.RealAce.InheritedObjectType != Guid.Empty)
            {
                ADSchemaObjectIdParameter         adschemaObjectIdParameter = ADSchemaObjectIdParameter.Parse(base.RealAce.InheritedObjectType.ToString());
                IEnumerable <ADSchemaClassObject> objects = adschemaObjectIdParameter.GetObjects <ADSchemaClassObject>(null, session);
                using (IEnumerator <ADSchemaClassObject> enumerator = objects.GetEnumerator())
                {
                    string text = null;
                    if (enumerator.MoveNext())
                    {
                        text = enumerator.Current.Name;
                    }
                    if (text == null || enumerator.MoveNext())
                    {
                        this.InheritedObjectType = ADSchemaObjectIdParameter.Parse(base.RealAce.InheritedObjectType.ToString());
                        TaskLogger.Trace("Could not resolve the following InheritedObjectType: {0}", new object[]
                        {
                            base.RealAce.InheritedObjectType.ToString()
                        });
                    }
                    else
                    {
                        this.InheritedObjectType = ADSchemaObjectIdParameter.Parse(text);
                    }
                }
            }
            if (base.RealAce.ObjectType != Guid.Empty)
            {
                ActiveDirectoryRights activeDirectoryRights = base.RealAce.ActiveDirectoryRights;
                string text2 = base.RealAce.ObjectType.ToString();
                bool   flag  = false;
                if ((activeDirectoryRights & ActiveDirectoryRights.ExtendedRight) == ActiveDirectoryRights.ExtendedRight)
                {
                    TaskLogger.Trace("Resolving ExtendedRight", new object[0]);
                    ExtendedRightIdParameter[]  extendedRights           = null;
                    ExtendedRightIdParameter    extendedRightIdParameter = ExtendedRightIdParameter.Parse(text2);
                    IEnumerable <ExtendedRight> objects2 = extendedRightIdParameter.GetObjects <ExtendedRight>(null, session);
                    using (IEnumerator <ExtendedRight> enumerator2 = objects2.GetEnumerator())
                    {
                        string text3 = null;
                        if (enumerator2.MoveNext())
                        {
                            text3 = enumerator2.Current.Name;
                        }
                        if (text3 != null && !enumerator2.MoveNext())
                        {
                            extendedRights = new ExtendedRightIdParameter[]
                            {
                                ExtendedRightIdParameter.Parse(text3)
                            };
                            flag = true;
                        }
                    }
                    this.ExtendedRights = extendedRights;
                }
                if ((!flag && (activeDirectoryRights & ActiveDirectoryRights.CreateChild) == ActiveDirectoryRights.CreateChild) || (activeDirectoryRights & ActiveDirectoryRights.DeleteChild) == ActiveDirectoryRights.DeleteChild || (activeDirectoryRights & ActiveDirectoryRights.ReadProperty) == ActiveDirectoryRights.ReadProperty || (activeDirectoryRights & ActiveDirectoryRights.WriteProperty) == ActiveDirectoryRights.WriteProperty)
                {
                    TaskLogger.Trace("Resolving Child Object Type", new object[0]);
                    ADSchemaObjectIdParameter[]       childObjectTypes           = null;
                    ADSchemaObjectIdParameter         adschemaObjectIdParameter2 = ADSchemaObjectIdParameter.Parse(text2);
                    IEnumerable <ADSchemaClassObject> objects3 = adschemaObjectIdParameter2.GetObjects <ADSchemaClassObject>(null, session);
                    using (IEnumerator <ADSchemaClassObject> enumerator3 = objects3.GetEnumerator())
                    {
                        string text4 = null;
                        if (enumerator3.MoveNext())
                        {
                            text4 = enumerator3.Current.Name;
                        }
                        if (text4 != null && !enumerator3.MoveNext())
                        {
                            childObjectTypes = new ADSchemaObjectIdParameter[]
                            {
                                ADSchemaObjectIdParameter.Parse(text4)
                            };
                            flag = true;
                        }
                    }
                    this.ChildObjectTypes = childObjectTypes;
                }
                if ((!flag && (activeDirectoryRights & ActiveDirectoryRights.ReadProperty) == ActiveDirectoryRights.ReadProperty) || (activeDirectoryRights & ActiveDirectoryRights.WriteProperty) == ActiveDirectoryRights.WriteProperty || (activeDirectoryRights & ActiveDirectoryRights.Self) == ActiveDirectoryRights.Self)
                {
                    TaskLogger.Trace("Resolving Property", new object[0]);
                    ADSchemaObjectIdParameter[]           properties = null;
                    ADSchemaObjectIdParameter             adschemaObjectIdParameter3 = ADSchemaObjectIdParameter.Parse(text2);
                    IEnumerable <ADSchemaAttributeObject> objects4 = adschemaObjectIdParameter3.GetObjects <ADSchemaAttributeObject>(null, session);
                    using (IEnumerator <ADSchemaAttributeObject> enumerator4 = objects4.GetEnumerator())
                    {
                        string text5 = null;
                        if (enumerator4.MoveNext())
                        {
                            text5 = enumerator4.Current.Name;
                        }
                        if (text5 == null || enumerator4.MoveNext())
                        {
                            ExtendedRightIdParameter    extendedRightIdParameter2 = ExtendedRightIdParameter.Parse(text2);
                            IEnumerable <ExtendedRight> objects5 = extendedRightIdParameter2.GetObjects <ExtendedRight>(null, session);
                            using (IEnumerator <ExtendedRight> enumerator5 = objects5.GetEnumerator())
                            {
                                string text6 = null;
                                if (enumerator5.MoveNext())
                                {
                                    text6 = enumerator5.Current.Name;
                                }
                                TaskLogger.Trace("Could not resolve the following property: {0}", new object[]
                                {
                                    text2
                                });
                                if (text6 != null && !enumerator5.MoveNext())
                                {
                                    properties = new ADSchemaObjectIdParameter[]
                                    {
                                        ADSchemaObjectIdParameter.Parse(text6)
                                    };
                                }
                                goto IL_3A4;
                            }
                        }
                        properties = new ADSchemaObjectIdParameter[]
                        {
                            ADSchemaObjectIdParameter.Parse(text5)
                        };
                        IL_3A4 :;
                    }
                    this.Properties = properties;
                }
            }
        }