Get full name by log in name in sharepoint 2010

Is there an easy way to retrieve fullname e.g "John Smith" from its login name "j.smith" in sharepoint? Ive been ages looking for that code.

I have this code:

   string strName = SPUtility.GetAccountName("j.smith");

Where strName should be my fullname and "j.smith" is my login name. I dont think its correct..any advice from sharepoint masters out there?


If the user whose full name needs to be fetched is already added to the site or it is Ok that the user be added to the site you can use :


Alternatively you can use User profile service and get the full name of the user from his user profile if the user is not added to the site and you do not want to add that user to the site.

 SPServiceContext context = SPServiceContext.GetContext(site);
 UserProfileManager upm = new UserProfileManager(context);
 UserProfile profile = upm.GetUserProfile(@"zsdev\ia"); 

Need Your Help

Mimicking the behavior of HTML5 pattern attributes for inputs using web2py?

python html5 web2py web2py-modules

I'm looking to validate all of my forms with HTML5 and the pattern attribute, but as always, nothing is perfect on the internet and I still need a backup to catch those users who do not use HTML5

Problems updating new ruby version

ruby install rvm patch

I tried to install a new ruby version with rvm on my mac. There were several problems why I choosed to reinstall everything.