







| using System; using System.Collections.Generic; using System.Text; using Microsoft.SharePoint; using System.Web; using Microsoft.Office.Server; using Microsoft.Office.Server.Administration; using Microsoft.Office.Server.UserProfiles; namespace ConsoleApplication4 {     class Program     {         static void Main(string[] args)         {             try             {                 using (SPSite site = new SPSite("http://mossweb:1111/sites/Publish"))                 {                     ServerContext context = ServerContext.GetContext(site);                     UserProfileManager profileManager = new UserProfileManager(context);                     PropertyCollection pc = profileManager.Properties;                     Property p = pc.Create(false);                     // 名称                      = "SkillLevel";                     // 显示名称                     p.DisplayName = "技能级别";                     // 类型                     p.Type = "String";                     // 长度                     p.Length = 50;                     // 策略设置                     p.PrivacyPolicy = PrivacyPolicy.OptIn;                     // 默认隐私设置                     p.DefaultPrivacy = Privacy.Organization;                     pc.Add(p);                     Console.WriteLine("Success!");                 }             }             catch (Exception ex)             {                 Console.WriteLine(ex.Message);             }             Console.ReadLine();         }     } } | 

| using System; using System.Collections.Generic; using System.Text; using Microsoft.SharePoint; using System.Web; using Microsoft.Office.Server; using Microsoft.Office.Server.Administration; using Microsoft.Office.Server.UserProfiles; namespace ConsoleApplication4 {     class Program     {         static void Main(string[] args)         {             try             {                 using (SPSite site = new SPSite("http://mossweb:1111/sites/Publish"))                 {                     ServerContext context = ServerContext.GetContext(site);                     UserProfileManager profileManager = new UserProfileManager(context);                     PropertyCollection pc = profileManager.Properties;                     Property p = pc.Create(false);                     // 名称                      = "TestCountry1";                     // 显示名称                     p.DisplayName = "来自国家";                     // 类型                     p.Type = PropertyDataType.String;                     // 长度                     p.Length = 50;                     // 策略设置                     p.PrivacyPolicy = PrivacyPolicy.OptIn;                     // 默认隐私设置                     p.DefaultPrivacy = Privacy.Organization;                     // 多值字段                     p.IsMultivalued = true;                     // 是否可编辑                     p.IsUserEditable = true;                     p.ChoiceType = ChoiceTypes.Closed;                     string[] choices = new string[] { "中国", "美国", "加拿大", "新加坡" };                     foreach (string choice in choices)                     {                         p.ChoiceList.Add(choice);                     }                     p.Separator = MultiValueSeparator.Comma;                     pc.Add(p);                     Console.WriteLine("Success!");                 }             }             catch (Exception ex)             {                 Console.WriteLine(ex.Message);             }             Console.ReadLine();         }     } } | 
 
 
                     
            
        













 
                    

 
                 
                    