Get all members in OU=Accounts or OU=Archived Users in Active Directory

Get all members in OU=Accounts or OU=Archived Users in Active Directory


Note: To add or read properties from an Active Directory group you need to have special username and password like an Active Directory admin.


tring folderPath = "";
folderPath = "LDAP://OU=Archived Users,DC=aaaaa,DC=com";
DirectoryEntry addGroup;
addGroup = new DirectoryEntry(folderPath, "Spluser""password");
Response.Write("The name is " + addGroup.Name.ToString() +"<br/>");

foreach (DirectoryEntry member in addGroup.Children)
{
 Response.Write(member.Properties["displayName"].Value.ToString() + "<br/>");
}



No comments: