public ReadOnlyActiveDirectorySchemaPropertyCollection FindAllProperties(PropertyTypes type)
 {
     base.CheckIfDisposed();
     if (((int)type & -7) == 0)
     {
         StringBuilder stringBuilder = new StringBuilder(25);
         stringBuilder.Append("(&(");
         stringBuilder.Append(PropertyManager.ObjectCategory);
         stringBuilder.Append("=attributeSchema)");
         stringBuilder.Append("(!(");
         stringBuilder.Append(PropertyManager.IsDefunct);
         stringBuilder.Append("=TRUE))");
         if ((type & PropertyTypes.Indexed) != 0)
         {
             stringBuilder.Append("(");
             stringBuilder.Append(PropertyManager.SearchFlags);
             stringBuilder.Append(":1.2.840.113556.1.4.804:=");
             stringBuilder.Append(1);
             stringBuilder.Append(")");
         }
         if ((type & PropertyTypes.InGlobalCatalog) != 0)
         {
             stringBuilder.Append("(");
             stringBuilder.Append(PropertyManager.IsMemberOfPartialAttributeSet);
             stringBuilder.Append("=TRUE)");
         }
         stringBuilder.Append(")");
         return(ActiveDirectorySchema.GetAllProperties(this.context, this.schemaEntry, stringBuilder.ToString()));
     }
     else
     {
         throw new ArgumentException(Res.GetString("InvalidFlags"), "type");
     }
 }
        public ReadOnlyActiveDirectorySchemaClassCollection FindAllClasses()
        {
            base.CheckIfDisposed();
            string[] objectCategory = new string[5];
            objectCategory[0] = "(&(";
            objectCategory[1] = PropertyManager.ObjectCategory;
            objectCategory[2] = "=classSchema)(!(";
            objectCategory[3] = PropertyManager.IsDefunct;
            objectCategory[4] = "=TRUE)))";
            string str = string.Concat(objectCategory);

            return(ActiveDirectorySchema.GetAllClasses(this.context, this.schemaEntry, str));
        }
 public ReadOnlyActiveDirectorySchemaPropertyCollection FindAllProperties()
 {
     base.CheckIfDisposed();
     this.CheckIfDisabled();
     if (this.schema == null)
     {
         string distinguishedName = null;
         try
         {
             distinguishedName = base.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.SchemaNamingContext);
         }
         catch (COMException exception)
         {
             throw ExceptionHelper.GetExceptionFromCOMException(base.context, exception);
         }
         Utils.GetNewDirectoryContext(base.Name, DirectoryContextType.DirectoryServer, base.context);
         this.schema = new ActiveDirectorySchema(base.context, distinguishedName);
     }
     return(this.schema.FindAllProperties(PropertyTypes.InGlobalCatalog));
 }
 public ReadOnlyActiveDirectorySchemaClassCollection FindAllClasses(SchemaClassType type)
 {
     base.CheckIfDisposed();
     if (type < SchemaClassType.Type88 || type > SchemaClassType.Auxiliary)
     {
         throw new InvalidEnumArgumentException("type", (int)type, typeof(SchemaClassType));
     }
     else
     {
         object[] objectCategory = new object[9];
         objectCategory[0] = "(&(";
         objectCategory[1] = PropertyManager.ObjectCategory;
         objectCategory[2] = "=classSchema)(";
         objectCategory[3] = PropertyManager.ObjectClassCategory;
         objectCategory[4] = "=";
         objectCategory[5] = (int)type;
         objectCategory[6] = ")(!(";
         objectCategory[7] = PropertyManager.IsDefunct;
         objectCategory[8] = "=TRUE)))";
         string str = string.Concat(objectCategory);
         return(ActiveDirectorySchema.GetAllClasses(this.context, this.schemaEntry, str));
     }
 }
Example #5
0
        public ReadOnlyActiveDirectorySchemaPropertyCollection FindAllProperties()
        {
            CheckIfDisposed();
            CheckIfDisabled();

            // create an ActiveDirectorySchema object
            if (_schema == null)
            {
                string schemaNC = null;
                try
                {
                    schemaNC = directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.SchemaNamingContext);
                }
                catch (COMException e)
                {
                    throw ExceptionHelper.GetExceptionFromCOMException(context, e);
                }
                DirectoryContext schemaContext = Utils.GetNewDirectoryContext(Name, DirectoryContextType.DirectoryServer, context);
                _schema = new ActiveDirectorySchema(context, schemaNC);
            }

            // return the global catalog replicated properties
            return(_schema.FindAllProperties(PropertyTypes.InGlobalCatalog));
        }
