Archive for November, 2012

November 29, 2012

Restore-SPSite : Your backup is from a different version

I was restoring a SharePoint backup which i took it from one of our staging servers to the virtual machine in my local machine. So was unable to restore the same and was getting the following error due to imcompatible versions in between the Servers (sharepoint foundation versions).

Restore-SPSite : Your backup is from a different version of Microsoft SharePoint Foundation and cannot be restored to a server running the current version. The backup file should be restored to a server with version ‘14.0.0.6106’ or later.
At line:1 char:15 + Restore-SPSite <<<<  http://smssps:3333/ -Path ?C:\AppDev-01 backups 28 Nov 2012\ShounAlQuran\ShounalQuranAppDev01.bak” -Force -DatabaseServer “smssps” -DatabaseName “WSS_Content_ShounAlQuran”
+ CategoryInfo          : InvalidData: (Microsoft.Share…dletRestoreSite:
SPCmdletRestoreSite) [Restore-SPSite], SPException + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletRestoreSite

use the powershell command : (get-spfarm).BuildVersion to find the version of the sharepoint foundation.


so if the versions differs please go through the following link and install the correct patches to make sure that the versions are same in both the source and the destination.

http://www.sharepointdesignerstepbystep.com

Advertisements
November 21, 2012

Website got hacked

Shortly, after publishing of the website which i was working on few days back, yesterday i noticed some unexpected number of records is being inserted into one of the Share Point List we do have in our system. The purpose of the said list was to get the user comments from the website visitors for the News, Articles, etc via a User Input Form. The said form was fully secured with the client side scripts for malicious data inputs. At first i panicked, because i was worried about the rest of the user input forms also been compromised. But, thankfully its not and the intrusion was limited only to the said form above. 🙂

When investigated the data that hacker tried to inject into the system seems an automated script which is being used for SQL Injection and as well as a sort of a DOS (Denial of Service) attack. As an urgent fix for this had to implement the Captcha (Completely Automated Public Turing test to tell Computers and Humans Apart) feature to make sure the data is being inputted by a human and not from an automated robotic program.

the scripts which was embedded..

November 14, 2012

Adding a single value and multiple values into a Lookup Column

There might be situations where you may have to add multiple values to a SharePoint list field.


SPFieldMultiChoiceValue multiChoiceFunction = new SPFieldMultiChoiceValue();

for (int i = 0; i &lt; CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected)
{
int lvId = Convert.ToInt32(CheckBoxList1.Items[i].Value);
string lvValue = CheckBoxList1.Items[i].Text.ToString().Trim();
SPFieldLookupValue lv = new SPFieldLookupValue(lvId, lvValue);
multiChoiceFunction.Add(lv.ToString());
}
}

item["Function"] = multiChoiceFunction;

below is the code snippet of the way to add a value to a SharePoint look up column field :

foreach (ListItem lst in RadioButtonList1.Items)
{
if (lst.Selected == true)
{
int lvId = Convert.ToInt32(lst.Value);
string lvValue = lst.Text.ToString().Trim();
SPFieldLookupValue lv = new SPFieldLookupValue(lvId, lvValue);
item["TypeOfTest"] = lv;
}
}