In this article you will see how to create User Profile Sub-Types in SharePoint 2010. User Profile Sub-Types: User properties can be associated to the particular user Profile Sub Type and these sub types allows creating different kinds of User Profiles. Each User Profiles will display different user properties based on the Sub Types. In this you will see how to create User Profile sub types in SharePoint 2010 using SharePoint Object Model. Steps Involved:
class Program { public static void Main(string[] args) { using (SPSite site = new SPSite("https://servername.com/hrp/hrp/")) { //// SPServiceContext class is used to represent a context object that encapsulates all the information that is required to make a call to a user profile service application. SPServiceContext context = SPServiceContext.GetContext(site); ////ProfileSubtypeManager class is used to create, delete, retrieve, and manage profile subtypes for a profile type. ProfileSubtypeManager psm = ProfileSubtypeManager.Get(context);
//// Get the user profile subtype ProfileSubtype subtype=psm.GetProfileSubtype("Finance"); //// Check whether the subtype exists if (subtype == null) { //// create a new user profile subtype //// Finance is the Name of the subtype //// Finance Subtype is the Display name of the subtype psm.CreateSubtype("Finance", "Finance Subtype", ProfileType.User); } else { Console.WriteLine(subtype.DisplayName + " already exists."); Console.ReadLine(); } } } } }
Summary: Thus in this article you have seen how to create User Profile Sub-types using SharePoint object model.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: