public IEnumerable <object> Get()
        {
            return(_context.ListServerAttributes("altServer", "objectClass", "namingContexts",
                                                 "supportedControl", "supportedExtension",
                                                 "supportedLDAPVersion", "supportedSASLMechanisms", "vendorName",
                                                 "vendorVersion", "supportedAuthPasswordSchemes")
                   .Select(SelectProjection)
                   .ToArray());

            //under the covers this actually executes a query that looks something like this:
            //
            //_context.Query(null, SearchScope.Base)
            //        .Where("(objectClass=*)")
            //        .Select("namingContexts", "supportedControl", "supportedExtension", "supportedLDAPVersion",
            //                "supportedSASLMechanisms", "vendorName", "vendorVersion", "supportedAuthPasswordSchemes")
            //        .FirstOrDefault();
            //
            //null or empty naming contexts are not supported using the normal Query method, however.
        }
        private void PopulateData()
        {
            _messenger.Send(new ToggleBusyMessage());
            Task.Run(
                () =>
            {
                return(_context.ListServerAttributes("altServer", "objectClass", "namingContexts",
                                                     "supportedControl", "supportedExtension",
                                                     "supportedLDAPVersion",
                                                     "supportedSASLMechanisms", "vendorName",
                                                     "vendorVersion",
                                                     "supportedAuthPasswordSchemes"));

                /********************************************************************************
                 *      under the covers this actually executes a query that looks something like this:
                 *
                 *      _context.Query(null, SearchScope.Base)
                 *              .Where("(objectClass=*)")
                 *              .Select("namingContexts", "supportedControl", "supportedExtension", "supportedLDAPVersion",
                 *                      "supportedSASLMechanisms", "vendorName", "vendorVersion", "supportedAuthPasswordSchemes")
                 *              .FirstOrDefault();
                 *
                 *      null or empty naming contexts are not supported using the normal Query method, however.
                 *********************************************************************************/
            })
            .ContinueWith(
                t =>
            {
                _messenger.Send(new ToggleBusyMessage());
                if (t.Exception != null)
                {
                    _messenger.Send(new ErrorMessage(t.Exception));
                    return;
                }

                foreach (var directoryAttribute in t.Result)
                {
                    ServerSettings.Add(new KeyValueViewModel(directoryAttribute.Key,
                                                             directoryAttribute.Value));
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
        public void ListServerAttributes()
        {
            var attributes = _context.ListServerAttributes();

            attributes.Should().Not.Be.Null().And.Not.Be.Empty();
        }
 /// <summary>
 /// Executes <see cref="DirectoryContext.ListServerAttributes"/> within a <see cref="Task"/>.
 /// </summary>
 /// <returns></returns>
 public static Task <IDirectoryAttributes> ListServerAttributesAsync(this IDirectoryContext context, params string[] attributes)
 {
     return(Task.Factory.StartNew(() => context.ListServerAttributes(attributes)));
 }