public override string FillField(BaseDataMap map, object importRow, ref User user, string fieldName, string importValue, bool isRequiredOnUser,
            out bool updatedField)
        {
            updatedField = false;

            string errorMessage = String.Empty;
            var users = UserKeyStorage.GetUsersFromKey(fieldName, importValue, ref errorMessage);
            if (!String.IsNullOrEmpty(errorMessage))
            {
                return String.Format(
                                    "An error occured in the GetUsersFromKey method in the FillField method in trying to retrieve the users from key. ErrorMessage: {1}. " +
                                    "User '{2}'. FieldName: {0}. ImportValue: {3}.",
                                    fieldName, errorMessage, map.GetUserDebugInfo(user), importValue);
            }
            if (users.Count > 1)
            {
                return String.Format(
                                    "Duplicate values where found in the column '{0}' in the Users table in the .NET membership database. The value must be unique. ErrorMessage: {1}. " +
                                    "User '{2}'. FieldName: {0}. ImportValue: {3}.",
                                    fieldName, errorMessage, map.GetUserDebugInfo(user), importValue);
            }
            if (users.Count == 1)
            {
                if (users.First().LocalName != user.LocalName)
                {
                    return String.Format(
                                    "A key with the same value in column '{0}' was found on another user in the Users table in the .NET membership database. The value must be unique. " +
                                    "ErrorMessage: {1}. Found on user: {2}. Current user '{3}'. FieldName: {0}. ImportValue: {4}.",
                                    fieldName, errorMessage, map.GetUserDebugInfo(users.First()), map.GetUserDebugInfo(user), importValue);
                }
            }

            var result = UserKeyStorage.UpdateKeyValueToDotnetMemberShipProviderDatabase(fieldName, importValue, user.Domain.GetFullName(user.LocalName), ref errorMessage);
            if (!String.IsNullOrEmpty(errorMessage))
            {
                return String.Format(
                                    "The update of column '{0}' in the Users table in the .NET membership database failed of the following reason: {1}. " +
                                    "User '{2}'. FieldName: {0}. ImportValue: {3}.",
                                    fieldName, errorMessage, map.GetUserDebugInfo(user), importValue);
            }
            updatedField = result == 1;
            return string.Empty;
        }
        public override string FillField(BaseDataMap map, object importRow, ref User user, string fieldName, string importValue, bool isRequiredOnUser,
            out bool updatedField)
        {
            updatedField = false;

            var profile = user.Profile;
            if (profile != null)
            {
                var propertyInfo = Sitecore.Reflection.ReflectionUtil.GetPropertyInfo(profile, fieldName);
                if (propertyInfo != null)
                {
                    if (propertyInfo.PropertyType == typeof (string) || propertyInfo.PropertyType == typeof (String))
                    {
                        var existingValue = propertyInfo.GetValue(profile, null) as string;
                        if (existingValue != importValue)
                        {
                            Sitecore.Reflection.ReflectionUtil.SetProperty(profile, propertyInfo, importValue);
                            updatedField = true;
                        }
                    }
                    else
                    {
                        return String.Format("The property on the User.Profile was not of type string. Therefore the field could not be filled. PropertyType: {0}. User '{1}'. FieldName: {2}. ImportValue: {3}.", propertyInfo.PropertyType, map.GetUserDebugInfo(user), fieldName, importValue);
                    }
                }
                else
                {
                    if (CheckThatPropertyExist)
                    {
                        return
                            String.Format(
                                "The profile did not contain a property as defined in fieldName. This field must be found on the user because the 'isRequired' value is set. User '{0}'. FieldName: {1}. ImportValue: {2}.",
                                map.GetUserDebugInfo(user), fieldName, importValue);
                    }
                }
            }
            else
            {
                return String.Format("The profile was null on the user '{0}' while processing the fieldName: {1}, with importValue: {2}.", map.GetUserDebugInfo(user), fieldName, importValue);
            }
            return string.Empty;
        }
 public override string FillField(BaseDataMap map, object importRow, ref User user, string fieldName, string importValue, bool isRequiredOnUser,
     out bool updatedField)
 {
     updatedField = false;
     var profile = user.Profile;
     if (profile != null)
     {
         if (CheckThatPropertyExist)
         {
             var customPropertiesNames = profile.GetCustomPropertyNames();
             if (customPropertiesNames != null)
             {
                 if (!customPropertiesNames.Contains(fieldName))
                 {
                     return String.Format(
                             "The profile does not contain a Custom Property as defined in fieldName. " +
                             "User '{0}'. FieldName: {1}. ImportValue: {2}.",
                             map.GetUserDebugInfo(user), fieldName, importValue);
                 }
             }
             else
             {
                 return String.Format("The profile.GetCustomPropertyNames() returned null. Therefore the custom property could not be verified if it exists. User '{0}'. FieldName: {1}. ImportValue: {2}.", map.GetUserDebugInfo(user), fieldName, importValue);
             }
         }
         var existingValue = profile.GetCustomProperty(fieldName);
         if (existingValue != importValue)
         {
             profile.SetCustomProperty(fieldName, importValue);
             updatedField = true;
         }
     }
     else
     {
         return String.Format("The profile was null on the user '{0}' while processing the fieldName: {1}, with importValue: {2}.", map.GetUserDebugInfo(user), fieldName, importValue);
     }
     return string.Empty;
 }
 public virtual string FillField(BaseDataMap map, object importRow, ref User user, string importValue, out bool updatedField)
 {
     updatedField = false;
     if (IsRequiredOnImportRow)
     {
         if (String.IsNullOrEmpty(importValue))
         {
             return String.Format("The imported value '{0}' was empty. This field must be provided when the field is marked as required on import row. " +
                                  "The field was not updated. User: {1}. ImportRow: {2}. FieldName: {3}.", importValue, map.GetUserDebugInfo(user), map.GetImportRowDebugInfo(importRow), NewItemField);
         }
     }
     if (FieldStorageHandler != null)
     {
         string errorMessage = String.Empty;
         var processedImportValue = ProcessImportedValue(importValue, ref errorMessage);
         if (!String.IsNullOrEmpty(errorMessage))
         {
             return String.Format("The processedImportValue '{0}' resulted in an error. The field was not updated. ErrorMessage: {1}. " +
                                  "User: {2}. ImportRow: {3}. FieldName: {4}. ImportValue: {5}.", processedImportValue, errorMessage, map.GetUserDebugInfo(user), map.GetImportRowDebugInfo(importRow), NewItemField, importValue);
         }
         if (IsRequiredOnUser)
         {
             if (String.IsNullOrEmpty(processedImportValue))
             {
                 return String.Format("The processedImportValue '{0}' was empty or null. This field cannot be empty or null when the field is marked as required on the user. " +
                                      "The field was not updated. User: {1}. ImportRow: {2}. FieldName: {3}. ImportValue: {4}.", processedImportValue, map.GetUserDebugInfo(user), map.GetImportRowDebugInfo(importRow), NewItemField, importValue);
             }
         }
         var statusMessage = FieldStorageHandler.FillField(map, importRow, ref user, NewItemField, processedImportValue, IsRequiredOnUser, out updatedField);
         if (!String.IsNullOrEmpty(statusMessage))
         {
             return String.Format("An error occured trying to fill the field with a value. The field was not updated. See error log: '{0}'.", statusMessage);
         }
     }
     else
     {
         return String.Format("The FillField failed because the FieldStorageHandler object was null. User: {0}. NewItemField: {1}. ImportValue: {2}.", map.GetUserDebugInfo(user), NewItemField, importValue);
     }
     return String.Empty;
 }