diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaClass.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaClass.cs index 9909ce6616036d..baa3c301fa5c9b 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaClass.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaClass.cs @@ -1429,7 +1429,7 @@ private ArrayList GetPropertyValuesRecursively(string[] propertyNames) // get the properties of the auxiliary classes foreach (string auxSchemaClassName in GetValuesFromCache(PropertyManager.AuxiliaryClass)) { - ActiveDirectorySchemaClass auxSchemaClass = new ActiveDirectorySchemaClass(_context, auxSchemaClassName, (DirectoryEntry?)null, null); + using ActiveDirectorySchemaClass auxSchemaClass = new ActiveDirectorySchemaClass(_context, auxSchemaClassName, (DirectoryEntry?)null, null); foreach (string property in auxSchemaClass.GetPropertyValuesRecursively(propertyNames)) { @@ -1441,8 +1441,7 @@ private ArrayList GetPropertyValuesRecursively(string[] propertyNames) } foreach (string auxSchemaClassName in GetValuesFromCache(PropertyManager.SystemAuxiliaryClass)) { - ActiveDirectorySchemaClass auxSchemaClass = new ActiveDirectorySchemaClass(_context, auxSchemaClassName, (DirectoryEntry?)null, null); - + using ActiveDirectorySchemaClass auxSchemaClass = new ActiveDirectorySchemaClass(_context, auxSchemaClassName, (DirectoryEntry?)null, null); foreach (string property in auxSchemaClass.GetPropertyValuesRecursively(propertyNames)) { if (!values.Contains(property))