Beispiel #1
0
        private void ListAttributes(SearchResultCollection results, string[] attrs)
        {
            Dictionary <string, Object>[] attributedResults = new Dictionary <string, object> [results.Count];
            for (int i = 0; i < results.Count; i++)
            {
                attributedResults[i] = new Dictionary <string, object>();
                DirectoryEntry userEntry = results[i].GetDirectoryEntry();
                foreach (string key in attrs)
                {
                    attributedResults[i].Add(key, userEntry.Properties[key].Value);
                }
            }

            if (!this.m_json)
            {
                int formatLen = OutputFormatting.GetFormatLenSpecifier(attributedResults[0].Keys.ToArray <string>());
                foreach (Dictionary <string, Object> attributedResult in attributedResults)
                {
                    foreach (KeyValuePair <string, object> kvp in attributedResult)
                    {
                        OutputFormatting.PrintSuccess(String.Format("{0,-" + formatLen + "} : {1}", kvp.Key, kvp.Value.ToString()), 1);
                    }
                }
            }
            else
            {
                OutputFormatting.PrintJson(attributedResults);
            }
        }
Beispiel #2
0
 private void ListAll(SearchResultCollection results)
 {
     if (this.m_json)
     {
         OutputFormatting.PrintJson(results);
     }
     else
     {
         foreach (SearchResult result in results)
         {
             DirectoryEntry userEntry = result.GetDirectoryEntry();
             OutputFormatting.PrintADProperties(userEntry);
         }
     }
 }