Sometimes we get uniques user id from sharepoint but the requirement is for name.
This can be done in one simple line:
using (SPSite site=new SPSite(siteurl))
{
using (SPWeb web=site.OpenWeb())
{
string userName= web.AllUsers.GetByID(Convert.ToInt32(userid)).Name;
}
}
Line number 5 actually gets the user name by searching all users in the 'web' scope by searching userId.
1 comment:
Fine advice just as what I needed.
Post a Comment