Example #6
0
 public static ActiveDirectorySchema GetCurrentSchema()
 {
     return(ActiveDirectorySchema.GetSchema(new DirectoryContext(DirectoryContextType.Forest)));
 }
        public void Save()
        {
            CheckIfDisposed();

            if (!isBound)
            {
                try
                {
                    // create a new directory entry for this class
                    if (_schemaEntry == null)
                    {
                        _schemaEntry = DirectoryEntryManager.GetDirectoryEntry(_context, WellKnownDN.SchemaNamingContext);
                    }

                    // this will create the class and set the CN value
                    string rdn = "CN=" + _commonName;
                    rdn = Utils.GetEscapedPath(rdn);
                    _classEntry = _schemaEntry.Children.Add(rdn, "classSchema");
                }
                catch (COMException e)
                {
                    throw ExceptionHelper.GetExceptionFromCOMException(_context, e);
                }
                catch (ActiveDirectoryObjectNotFoundException)
                {
                    // this is the case where the context is a config set and we could not find an ADAM instance in that config set
                    throw new ActiveDirectoryOperationException(Res.GetString(Res.ADAMInstanceNotFoundInConfigSet, _context.Name));
                }

                // set the ldap display name property
                SetProperty(PropertyManager.LdapDisplayName, _ldapDisplayName);

                // set the oid value
                SetProperty(PropertyManager.GovernsID, _oid);

                // set the description
                SetProperty(PropertyManager.Description, _description);

                // set the possibleSuperiors property
                if (_possibleSuperiors != null)
                {
                    _classEntry.Properties[PropertyManager.PossibleSuperiors].AddRange(_possibleSuperiors.GetMultiValuedProperty());
                }

                // set the mandatoryProperties property
                if (_mandatoryProperties != null)
                {
                    _classEntry.Properties[PropertyManager.MustContain].AddRange(_mandatoryProperties.GetMultiValuedProperty());
                }

                // set the optionalProperties property
                if (_optionalProperties != null)
                {
                    _classEntry.Properties[PropertyManager.MayContain].AddRange(_optionalProperties.GetMultiValuedProperty());
                }

                // set the subClassOf property
                if (_subClassOf != null)
                {
                    SetProperty(PropertyManager.SubClassOf, _subClassOf.Name);
                }
                else
                {
                    // if no super class is specified, set it to "top"
                    SetProperty(PropertyManager.SubClassOf, "top");
                }

                // set the objectClassCategory property
                SetProperty(PropertyManager.ObjectClassCategory, _type);

                // set the schemaIDGuid property
                if (_schemaGuidBinaryForm != null)
                {
                    SetProperty(PropertyManager.SchemaIDGuid, _schemaGuidBinaryForm);
                }

                // set the default security descriptor
                if (_defaultSDSddlForm != null)
                {
                    SetProperty(PropertyManager.DefaultSecurityDescriptor, _defaultSDSddlForm);
                }
            }

            try
            {
                // commit the classEntry to server
                _classEntry.CommitChanges();

                // Refresh the schema cache on the schema role owner
                if (_schema == null)
                {
                    ActiveDirectorySchema schemaObject = ActiveDirectorySchema.GetSchema(_context);
                    bool alreadyUsingSchemaRoleOwnerContext = false;
                    DirectoryServer schemaRoleOwner = null;

                    try
                    {
                        //
                        // if we are not already talking to the schema role owner, change the context
                        //
                        schemaRoleOwner = schemaObject.SchemaRoleOwner;
                        if (Utils.Compare(schemaRoleOwner.Name, _context.GetServerName()) != 0)
                        {
                            DirectoryContext schemaRoleOwnerContext = Utils.GetNewDirectoryContext(schemaRoleOwner.Name, DirectoryContextType.DirectoryServer, _context);
                            _schema = ActiveDirectorySchema.GetSchema(schemaRoleOwnerContext);
                        }
                        else
                        {
                            alreadyUsingSchemaRoleOwnerContext = true;
                            _schema = schemaObject;
                        }
                    }
                    finally
                    {
                        if (schemaRoleOwner != null)
                        {
                            schemaRoleOwner.Dispose();
                        }
                        if (!alreadyUsingSchemaRoleOwnerContext)
                        {
                            schemaObject.Dispose();
                        }
                    }
                }
                _schema.RefreshSchema();
            }
            catch (COMException e)
            {
                throw ExceptionHelper.GetExceptionFromCOMException(_context, e);
            }

            // now that the changes are committed to the server
            // update the defunct/non-defunct status of the class on the server
            _isDefunctOnServer = _isDefunct;

            // invalidate all properties
            _commonName = null;
            _oid = null;
            _description = null;
            _descriptionInitialized = false;
            _possibleSuperiors = null;
            _auxiliaryClasses = null;
            _possibleInferiors = null;
            _mandatoryProperties = null;
            _optionalProperties = null;
            _subClassOf = null;
            _typeInitialized = false;
            _schemaGuidBinaryForm = null;
            _defaultSDSddlForm = null;
            _defaultSDSddlFormInitialized = false;
            _propertiesFromSchemaContainerInitialized = false;

            // set bind flag
            isBound = true;
        }
