Thursday, January 12, 2012

Extend Search Core Result Web part with FAST for SharePoint 2010

I have tried to extend Search Core Result Web part with simple customization and deployed as feature to FAST SharePoint 2010 Template as following:

[ToolboxItemAttribute(false)]
    public class AppendCoreResultWebPart : CoreResultsWebPart
    {
protected override void ConfigureDataSourceProperties()
        {
        //Just Append Search Query with My Name
            this.AppendedQuery = "Fadi Abdulwahab";

            base.ConfigureDataSourceProperties();
        }
    }
}



But the problem in this web part that did not show any result by default but the rest controls like paging or Refinement web parts returned results as the below image

 So to fix this problem as Mr. Mikael Svenson [I asked him to help me in this issue] said just "Export the settings from the default core results webpart.. And add those to the .webpart file of your custom webpart"
Note: I advice you to visit  Mr. Mikael Svenson  blog  http://techmikael.blogspot.com/ 
So just go to Web Parts page under Site Actions >> Site Settings >> Galleries and export the .webpart file of Default Search Core Result web part and then copy the below properties and then export your custom web part file and add the below properties and then upload it again to web part galleries

        <property name="ChromeType">None</property>
        <property name="AllowMinimize" type="bool">true</property>
        <property name="AllowClose" type="bool">true</property>
        <property name="Hidden" type="bool">false</property>
        <property name="ShowActionLinks" type="bool">false</property>
        <property name="ShowMessages" type="bool">true</property>

Finally Go to SharePoint page and remove the old web part and add the new web part J.


Sunday, October 2, 2011

Microsoft® SQL Server® 2008 R2 Service Pack 1 and Cumulative Update package 1 for SQL Server 2008 R2


I will explain the steps how to install SQL Server R2 SP1 & its CU in Cluster environment.
[Microsoft® SQL Server® 2008 R2 Service Pack 1]
[Cumulative Update package 1 for SQL Server 2008 R2]

  1. First download the setup files.
  2. Take backup of your environment.
  3. Go to Passive Node.
  4. Install Microsoft® SQL Server® 2008 R2 Service Pack 1 in Passive Node server.
  5. Install Cumulative Update package 1 for SQL Server 2008 R2 in Node server .
  6. Restart the server
  7. Move SQL Service to Upgraded Server and wait for 1 min until SQL Server finish from Upgrade mode
  8. then go to Second server and do the same steps
Note : 
  1. before install SP 1 & CU make sure Integration Service in started
  2. if you get any error just reboot the system and rerun the setup file again


Tuesday, September 27, 2011

Exception from HRESULT: 0x80041054

The following error "Exception from HRESULT: 0x80041054" related to ForeFront Protection 2010 for SharePoint and if you check the log [Windows Log] you will find the following error "The SharePoint service is running but the Forefront VSAPI Library is not registered"

so to fix this error from SharePoint Side just go to Central administration >> Security >> Manage antivirus settings >> then Uncheck all check boxex and then browse the site .

To fix it from Forefront Protection production by follow the steps in this URL
http://ikarstein.wordpress.com/2010/12/07/forefront-protection-2010-for-sharepointerror-the-sharepoint-service-is-running-but-the-forefront-vsapi-library-is-not-registered/

then Re-Check the Settings in Manage antivirus settings to enable scan documents when upload or download.

The BDC Service application ... is not accessible. The full exception text is: There are no addresses available for this application

Today i have faced this problem "The BDC Service application ... is not accessible. The full exception text is: There are no addresses available for this application" in sharePoint 2010


so to fix it do the following :
1-Delete the created BDC Service App
2- Make sure Business Data Connectivity Service started on the server
3- Re-Create BDC Service App.


Done.

Saturday, August 6, 2011

Sandbox Solutions and Load Balancing schemes

Sandbox solution or User Solution as Microsoft Definition "A sandbox is a restricted execution environment that enables programs to access only certain resources and keeps problems that occur in the sandbox from affecting the rest of the server environment".

