I want to fetch the AD group users in SharePoint. Below is the code where i can get the SharePoint group. but how can we get AD group
private SPFieldUserValueCollection GetPeopleFromPickerControl(PeopleEditor people, SPWeb web)
{
SPFieldUserValueCollection values = new SPFieldUserValueCollection();
if (people.ResolvedEntities.Count > 0)
{
for (int i = 0; i < people.ResolvedEntities.Count; i++)
{
PickerEntity user = (PickerEntity)people.ResolvedEntities[i];
switch ((string)user.EntityData["PrincipalType"])
{
case "User":
SPUser webUser = web.EnsureUser(user.Key);
SPFieldUserValue userValue = new SPFieldUserValue(web, webUser.ID, webUser.Name);
values.Add(userValue);
break;
case "SharePointGroup":
SPGroup siteGroup = web.SiteGroups[user.EntityData["AccountName"].ToString()];
SPFieldUserValue groupValue = new SPFieldUserValue(web, siteGroup.ID, siteGroup.Name);
values.Add(groupValue);
break;
}
}
}
return values;
}