Example #8
0
		public ReadOnlyActiveDirectorySchemaPropertyCollection FindAllProperties()
		{
			base.CheckIfDisposed();
			this.CheckIfDisabled();
			if (this.schema == null)
			{
				string str = null;
				try
				{
					str = this.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.SchemaNamingContext);
				}
				catch (COMException cOMException1)
				{
					COMException cOMException = cOMException1;
					throw ExceptionHelper.GetExceptionFromCOMException(this.context, cOMException);
				}
				Utils.GetNewDirectoryContext(base.Name, DirectoryContextType.DirectoryServer, this.context);
				this.schema = new ActiveDirectorySchema(this.context, str);
			}
			return this.schema.FindAllProperties(PropertyTypes.InGlobalCatalog);
		}
 public void Save()
 {
     this.CheckIfDisposed();
     if (!this.isBound)
     {
         try
         {
             if (this.schemaEntry == null)
             {
                 this.schemaEntry = DirectoryEntryManager.GetDirectoryEntry(this.context, WellKnownDN.SchemaNamingContext);
             }
             string escapedPath = Utils.GetEscapedPath("CN=" + this.commonName);
             this.propertyEntry = this.schemaEntry.Children.Add(escapedPath, "attributeSchema");
         }
         catch (COMException exception)
         {
             throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception);
         }
         catch (ActiveDirectoryObjectNotFoundException)
         {
             throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", new object[] { this.context.Name }));
         }
         this.SetProperty(PropertyManager.LdapDisplayName, this.ldapDisplayName);
         this.SetProperty(PropertyManager.AttributeID, this.oid);
         if (this.syntax != ~ActiveDirectorySyntax.CaseExactString)
         {
             this.SetSyntax(this.syntax);
         }
         this.SetProperty(PropertyManager.Description, this.description);
         this.propertyEntry.Properties[PropertyManager.IsSingleValued].Value = this.isSingleValued;
         this.propertyEntry.Properties[PropertyManager.IsMemberOfPartialAttributeSet].Value = this.isInGlobalCatalog;
         this.propertyEntry.Properties[PropertyManager.IsDefunct].Value = this.isDefunct;
         if (this.rangeLower.HasValue)
         {
             this.propertyEntry.Properties[PropertyManager.RangeLower].Value = this.rangeLower.Value;
         }
         if (this.rangeUpper.HasValue)
         {
             this.propertyEntry.Properties[PropertyManager.RangeUpper].Value = this.rangeUpper.Value;
         }
         if (this.searchFlags != SearchFlags.None)
         {
             this.propertyEntry.Properties[PropertyManager.SearchFlags].Value = (int) this.searchFlags;
         }
         if (this.linkId.HasValue)
         {
             this.propertyEntry.Properties[PropertyManager.LinkID].Value = this.linkId.Value;
         }
         if (this.schemaGuidBinaryForm != null)
         {
             this.SetProperty(PropertyManager.SchemaIDGuid, this.schemaGuidBinaryForm);
         }
     }
     try
     {
         this.propertyEntry.CommitChanges();
         if (this.schema == null)
         {
             ActiveDirectorySchema schema = ActiveDirectorySchema.GetSchema(this.context);
             bool flag = false;
             DirectoryServer schemaRoleOwner = null;
             try
             {
                 schemaRoleOwner = schema.SchemaRoleOwner;
                 if (Utils.Compare(schemaRoleOwner.Name, this.context.GetServerName()) != 0)
                 {
                     DirectoryContext context = Utils.GetNewDirectoryContext(schemaRoleOwner.Name, DirectoryContextType.DirectoryServer, this.context);
                     this.schema = ActiveDirectorySchema.GetSchema(context);
                 }
                 else
                 {
                     flag = true;
                     this.schema = schema;
                 }
             }
             finally
             {
                 if (schemaRoleOwner != null)
                 {
                     schemaRoleOwner.Dispose();
                 }
                 if (!flag)
                 {
                     schema.Dispose();
                 }
             }
         }
         this.schema.RefreshSchema();
     }
     catch (COMException exception2)
     {
         throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception2);
     }
     this.isDefunctOnServer = this.isDefunct;
     this.commonName = null;
     this.oid = null;
     this.syntaxInitialized = false;
     this.descriptionInitialized = false;
     this.isSingleValuedInitialized = false;
     this.isInGlobalCatalogInitialized = false;
     this.rangeLowerInitialized = false;
     this.rangeUpperInitialized = false;
     this.searchFlagsInitialized = false;
     this.linkedPropertyInitialized = false;
     this.linkIdInitialized = false;
     this.schemaGuidBinaryForm = null;
     this.propertiesFromSchemaContainerInitialized = false;
     this.isBound = true;
 }
 public void Save()
 {
     this.CheckIfDisposed();
     if (!this.isBound)
     {
         try
         {
             if (this.schemaEntry == null)
             {
                 this.schemaEntry = DirectoryEntryManager.GetDirectoryEntry(this.context, WellKnownDN.SchemaNamingContext);
             }
             string escapedPath = Utils.GetEscapedPath("CN=" + this.commonName);
             this.classEntry = this.schemaEntry.Children.Add(escapedPath, "classSchema");
         }
         catch (COMException exception)
         {
             throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception);
         }
         catch (ActiveDirectoryObjectNotFoundException)
         {
             throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", new object[] { this.context.Name }));
         }
         this.SetProperty(PropertyManager.LdapDisplayName, this.ldapDisplayName);
         this.SetProperty(PropertyManager.GovernsID, this.oid);
         this.SetProperty(PropertyManager.Description, this.description);
         if (this.possibleSuperiors != null)
         {
             this.classEntry.Properties[PropertyManager.PossibleSuperiors].AddRange(this.possibleSuperiors.GetMultiValuedProperty());
         }
         if (this.mandatoryProperties != null)
         {
             this.classEntry.Properties[PropertyManager.MustContain].AddRange(this.mandatoryProperties.GetMultiValuedProperty());
         }
         if (this.optionalProperties != null)
         {
             this.classEntry.Properties[PropertyManager.MayContain].AddRange(this.optionalProperties.GetMultiValuedProperty());
         }
         if (this.subClassOf != null)
         {
             this.SetProperty(PropertyManager.SubClassOf, this.subClassOf.Name);
         }
         else
         {
             this.SetProperty(PropertyManager.SubClassOf, "top");
         }
         this.SetProperty(PropertyManager.ObjectClassCategory, this.type);
         if (this.schemaGuidBinaryForm != null)
         {
             this.SetProperty(PropertyManager.SchemaIDGuid, this.schemaGuidBinaryForm);
         }
         if (this.defaultSDSddlForm != null)
         {
             this.SetProperty(PropertyManager.DefaultSecurityDescriptor, this.defaultSDSddlForm);
         }
     }
     try
     {
         this.classEntry.CommitChanges();
         if (this.schema == null)
         {
             ActiveDirectorySchema schema = ActiveDirectorySchema.GetSchema(this.context);
             bool flag = false;
             DirectoryServer schemaRoleOwner = null;
             try
             {
                 schemaRoleOwner = schema.SchemaRoleOwner;
                 if (Utils.Compare(schemaRoleOwner.Name, this.context.GetServerName()) != 0)
                 {
                     DirectoryContext context = Utils.GetNewDirectoryContext(schemaRoleOwner.Name, DirectoryContextType.DirectoryServer, this.context);
                     this.schema = ActiveDirectorySchema.GetSchema(context);
                 }
                 else
                 {
                     flag = true;
                     this.schema = schema;
                 }
             }
             finally
             {
                 if (schemaRoleOwner != null)
                 {
                     schemaRoleOwner.Dispose();
                 }
                 if (!flag)
                 {
                     schema.Dispose();
                 }
             }
         }
         this.schema.RefreshSchema();
     }
     catch (COMException exception2)
     {
         throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception2);
     }
     this.isDefunctOnServer = this.isDefunct;
     this.commonName = null;
     this.oid = null;
     this.description = null;
     this.descriptionInitialized = false;
     this.possibleSuperiors = null;
     this.auxiliaryClasses = null;
     this.possibleInferiors = null;
     this.mandatoryProperties = null;
     this.optionalProperties = null;
     this.subClassOf = null;
     this.typeInitialized = false;
     this.schemaGuidBinaryForm = null;
     this.defaultSDSddlForm = null;
     this.defaultSDSddlFormInitialized = false;
     this.propertiesFromSchemaContainerInitialized = false;
     this.isBound = true;
 }
