V
Vamshi Gopalapuram
Guest
Hi All,
I have been using the below code to get the list of users from active directory for a selected group, this code pulls the details without any issue for the groups with users less than 1500 but gives an error if I select any group with more then 1500 users. Can any one help me how to get past this error.
List<string> usersList = new List<string>();
PrincipalContext principalContext = new PrincipalContext(ContextType.Domain);
GroupPrincipal group = GroupPrincipal.FindByIdentity(principalContext, DropDownList1.SelectedValue);
DataTable dt = new DataTable();
dt.Columns.Add("Description");
dt.Columns.Add("DisplayName");
dt.Columns.Add("SamAccountName");
dt.Columns.Add("DistinguishedName");
dt.AcceptChanges();
foreach (Principal principal in group.Members)
{
usersList.Add(principal.Name);
dt.Rows.Add(principal.Description.ToString(), principal.Name.ToString(), principal.SamAccountName.ToString(),principal.DistinguishedName.ToString());
dt.AcceptChanges();
}
grdViewAllADSUsers.DataSource = dt;
grdViewAllADSUsers.DataBind();
Thanks in advance
Regards,
Vamshi
Continue reading...
I have been using the below code to get the list of users from active directory for a selected group, this code pulls the details without any issue for the groups with users less than 1500 but gives an error if I select any group with more then 1500 users. Can any one help me how to get past this error.
List<string> usersList = new List<string>();
PrincipalContext principalContext = new PrincipalContext(ContextType.Domain);
GroupPrincipal group = GroupPrincipal.FindByIdentity(principalContext, DropDownList1.SelectedValue);
DataTable dt = new DataTable();
dt.Columns.Add("Description");
dt.Columns.Add("DisplayName");
dt.Columns.Add("SamAccountName");
dt.Columns.Add("DistinguishedName");
dt.AcceptChanges();
foreach (Principal principal in group.Members)
{
usersList.Add(principal.Name);
dt.Rows.Add(principal.Description.ToString(), principal.Name.ToString(), principal.SamAccountName.ToString(),principal.DistinguishedName.ToString());
dt.AcceptChanges();
}
grdViewAllADSUsers.DataSource = dt;
grdViewAllADSUsers.DataBind();
Thanks in advance
Regards,
Vamshi
Continue reading...