So Sandbox solution more secure,safer and the user who deploy the solutions has limitation to server resources for example you can't deploy a files to Servers like Visual Web Part, You can't execute SPWebApplication , SPSecurity , Reflection code (Connected Web Parts uses Reflection so you can't Implemented also)… and these solution deployed or stored at Site collection level .

Administrator Can monitors these solutions and gives them specific resources or can block these solutions.
These solutions run under specific process located under 14\UserCode\ folder not under w3c.exe process.


In this article I will explain the Sandbox solution and Load Balancing schemes which affect the execution of code in the servers.

If you go to Central Administration >> System Settings >> Manage user solutions
You will find the below options:

The first option means:
If you have two frontend servers with Microsoft Load balance configuration (NLB) and the user request a page which run sandbox solution code; if the NLB routed the request to one these server the code run in the same server which received the request so in this case all frontend servers must started Microsoft SharePoint Foundation Sandboxed code Service and if in case this service not started on the server which received the request; the code will not run and the user will get an error.

Second option:

If in case the service started in Frontend 1 server only and the NLB routed the request to Frontend 2; here the Sandbox process will route this request again to Frontend 1 and then run this code and the user will get the Response (this is known as solution affinity).


So for example I created a web part (not visual web part) with basic code like below:
public override void RenderControl(HtmlTextWriter writer)
        {
            base.RenderControl(writer);

            writer.Write("Hello Fadi From Sandbox Solution");
        }


And then I uploaded this solution to Site Settings >> Solutions and then activated and then I add this web part to a test page.



Now I stopped Frontend 1 from the NLB and then I requested the page which has sandbox solution code; sandbox process route the request to Frontend 1 to run the code and get the Response.

Note: try the first option with this an example and you will get an error because when the NLB route the request to Frontend 2 which the service in this server not started so the code will not run.
so the benifits with second option as microsoft wrote : "The more you isolate sandboxed solutions, the better your ability to protect the main part of your SharePoint Server 2010 site from code that might consume too many resources. You can increase isolation by using remote load balancing and by running the sandboxed solution service only on specific servers."

Wednesday, July 27, 2011

Excel SpeardSheet can't be open in Sharepoint Server 2010 with Office Web Apps

Today I came across an error with Excel service and Office web apps with that I make sure all features running and application service associated with my web application so I check the log and I found this error:
SQL Database 'WSS_Content_SCTAIntranet_80' on SQL Server instance '[Instance Name]' not found. Additional error information from SQL Server is included below.

Cannot open database "WSS_Content_SCTAIntranet_80" requested by the login. The login failed.
Login failed for user '[DomainName]\EPM_ExcelService'.



So to fix this problem just go to SQL Server Management Studio > Security Folder > Logins >[DomainName]\EPM_ExcelService then Right click and Properties


Select the database name (WSS_Content_SCTAIntranet_80) and then in down part check [db_owner].

Sunday, July 24, 2011

How to encrypt the connection string in web.config in Asp.net Web Application or Site and SharePoint Web Application

In order to encrypt sensitive information in the web.config of Asp.net Web application/Site or SharePoint Web application like connection String which include user name and password or any data in appSettings so to secure your data easily you can use .net 2.0 tool called (aspnet_regiis.exe).


In this post I will show you how to encrypt/decrypt appSettings data in Web.config using the aspnet_regiis tool.

So first go to command prompt of .net 2.0 which located in this path:

C:\Windows\Microsoft.NET\Framework\v2.0.50727>


Then I have a Test Web application with this section in web.config

<appSettings>
    <add key="MyPassword" value="1234"/>
</appSettings>


Now to encrypt this data, just run the following command:


aspnet_regiis -pef "appSettings" "D:\CustomFunctoids\TestWeb\TestWeb"

first parameter : name of section you want to encrypt it
second parameter : the folder directory of the web application which contains the web.config



So you will get a succeeded message tell you that the encryption done.
Now check your web.config /appSettings section and you will see something like this:

<appSettings configProtectionProvider="RsaProtectedConfigurationProvider">
    <EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
      xmlns="http://www.w3.org/2001/04/xmlenc#">
      <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" />
      <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
        <EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
          <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
          <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
            <KeyName>Rsa Key</KeyName>
          </KeyInfo>
          <CipherData>
            <CipherValue>BPLmgrIVZKTDerhKlyktxqnn5iybr8aO0IInylE8uT1Pe3zCB5y9DIHqlllH3e0sz6TtJaU/wS0oEiPIWMMO0BL/BPdj9E5Onq4nYiA2r/zBPCR6H0nYhk9/uMjao4YDcg6daask65Y8Mx1RBO/xM/IKzdNGXICpiF09Mrwrv1Q=</CipherValue>
          </CipherData>
        </EncryptedKey>
      </KeyInfo>
      <CipherData>
        <CipherValue>kziM2nK5Ej6kg7hxnN2shTB8EiMW/I5jrgQRJAIRD5gSV/KG6iYslstFz+r+6Wk9OKXKP2zUhDRl42++HOWbtjqJn5XjmHuzy3tHy+7YMvRL6CNY7lXQTQ==</CipherValue>
      </CipherData>
    </EncryptedData>
  </appSettings>


So it encrypted by using RsaProtectedConfigurationProvider algorithm
Now if your browse your site and you get this error :

"Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: The RSA key container could not be opened"


this means the user used by the Asp.Net web site does not have access to read this key container so to know what the name of user ?  you can create a simple .aspx page and place this code inside it
to determine the user account or identity under which ASP.NET runs by retrieving the current WindowsIdentity name.


<%@ Page Language="C#" %>
<%
Response.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name);
%>


So this page will print the current user used to run the web site so in my PC I got this result "VAIO-PC\VAIO"
now to grant this user ability to read this encrypted data run the following command


aspnet_regiis -pa "NetFrameworkConfigurationKey" "VAIO-PC\VAIO"


Now what if you want to decrypt the data to modify it so how to decrypt the appSettings section ?
run the following command to return to the normal status (Plan text)

aspnet_regiis -pdf "appSettings" "D:\CustomFunctoids\TestWeb\TestWeb"


Notes:
1.       You need to run this in all front end servers
2.       No need to any changes in your code because .net code can recognize this changes
3.       You can do the above steps by .net code