Exemple #1
0
        /// <summary>
        /// Write a MultiValued property to SPO
        /// </summary>
        /// <param name="UserName"></param>
        /// <param name="PropertyName"></param>
        /// <param name="PropertyValue"></param>
        static void SetSingleMVProfileProperty(string UserName, string PropertyName, string PropertyValue)
        {
            try
            {
                string[] arrs = PropertyValue.Split(ConfigurationManager.AppSettings["PROPERTYSEPERATOR"][0]);

                UPSvc.ValueData[] vd = new UPSvc.ValueData[arrs.Count()];

                for (int i = 0; i <= arrs.Count() - 1; i++)
                {
                    vd[i]       = new UPSvc.ValueData();
                    vd[i].Value = arrs[i];
                }

                UPSvc.PropertyData[] data = new UPSvc.PropertyData[1];
                data[0]                = new UPSvc.PropertyData();
                data[0].Name           = PropertyName;
                data[0].IsValueChanged = true;
                data[0].Values         = vd;

                _userProfileService.ModifyUserPropertyByAccountName(string.Format(@"i:0#.f|membership|{0}", UserName), data);
            }
            catch (Exception ex)
            {
                LogMessage("Exception trying to update profile property " + PropertyName + " for user " + UserName + "\n" + ex.Message, LogLevel.Error);
            }
        }
Exemple #2
0
 /// <summary>
 /// Use this function if you want to set a single property in the user profile store
 /// </summary>
 /// <param name="UserName"></param>
 /// <param name="PropertyName"></param>
 /// <param name="PropertyValue"></param>
 static void SetSingleProfileProperty(string UserName, string PropertyName, string PropertyValue)
 {
     try
     {
         UPSvc.PropertyData[] data = new UPSvc.PropertyData[1];
         data[0]                 = new UPSvc.PropertyData();
         data[0].Name            = PropertyName;
         data[0].IsValueChanged  = true;
         data[0].Values          = new UPSvc.ValueData[1];
         data[0].Values[0]       = new UPSvc.ValueData();
         data[0].Values[0].Value = PropertyValue;
         _userProfileService.ModifyUserPropertyByAccountName(UserName, data);
     }
     catch (Exception ex)
     {
         LogMessage("Exception trying to update profile property " + PropertyName + " for user " + UserName + "\n" + ex.Message, LogLevel.Error);
     }
 }