{
RecursiveTraversal rt = new RecursiveTraversal();
string objinner = "";
try{
DirectoryEntry entryRoot = new DirectoryEntry("LDAP://RootDSE");
string dmain = entryRoot.Properties["defaultNamingContext"][0].ToString();
DirectoryEntry entry = new DirectoryEntry ("LDAP://" + dmain);
foreach (DirectoryEntry cd in entry.Children)
{
rt.traverse(cd,0);
}
objinner = "
XmlDocument xm=new XmlDocument();
xm.InnerXml = objinner;
doc = xm;
}
catch (Exception ex)
{
}
return doc;
}
public class RecursiveTraversal
{
public string obj;
public void traverse(DirectoryEntry entry,int x)
{
// Check if it is a OU
if( entry.SchemaClassName=="organizationalUnit" )
{
x++;
// Get a list of all the entries in the directory
obj = obj + "
foreach (DirectoryEntry di in nw.Children)
{
traverse(di, x);
}
obj = obj + "
}
else
{
obj = obj + ">";
obj = obj + " ";
}
}
}
}
No comments:
Post a Comment