get users in an OU in active directory and then populate all of it in gridview.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi There,
I am new to C# Asp.Net. and i have a project. A part of my project is to populate a gridview with all the users of an OU in Active Directory. here is what i got.
public GroupPrincipal GetGroup(string sGroupName)
{
PrincipalContext oPrincipalContext = GetPrincipalContext();

GroupPrincipal oGroupPrincipal = GroupPrincipal.FindByIdentity(oPrincipalContext, sGroupName);
if (oGroupPrincipal.Name.ToString() == null)
{
lblGroupName.Text = "None";

}
else
{
foreach (Principal p in oGroupPrincipal.GetMembers(true))
{

//here is where i got stucked. I think i need to create a datatable here and populate my gridview
// using the dt. but i dont know how to.

}


lblGroupName.Text = oGroupPrincipal.Name.ToString();
}

return oGroupPrincipal;

}

Thanks in advance Guys!

View the full article
 
Back
Top