public DirectoryQueryTests()
        {
            _workDirectory = Path.Combine(Directory.GetCurrentDirectory(), _workDirectoryName);
            DirectoryInfo di = new DirectoryInfo(_workDirectory);
            if (!di.Exists)
            {
                di.Create();
            }

            _directoryQuery = new DirectoryQuery(_workDirectory);
        }
        /// <summary>
        /// List server information from RootDSE.
        /// </summary>
        /// <param name="connection">The connection to the directory.</param>
        /// <param name="log">The log for query information. Defaults to null.</param>
        /// <param name="attributes">
        /// Specify specific attributes to load.  Some LDAP servers require an explicit request for certain attributes.
        /// </param>
        /// <param name="resultProcessing">How the async results are processed</param>
        /// <returns></returns>
        public static async Task <IDirectoryAttributes> ListServerAttributesAsync(this LdapConnection connection, string[] attributes = null, ILinqToLdapLogger log = null,
                                                                                  PartialResultProcessing resultProcessing            = LdapConfiguration.DefaultAsyncResultProcessing)
        {
            try
            {
                if (connection == null)
                {
                    throw new ArgumentNullException("connection");
                }
                using (var provider = new DirectoryQueryProvider(
                           connection, SearchScope.Base, new ServerObjectMapping(), false)
                {
                    Log = log, IsDynamic = true
                })
                {
                    var directoryQuery = new DirectoryQuery <IDirectoryAttributes>(provider);

                    var query = directoryQuery
                                .FilterWith("(objectClass=*)");

                    if (attributes?.Length > 0)
                    {
                        query = query.Select(attributes);
                    }

                    var results = await QueryableAsyncExtensions.FirstOrDefaultAsync(query, resultProcessing).ConfigureAwait(false);

                    return(results ?? new DirectoryAttributes());
                }
            }
            catch (Exception ex)
            {
                if (log != null)
                {
                    log.Error(ex);
                }
                throw;
            }
        }
 public FileSystemWidgetContext(string contextString)
     : base(contextString)
 {
     _fileQuery = new FileQuery(base.ContextString);
     _directoryQuery = new DirectoryQuery(base.ContextString);
 }