Saturday, August 25, 2012

How to create Profile programmatically in sharepoint 2010

In this post i will given a code to create profile in share point 2010 .Here i have used Userprofilemanager class to do this.Then using this i will check the the whether the user name is exist or not.If it is not exit ,it will create as user profile
using (SPSite sc = new SPSite(SPContext.Current.Site.Url))
{
SPServiceContext c = SPServiceContext.GetContext(sc);
UserProfileManager upm = new UserProfileManager(c);
SPUser su = sc.RootWeb.CurrentUser;
if (!upm.UserExists(su.LoginName))
{
upm.CreateUserProfile(su.LoginName);
}
}

1 comment:

blogger said...

nice blog checkout my latest blog at

http://www.togetherfornature.blogspot.com

feel free to leave a comment

Bel