/// <devdoc>
        /// Returns an enumerator, which can be used to iterate through the collection.
        /// </devdoc>
        public IDictionaryEnumerator GetEnumerator()
        {
            if (!(_entry.AdsObject is UnsafeNativeMethods.IAdsPropertyList))
            {
                throw new NotSupportedException(SR.DSCannotEmunerate);
            }

            // Once an object has been used for an enumerator once, it can't be used again, because it only
            // maintains a single cursor. Re-bind to the ADSI object to get a new instance.
            // That's why we must clone entry here. It will be automatically disposed inside Enumerator.
            DirectoryEntry entryToUse = _entry.CloneBrowsable();

            entryToUse.FillCache("");

            _ = (UnsafeNativeMethods.IAdsPropertyList)entryToUse.AdsObject;

            entryToUse.propertiesAlreadyEnumerated = true;
            return(new PropertyEnumerator(_entry, entryToUse));
        }