i am stuck to an issue where i have a List ID - list of Ids i have to find the LoginName of SPUser or SPGroup with the id in the ListID
i tried the following but it threws exception as it did not find user when group id is there
foreach (var id in ID)
{
SPUser spUser = web.SiteUsers.GetByID(Convert.ToInt32(id));
if (spUser != null)
{
lstUsers.Add(spUser.LoginName);
continue;
}
SPGroup spGroup = web.SiteGroups.GetByID(Convert.ToInt32(id ));
if (spGroup != null)
{
lstGroups.Add(spGroup.LoginName);
continue;
}
}
please suggest what to do !!!
ID? What users are you trying to get? Any user with permissions on each list item? – Tim Gabrhel Sep 20 '11 at 17:48