static void AddProfileProperty(string name, string displayName, bool isMultidValue) { using (SPSite oSite = new SPSite("http://servername")) { //SPServiceContext oServContext = SPServiceContext.GetContext(oSite); ClientContext clientContext = new ClientContext("http://svg-ronald:8080/"); ProfilePropertyManager prfPropMgr; ProfileSubtypeManager prfTypeMgr; ProfileSubtypePropertyManager prftypePropMgr; ProfileTypePropertyManager typPropMgr; ProfileSubtypeProperty prfTypeProp; ProfileTypeProperty prfProp; ProfileSubtype prfType; CorePropertyManager corePropMgr; CoreProperty coreProp; //prfPropMgr = new UserProfileConfigManager(oServContext).ProfilePropertyManager; prfPropMgr = new UserProfileConfigManager().ProfilePropertyManager; //prfProp.Name = name; corePropMgr = prfPropMgr.GetCoreProperties(); coreProp = corePropMgr.Create(false); coreProp.Name = name; coreProp.DisplayName = displayName; coreProp.IsMultivalued = isMultidValue; coreProp.Type = PropertyDataType.StringMultiValue; coreProp.Length = 1024; corePropMgr.Add(coreProp); typPropMgr = prfPropMgr.GetProfileTypeProperties(ProfileType.User); prfProp = typPropMgr.Create(coreProp); prfProp.IsVisibleOnViewer = true; typPropMgr.Add(prfProp); //prftypePropMgr.Add(prfTypeProp); prftypePropMgr = prfPropMgr.GetProfileSubtypeProperties(name); prfTypeProp = prftypePropMgr.Create(prfProp); prfTypeProp.IsUserEditable = true; prfTypeProp.DefaultPrivacy = Privacy.Public; prfTypeProp.UserOverridePrivacy = true; } }
public void CreateUIDProperty() { var propManager = _propertyManager.GetCoreProperties(); var property = propManager.GetPropertyByName(UUID_PROPERTY); if (property != null) { return; } Logger.WriteInfo("Creating property '" + UUID_PROPERTY + "' in profile service"); var profilePropMgr = new UserProfileConfigManager(_context).ProfilePropertyManager; var corePropManager = profilePropMgr.GetCoreProperties(); // Create the property. var coreProp = corePropManager.Create(false); coreProp.Name = UUID_PROPERTY; coreProp.DisplayName = "SPC UID"; coreProp.Type = PropertyDataType.String; coreProp.Length = 36; coreProp.IsMultivalued = false; coreProp.IsSearchable = true; corePropManager.Add(coreProp); // Create a profile type property and make the core property visible in the Details section page. var typePropManager = profilePropMgr.GetProfileTypeProperties(ProfileType.User); var typeProp = typePropManager.Create(coreProp); typeProp.IsVisibleOnViewer = true; typePropManager.Add(typeProp); // Create a profile subtype property. var subtypeManager = ProfileSubtypeManager.Get(_context); var subtype = subtypeManager.GetProfileSubtype(ProfileSubtypeManager.GetDefaultProfileName(ProfileType.User)); var subtypePropMgr = profilePropMgr.GetProfileSubtypeProperties(subtype.Name); var subtypeProp = subtypePropMgr.Create(typeProp); subtypeProp.IsUserEditable = false; subtypeProp.DefaultPrivacy = Privacy.Public; subtypeProp.UserOverridePrivacy = true; subtypePropMgr.Add(subtypeProp); Logger.WriteInfo("Created SPC UID property in profile service"); }
static void AddProfileProperty(string name, string displayName, bool isMultidValue) { using (SPSite oSite = new SPSite("http://servername")) { //SPServiceContext oServContext = SPServiceContext.GetContext(oSite); ClientContext clientContext = new ClientContext("http://svg-ronald:8080/"); ProfilePropertyManager prfPropMgr; ProfileSubtypeManager prfTypeMgr; ProfileSubtypePropertyManager prftypePropMgr; ProfileTypePropertyManager typPropMgr; ProfileSubtypeProperty prfTypeProp; ProfileTypeProperty prfProp; ProfileSubtype prfType; CorePropertyManager corePropMgr; CoreProperty coreProp; //prfPropMgr = new UserProfileConfigManager(oServContext).ProfilePropertyManager; prfPropMgr = new UserProfileConfigManager().ProfilePropertyManager; //prfProp.Name = name; corePropMgr = prfPropMgr.GetCoreProperties(); coreProp = corePropMgr.Create(false); coreProp.Name = name; coreProp.DisplayName = displayName; coreProp.IsMultivalued = isMultidValue; coreProp.Type = PropertyDataType.StringMultiValue; coreProp.Length = 1024; corePropMgr.Add(coreProp); typPropMgr = prfPropMgr.GetProfileTypeProperties(ProfileType.User); prfProp = typPropMgr.Create(coreProp); prfProp.IsVisibleOnViewer = true; typPropMgr.Add(prfProp); //prftypePropMgr.Add(prfTypeProp); prftypePropMgr = prfPropMgr.GetProfileSubtypeProperties(name); prfTypeProp = prftypePropMgr.Create(prfProp); prfTypeProp.IsUserEditable = true; prfTypeProp.DefaultPrivacy = Privacy.Public; prfTypeProp.UserOverridePrivacy = true; } }