Example #11
0
 public void Save()
 {
     this.CheckIfDisposed();
     if (!this.isBound)
     {
         try
         {
             if (this.schemaEntry == null)
             {
                 this.schemaEntry = DirectoryEntryManager.GetDirectoryEntry(this.context, WellKnownDN.SchemaNamingContext);
             }
             string escapedPath = Utils.GetEscapedPath("CN=" + this.commonName);
             this.classEntry = this.schemaEntry.Children.Add(escapedPath, "classSchema");
         }
         catch (COMException exception)
         {
             throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception);
         }
         catch (ActiveDirectoryObjectNotFoundException)
         {
             throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", new object[] { this.context.Name }));
         }
         this.SetProperty(PropertyManager.LdapDisplayName, this.ldapDisplayName);
         this.SetProperty(PropertyManager.GovernsID, this.oid);
         this.SetProperty(PropertyManager.Description, this.description);
         if (this.possibleSuperiors != null)
         {
             this.classEntry.Properties[PropertyManager.PossibleSuperiors].AddRange(this.possibleSuperiors.GetMultiValuedProperty());
         }
         if (this.mandatoryProperties != null)
         {
             this.classEntry.Properties[PropertyManager.MustContain].AddRange(this.mandatoryProperties.GetMultiValuedProperty());
         }
         if (this.optionalProperties != null)
         {
             this.classEntry.Properties[PropertyManager.MayContain].AddRange(this.optionalProperties.GetMultiValuedProperty());
         }
         if (this.subClassOf != null)
         {
             this.SetProperty(PropertyManager.SubClassOf, this.subClassOf.Name);
         }
         else
         {
             this.SetProperty(PropertyManager.SubClassOf, "top");
         }
         this.SetProperty(PropertyManager.ObjectClassCategory, this.type);
         if (this.schemaGuidBinaryForm != null)
         {
             this.SetProperty(PropertyManager.SchemaIDGuid, this.schemaGuidBinaryForm);
         }
         if (this.defaultSDSddlForm != null)
         {
             this.SetProperty(PropertyManager.DefaultSecurityDescriptor, this.defaultSDSddlForm);
         }
     }
     try
     {
         this.classEntry.CommitChanges();
         if (this.schema == null)
         {
             ActiveDirectorySchema schema    = ActiveDirectorySchema.GetSchema(this.context);
             bool            flag            = false;
             DirectoryServer schemaRoleOwner = null;
             try
             {
                 schemaRoleOwner = schema.SchemaRoleOwner;
                 if (Utils.Compare(schemaRoleOwner.Name, this.context.GetServerName()) != 0)
                 {
                     DirectoryContext context = Utils.GetNewDirectoryContext(schemaRoleOwner.Name, DirectoryContextType.DirectoryServer, this.context);
                     this.schema = ActiveDirectorySchema.GetSchema(context);
                 }
                 else
                 {
                     flag        = true;
                     this.schema = schema;
                 }
             }
             finally
             {
                 if (schemaRoleOwner != null)
                 {
                     schemaRoleOwner.Dispose();
                 }
                 if (!flag)
                 {
                     schema.Dispose();
                 }
             }
         }
         this.schema.RefreshSchema();
     }
     catch (COMException exception2)
     {
         throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception2);
     }
     this.isDefunctOnServer = this.isDefunct;
     this.commonName        = null;
     this.oid                                      = null;
     this.description                              = null;
     this.descriptionInitialized                   = false;
     this.possibleSuperiors                        = null;
     this.auxiliaryClasses                         = null;
     this.possibleInferiors                        = null;
     this.mandatoryProperties                      = null;
     this.optionalProperties                       = null;
     this.subClassOf                               = null;
     this.typeInitialized                          = false;
     this.schemaGuidBinaryForm                     = null;
     this.defaultSDSddlForm                        = null;
     this.defaultSDSddlFormInitialized             = false;
     this.propertiesFromSchemaContainerInitialized = false;
     this.isBound                                  = true;
 }
		public void Save()
		{
			this.CheckIfDisposed();
			if (!this.isBound)
			{
				try
				{
					if (this.schemaEntry == null)
					{
						this.schemaEntry = DirectoryEntryManager.GetDirectoryEntry(this.context, WellKnownDN.SchemaNamingContext);
					}
					string escapedPath = string.Concat("CN=", this.commonName);
					escapedPath = Utils.GetEscapedPath(escapedPath);
					this.propertyEntry = this.schemaEntry.Children.Add(escapedPath, "attributeSchema");
				}
				catch (COMException cOMException1)
				{
					COMException cOMException = cOMException1;
					throw ExceptionHelper.GetExceptionFromCOMException(this.context, cOMException);
				}
				catch (ActiveDirectoryObjectNotFoundException activeDirectoryObjectNotFoundException)
				{
					object[] name = new object[1];
					name[0] = this.context.Name;
					throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", name));
				}
				this.SetProperty(PropertyManager.LdapDisplayName, this.ldapDisplayName);
				this.SetProperty(PropertyManager.AttributeID, this.oid);
				if (this.syntax != (ActiveDirectorySyntax.CaseIgnoreString | ActiveDirectorySyntax.NumericString | ActiveDirectorySyntax.DirectoryString | ActiveDirectorySyntax.OctetString | ActiveDirectorySyntax.SecurityDescriptor | ActiveDirectorySyntax.Int | ActiveDirectorySyntax.Int64 | ActiveDirectorySyntax.Bool | ActiveDirectorySyntax.Oid | ActiveDirectorySyntax.GeneralizedTime | ActiveDirectorySyntax.UtcTime | ActiveDirectorySyntax.DN | ActiveDirectorySyntax.DNWithBinary | ActiveDirectorySyntax.DNWithString | ActiveDirectorySyntax.Enumeration | ActiveDirectorySyntax.IA5String | ActiveDirectorySyntax.PrintableString | ActiveDirectorySyntax.Sid | ActiveDirectorySyntax.AccessPointDN | ActiveDirectorySyntax.ORName | ActiveDirectorySyntax.PresentationAddress | ActiveDirectorySyntax.ReplicaLink))
				{
					this.SetSyntax(this.syntax);
				}
				this.SetProperty(PropertyManager.Description, this.description);
				this.propertyEntry.Properties[PropertyManager.IsSingleValued].Value = this.isSingleValued;
				this.propertyEntry.Properties[PropertyManager.IsMemberOfPartialAttributeSet].Value = this.isInGlobalCatalog;
				this.propertyEntry.Properties[PropertyManager.IsDefunct].Value = this.isDefunct;
				if (this.rangeLower.HasValue)
				{
					this.propertyEntry.Properties[PropertyManager.RangeLower].Value = this.rangeLower.Value;
				}
				if (this.rangeUpper.HasValue)
				{
					this.propertyEntry.Properties[PropertyManager.RangeUpper].Value = this.rangeUpper.Value;
				}
				if (this.searchFlags != SearchFlags.None)
				{
					this.propertyEntry.Properties[PropertyManager.SearchFlags].Value = (int)this.searchFlags;
				}
				if (this.linkId.HasValue)
				{
					this.propertyEntry.Properties[PropertyManager.LinkID].Value = this.linkId.Value;
				}
				if (this.schemaGuidBinaryForm != null)
				{
					this.SetProperty(PropertyManager.SchemaIDGuid, this.schemaGuidBinaryForm);
				}
			}
			try
			{
				this.propertyEntry.CommitChanges();
				if (this.schema == null)
				{
					ActiveDirectorySchema schema = ActiveDirectorySchema.GetSchema(this.context);
					bool flag = false;
					DirectoryServer schemaRoleOwner = null;
					try
					{
						schemaRoleOwner = schema.SchemaRoleOwner;
						if (Utils.Compare(schemaRoleOwner.Name, this.context.GetServerName()) == 0)
						{
							flag = true;
							this.schema = schema;
						}
						else
						{
							DirectoryContext newDirectoryContext = Utils.GetNewDirectoryContext(schemaRoleOwner.Name, DirectoryContextType.DirectoryServer, this.context);
							this.schema = ActiveDirectorySchema.GetSchema(newDirectoryContext);
						}
					}
					finally
					{
						if (schemaRoleOwner != null)
						{
							schemaRoleOwner.Dispose();
						}
						if (!flag)
						{
							schema.Dispose();
						}
					}
				}
				this.schema.RefreshSchema();
			}
			catch (COMException cOMException3)
			{
				COMException cOMException2 = cOMException3;
				throw ExceptionHelper.GetExceptionFromCOMException(this.context, cOMException2);
			}
			this.isDefunctOnServer = this.isDefunct;
			this.commonName = null;
			this.oid = null;
			this.syntaxInitialized = false;
			this.descriptionInitialized = false;
			this.isSingleValuedInitialized = false;
			this.isInGlobalCatalogInitialized = false;
			this.rangeLowerInitialized = false;
			this.rangeUpperInitialized = false;
			this.searchFlagsInitialized = false;
			this.linkedPropertyInitialized = false;
			this.linkIdInitialized = false;
			this.schemaGuidBinaryForm = null;
			this.propertiesFromSchemaContainerInitialized = false;
			this.isBound = true;
		}
        public void Save()
        {
            CheckIfDisposed();

            if (!isBound)
            {
                try
                {
                    // create a new directory entry for this class
                    if (_schemaEntry == null)
                    {
                        _schemaEntry = DirectoryEntryManager.GetDirectoryEntry(_context, WellKnownDN.SchemaNamingContext);
                    }

                    // this will create the class and set the CN value
                    string rdn = "CN=" + _commonName;
                    rdn = Utils.GetEscapedPath(rdn);
                    _propertyEntry = _schemaEntry.Children.Add(rdn, "attributeSchema");
                }
                catch (COMException e)
                {
                    throw ExceptionHelper.GetExceptionFromCOMException(_context, e);
                }
                catch (ActiveDirectoryObjectNotFoundException)
                {
                    // this is the case where the context is a config set and we could not find an ADAM instance in that config set
                    throw new ActiveDirectoryOperationException(Res.GetString(Res.ADAMInstanceNotFoundInConfigSet, _context.Name));
                }

                // set the ldap display name property
                SetProperty(PropertyManager.LdapDisplayName, _ldapDisplayName);

                // set the oid value
                SetProperty(PropertyManager.AttributeID, _oid);

                // set the syntax
                if (_syntax != (ActiveDirectorySyntax)(-1))
                {
                    SetSyntax(_syntax);
                }

                // set the description
                SetProperty(PropertyManager.Description, _description);

                // set the isSingleValued attribute
                _propertyEntry.Properties[PropertyManager.IsSingleValued].Value = _isSingleValued;

                // set the isGlobalCatalogReplicated attribute
                _propertyEntry.Properties[PropertyManager.IsMemberOfPartialAttributeSet].Value = _isInGlobalCatalog;

                // set the isDefunct attribute
                _propertyEntry.Properties[PropertyManager.IsDefunct].Value = _isDefunct;

                // set the range lower attribute
                if (_rangeLower != null)
                {
                    _propertyEntry.Properties[PropertyManager.RangeLower].Value = (int)_rangeLower.Value;
                }

                // set the range upper attribute
                if (_rangeUpper != null)
                {
                    _propertyEntry.Properties[PropertyManager.RangeUpper].Value = (int)_rangeUpper.Value;
                }

                // set the searchFlags attribute
                if (_searchFlags != SearchFlags.None)
                {
                    _propertyEntry.Properties[PropertyManager.SearchFlags].Value = (int)_searchFlags;
                }

                // set the link id
                if (_linkId != null)
                {
                    _propertyEntry.Properties[PropertyManager.LinkID].Value = (int)_linkId.Value;
                }

                // set the schemaIDGuid property
                if (_schemaGuidBinaryForm != null)
                {
                    SetProperty(PropertyManager.SchemaIDGuid, _schemaGuidBinaryForm);
                }
            }

            try
            {
                // commit the classEntry to server
                _propertyEntry.CommitChanges();

                // Refresh the schema cache on the schema role owner
                if (_schema == null)
                {
                    ActiveDirectorySchema schemaObject = ActiveDirectorySchema.GetSchema(_context);
                    bool alreadyUsingSchemaRoleOwnerContext = false;
                    DirectoryServer schemaRoleOwner = null;

                    try
                    {
                        //
                        // if we are not already talking to the schema role owner, change the context
                        //
                        schemaRoleOwner = schemaObject.SchemaRoleOwner;
                        if (Utils.Compare(schemaRoleOwner.Name, _context.GetServerName()) != 0)
                        {
                            DirectoryContext schemaRoleOwnerContext = Utils.GetNewDirectoryContext(schemaRoleOwner.Name, DirectoryContextType.DirectoryServer, _context);
                            _schema = ActiveDirectorySchema.GetSchema(schemaRoleOwnerContext);
                        }
                        else
                        {
                            alreadyUsingSchemaRoleOwnerContext = true;
                            _schema = schemaObject;
                        }
                    }
                    finally
                    {
                        if (schemaRoleOwner != null)
                        {
                            schemaRoleOwner.Dispose();
                        }
                        if (!alreadyUsingSchemaRoleOwnerContext)
                        {
                            schemaObject.Dispose();
                        }
                    }
                }
                _schema.RefreshSchema();
            }
            catch (COMException e)
            {
                throw ExceptionHelper.GetExceptionFromCOMException(_context, e);
            }

            // now that the changes are committed to the server
            // update the defunct/non-defunct status of the class on the server
            _isDefunctOnServer = _isDefunct;

            // invalidate all properties
            _commonName = null;
            _oid = null;
            _syntaxInitialized = false;
            _descriptionInitialized = false;
            _isSingleValuedInitialized = false;
            _isInGlobalCatalogInitialized = false;
            _rangeLowerInitialized = false;
            _rangeUpperInitialized = false;
            _searchFlagsInitialized = false;
            _linkedPropertyInitialized = false;
            _linkIdInitialized = false;
            _schemaGuidBinaryForm = null;
            _propertiesFromSchemaContainerInitialized = false;

            // set bind flag
            isBound = true;
        }
 public void Save()
 {
     this.CheckIfDisposed();
     if (!this.isBound)
     {
         try
         {
             if (this.schemaEntry == null)
             {
                 this.schemaEntry = DirectoryEntryManager.GetDirectoryEntry(this.context, WellKnownDN.SchemaNamingContext);
             }
             string escapedPath = Utils.GetEscapedPath("CN=" + this.commonName);
             this.propertyEntry = this.schemaEntry.Children.Add(escapedPath, "attributeSchema");
         }
         catch (COMException exception)
         {
             throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception);
         }
         catch (ActiveDirectoryObjectNotFoundException)
         {
             throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", new object[] { this.context.Name }));
         }
         this.SetProperty(PropertyManager.LdapDisplayName, this.ldapDisplayName);
         this.SetProperty(PropertyManager.AttributeID, this.oid);
         if (this.syntax != ~ActiveDirectorySyntax.CaseExactString)
         {
             this.SetSyntax(this.syntax);
         }
         this.SetProperty(PropertyManager.Description, this.description);
         this.propertyEntry.Properties[PropertyManager.IsSingleValued].Value = this.isSingleValued;
         this.propertyEntry.Properties[PropertyManager.IsMemberOfPartialAttributeSet].Value = this.isInGlobalCatalog;
         this.propertyEntry.Properties[PropertyManager.IsDefunct].Value = this.isDefunct;
         if (this.rangeLower.HasValue)
         {
             this.propertyEntry.Properties[PropertyManager.RangeLower].Value = this.rangeLower.Value;
         }
         if (this.rangeUpper.HasValue)
         {
             this.propertyEntry.Properties[PropertyManager.RangeUpper].Value = this.rangeUpper.Value;
         }
         if (this.searchFlags != SearchFlags.None)
         {
             this.propertyEntry.Properties[PropertyManager.SearchFlags].Value = (int)this.searchFlags;
         }
         if (this.linkId.HasValue)
         {
             this.propertyEntry.Properties[PropertyManager.LinkID].Value = this.linkId.Value;
         }
         if (this.schemaGuidBinaryForm != null)
         {
             this.SetProperty(PropertyManager.SchemaIDGuid, this.schemaGuidBinaryForm);
         }
     }
     try
     {
         this.propertyEntry.CommitChanges();
         if (this.schema == null)
         {
             ActiveDirectorySchema schema    = ActiveDirectorySchema.GetSchema(this.context);
             bool            flag            = false;
             DirectoryServer schemaRoleOwner = null;
             try
             {
                 schemaRoleOwner = schema.SchemaRoleOwner;
                 if (Utils.Compare(schemaRoleOwner.Name, this.context.GetServerName()) != 0)
                 {
                     DirectoryContext context = Utils.GetNewDirectoryContext(schemaRoleOwner.Name, DirectoryContextType.DirectoryServer, this.context);
                     this.schema = ActiveDirectorySchema.GetSchema(context);
                 }
                 else
                 {
                     flag        = true;
                     this.schema = schema;
                 }
             }
             finally
             {
                 if (schemaRoleOwner != null)
                 {
                     schemaRoleOwner.Dispose();
                 }
                 if (!flag)
                 {
                     schema.Dispose();
                 }
             }
         }
         this.schema.RefreshSchema();
     }
     catch (COMException exception2)
     {
         throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception2);
     }
     this.isDefunctOnServer = this.isDefunct;
     this.commonName        = null;
     this.oid = null;
     this.syntaxInitialized                        = false;
     this.descriptionInitialized                   = false;
     this.isSingleValuedInitialized                = false;
     this.isInGlobalCatalogInitialized             = false;
     this.rangeLowerInitialized                    = false;
     this.rangeUpperInitialized                    = false;
     this.searchFlagsInitialized                   = false;
     this.linkedPropertyInitialized                = false;
     this.linkIdInitialized                        = false;
     this.schemaGuidBinaryForm                     = null;
     this.propertiesFromSchemaContainerInitialized = false;
     this.isBound = true;
 }