Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
see all nodes in given ldap node
//my ldap utilities using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; using System.DirectoryServices; using System.IO; namespace Ldap { class LdapStructure { static void Main(string[] args) { int depth; if (args.Length < 2 || string.IsNullOrEmpty(args[0]) || !Int32.TryParse(args[1], out depth) || depth < 0) { Console.WriteLine("\nUsage: <.exe> ldap_node (without LDAP://, but wrapped IN QUOTES!!!) depth [output_file]"); return; } if (args.Length >= 3) using (TextWriter tw = new StreamWriter(args[2])) { EnumerateOU(args[0], depth, tw); } else EnumerateOU(args[0], depth, Console.Out); } public static void EnumerateOU(string OuDn, int depth, TextWriter tw) { try { tw.WriteLine(); using (DirectoryEntry directoryObject = new DirectoryEntry("LDAP://" + OuDn)) { foreach (DirectoryEntry child in directoryObject.Children) ShowChildren(child, "", depth, tw); } } catch (Exception e) { tw.WriteLine("\nAn Error Occurred: " + e.Message.ToString()); } } public static void ShowChildren(DirectoryEntry parent, string print_prefix, int depth, TextWriter tw) { if (depth == 0) return; try { tw.WriteLine("{0} ({1})", print_prefix + parent.Path.ToString().Remove(0, 7), parent.Name); if (depth == 1) return; foreach (DirectoryEntry child in parent.Children) ShowChildren(child, print_prefix + "\t", depth - 1, tw); } catch (Exception e) { tw.WriteLine(e.Message); } finally { parent.Close(); parent.Dispose(); } } } }
run
|
edit
|
history
|
help
0
datetime
Find the count of subsets with given difference
Fibonacci Series
codejam1a1
Melody
J
Abstract Example
ElaineBrown**
30272 Program Ex5 if else
Prism area