The LazyItemEnumerable class has a boolean constructor parameter "isLazy" that can be set to false. One would expect the items would be loaded imediatly but this is not the case as the retrieval is specified as a delegate that is used in a Lazy field. This class is used in the ChildrenMapper, EnumerableMapper, ... .
This causes side effects where items are retrieved and mapped to the Glass object in a SecurityDisabler context because the user has no read rights on the item (and child items or items returned by the Query). In the children attribute we specify that this should NOT happen lazy, so we expect the child items to be retrieved and mapped while the root item is cast to Glass within the SecurityDisabler context but this is not the case. So we get an empty collection when we iterate over the items because the current user has no read acces to them.
/// <summary>
/// Initializes a new instance of the <see cref="LazyItemEnumerable{T}"/> class.
/// </summary>
/// <param name="getItems">The get items.</param>
/// <param name="isLazy">if set to <c>true</c> [is lazy].</param>
/// <param name="inferType">if set to <c>true</c> [infer type].</param>
/// <param name="service">The service.</param>
public LazyItemEnumerable(
Func<IEnumerable<Item>> getItems,
bool isLazy,
bool inferType,
ISitecoreService service
)
{
_getItems = getItems;
_type = typeof(T);
_isLazy = isLazy;
_inferType = inferType;
_service = service;
_lazyItemList = new Lazy<IList<T>>(() =>ProcessItems().ToList());
// If not lazy, we could invoke the _lazyItemList here to force the loading of the items.
}