Here when i am creating a new custom section it is showing error as Adding a property definition requires Manage User Profiles rights in the code CoreProperty cp = cpm.Create(true); how to solve this problem please help..?
SPSite site = new SPSite("localhost");
SPServiceContext context = SPServiceContext.GetContext(site);
UserProfileConfigManager upcm = new UserProfileConfigManager(context);
ProfilePropertyManager ppm = upcm.ProfilePropertyManager;
CorePropertyManager cpm = ppm.GetCoreProperties();
if (cpm.GetSectionByName(propertyname) == null)
{
**CoreProperty cp = cpm.Create(true);**
cp.Name = propertyname;
cp.DisplayName = displayname;
cpm.Add(cp);
ProfileTypePropertyManager ptpm = ppm.GetProfileTypeProperties(ProfileType.User);
ProfileTypeProperty ptp = ptpm.Create(cp);
ptpm.Add(ptp);
ProfileSubtypeManager psm = ProfileSubtypeManager.Get(context);
ProfileSubtype ps = psm.GetProfileSubtype(ProfileSubtypeManager.GetDefaultProfileName(ProfileType.User));
ProfileSubtypePropertyManager pspm = ps.Properties;
ProfileSubtypeProperty psp = pspm.Create(ptp);
pspm.Add(psp);
}
