Thursday, December 01, 2011

How to create test accounts in Facebook

Hi All,

Facebook now doesn't allow you to test your facebook application without creating test accounts. When you try to test your non published Facebook application and try to post any update you will get this error message:

oAuthException #100 can only call this method on valid test users for your app

To create a test account in Facebook, here is the steps:
1) Copy and paste the following url in your browser:

Before hit enter, do the following:
a) Get the access token for your facebook application, to get it paste the following url in the browser:

b) Permissions: To grant certain permissions to the test account, read the full extended permissions from below link:

If you get an error when you specify a name, you can omit the name parameters and in this case FB will create a name for your test account.

Once you edit above parameters and hit enter in the browser, you will get a message like this showing that your test account has been created successfully.

   "id": "XXXXXXXXXXX",
   "access_token": "XCEWWEE#######EEEEEU8ffOT3VYD70ld0nYCiNlZB5Flmh59yfPksO5XfUdVxnZAhi0oEKvpJxACywhxsNgwGWfe6gH2B1DaxVUSXy2mCfo1jzf3TUk7",
   "login_url": "",
   "email": "cqszpqv_smithwwwqitz_133222765997\",
   "password": "211212121233"

Try to log in with the username and password before run your application.

Hope this helps.

* References:
- How to create test users in Facebook:

Wednesday, November 30, 2011

Change Sql Azure DB Size

Hi All,

I was trying to change my business edition DB to web edition in SQL Azure and i didn't find a sample TSQL to run to shrink the DB file size from 20 GB (Business) to 1 GB (Web) Edition.

Here is the TSQL you want to run after deleting the unnecessary data in your DB and make sure its size under the required new DB size.

Alter database YOURDBNAME

 modify (          
           maxsize=1 GB,

Hope this helps.

Thursday, November 10, 2011

SharePoint Restore Error: 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 '' or later

Hi Folks,

I was deploying a new release for a SharePoint project that i'm working on with my team, when i was try to backup and restore a site collection from my development to staging environment, I got this error:

SharePoint Restore Error: 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 '' or later.

To fix this problem, follow these steps:

1) Make sure that both environments have the same updates and CUs. To do so, Open Central Administration and click on Upgrade and Migration link and click on "Check product and patch installation  status".
You will have list of updates and CUs that have been installed on your environment, make sure those updates are identical. Any missing updates, download and install it on the new environment if you haven't document this as a part of your release process that you have in place.

2) Then click on "Review database status" under upgrade and migration section and make sure you don't have "need upgrade" to any of your content databases.The status should be "No action required". If you have any upgrade required and specially if you have SP1 installed, this means you didn't run the SPConfig command post to your SP1 installation. To do so, follow these steps:

a) Launch an elevated (Run as Administrator) SharePoint 2010 Management shell :
(get-spserver $env:computername).NeedsUpgrade
If the result of this command is True, then you need to complete step (b) below. If the result is False then no further action (b) is needed.
b) In order to update the SharePoint databases, you must manually run the PSconfig utility. To run the utility:

  - Open an Administrative command prompt. 
  - Change directory to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN 
  - Run:
    PSConfig.exe -cmd upgrade -inplace b2b -force -cmd applicationcontent -install -cmd installfeatures

Wait till the configuration wizard finishes all updates and then you will be able to backup and restore your site collection with no issues...

Hope this helps.

Wednesday, November 02, 2011

Secure Store Service Error in SharePoint 2010 : Secure Store Service is not accessible

Hi All,

I have been noticed that one of our SharePoint 2010 installation has a problem when trying to click on Secure Store Service in central administration.

The problem is : Try to click on SSS service in Central Administration and you will get an error page.

How to check the exact problem: I checked the event log in my server and i found the following error:

The Secure Store Service application Secure Store Service is not accessible. The full exception text is: The HTTP service located at https://PORTALURL/b04c52908ae5479596745e86b13875d4/SecureStoreService.svc/https is too busy.

To cause of the problem: the SSS service is not provisioned correctly, and to fix it:
Select the secure store service and from the ribbon click on properties. Verify the information that you have and click on OK. this action will provision the required DB and other service application configuration for this service.

This action will take around 5 minutes or depends on the performance of your server.

You don't need to re-install or run the configuration wizard for this fix.

Hope this helps :) Happy SharePointing...

User Profile Synchronization in SharePoint 2010 Facts

Hi Folks,

I'd like to share with you some important facts about User Profile synchronization in SharePoint 2010. SharePoint 2010 has User Profile Service application which provides a two-way synchronization for users/groups from your directory services or any external system in sync with SharePoint 2010 users and groups profiles.

Terms used in this post:
* UP: User Profile.
* UPSSA: User Profile Synchronization Service Application.
* UPSS: User Profile Synchronization Service.

Here are some facts you should be aware when you start planning for user profiles in SharePoint:
1) SharePoint 2010 has User Profile Service Application which manage the synchronization process between SP and AD or any external system that contains users & groups.

2) SP 2010 provisions a version of Microsoft Forefront Identity Manager to participate in synchronization.

3) UPSSA can only have one user profile synchronization service.

4) A UPSS is associated with connections and mappings.

5) We divide connections in UPSS into two types: connections to directory services, and connections to business systems.

6) When you setup a connection in UPSS to connect to directory services, You specify which containers to be included in the synchronization. You can specify filters to exclude service or disabled accounts.

7) Mapping is a step to map SharePoint user profile fields to directory services/external system user profile master data fields.

8) Upon each synchronization, SharePoint deletes SP users who have been deleted from Directory services.

9) Upon each synchronization, SharePoint add and updates SP user profile's fields as configured in the UPSS.

10) IMPORTANT: If you have multiple directory services, each directory services MUST provide unique users. You can't synchronize a single user with multiple directory services.

11) IMPORTANT: You can populate properties from any existing business system. You can't create new user profiles from an external system, and you can't write data back to a business system.

12) To synchronize properties from external system, First you should create an external content type to bring data from the business system into SP 2010. Then you will be able to synchronize these users into SP.

13) You should have a key field to be used for mapping between SP user profiles and your external system. You can use employee's work email as the identifier of your external content type. In this case, SP will synchronize information which matches employee's email to be captured in your synchronization records.

14) You can build a custom solution using SP object model to create user profiles in SharePoint.

Hope this helps.

1) Profile Synchronization overview in SP 2010:
2) BCS Overview in SP 2010:

Unable to use SQL Server because ASP.NET version 2.0 Session State is not installed on the SQL server. Please install ASP.NET Session State SQL Server version 2.0 or above.

Hi Folks,

I was deploying an website which configured to store session data in a custom databases in SQL Server 2008. After i scripted the whole DB and moved it to a new server and after deploying the website and try to run the application, I was getting this error:

Unable to use SQL Server because ASP.NET version 2.0 Session State is not installed on the SQL server. Please install ASP.NET Session State SQL Server version 2.0 or above.

My web.config configurations:

       sqlConnectionString="data source=SERVERNAME; initial catalog=MYDB; user id=mostafa; password=mostafaelzoghbi" 

Since this error message is misleading, you don't need to run aspnet_regsql command since i was using a custom database and all stored procedures, tables, custom user data types and DB objects have been scripted and deployed too. the cause of this error if you didn't give enough permission to the user that accesses the database. User should have execute permissions or grant dbo.owner to it.

Hope this helps.

Friday, October 28, 2011

Best Practices for SQL 2008 in SharePoint 2010 Farm

Hi All,

In this post i'd like to share with you best practices for SQL 2008 R2 in SharePoint 2010 farm and the operations and configuration that need to be taken in place when installing, configuring and administrating SharePoint 2010.

1) Designing SQL 2008 servers in your SharePoint 2010 farm: When you decide which topology you will have in your SharePoint 2010 farm, the SQL Server 2008 should be in a dedicated server and shouldn't be having any other role in your SP 2010 farm.

2) After installing SQL 2008 R2, you shouldn't go and start SP 2010 installation with SQL 2008 R2 Default configuration, here is what you need to revise:
    a) Don't enable auto-create statistics on SQL Server that's supporting SharePoint farm. You can enable/disable this feature on the DB level, here is the command you need to execute in your DB:


     b) Set Maximum degree of parallelism to 1 for all SQL server instances that host SP 2010 DBs. The value behind this is that each request is served by a single SQL Server Process.

sp_configure 'show advanced options', 1;
sp_configure 'max degree of parallelism', 1;

3) Secure and harden your SQL 2008 server DB by blocking the default ports and block default SQL server default ports. Check Out ref #3.

4) Use SQL Server 2008 backup compression feature to speed up the SharePoint backup. This feature is available in SQL 2008 Ent. edition and SQL 2008 R2 standard edition too. This feature significantly reduces the backup file size and shipped logs. The only consideration you should know that this feature consumes more processing time that might affect the performance of your DB server if the server doesn't properly planned to have enough processing power. This feature you enable it on the server level under Database settings, you will find a check box to use DB compression.

Hope this helps and let me know if you have any additional notes or concerns.

1) Auto-Create Feature in SQL 2008:
2) Set the maximum degree of parallelism in SQL 2008:
3) Harden & Secure SQL 2008 server DBs:
5) SQL 2008 Best practices in SharePoint 2010 Farm:

Mostafa Arafa

Wednesday, October 05, 2011

Fix it: IIS Manager doesn't update web.config when you add HTTP Response headers in Azure

Hi All,

I was trying to disable Silverlight caching in IIS 7, and when i deployed my solution to Windows 2008 Ent. in Windows Azure. Every time you click on the xap file that i need to disable caching on it by checking expire web content immediately after i clicked on Set Common Headers link on the right pane, the web.config is not being updated at all. but this works on my local IIS.

I ended up with adding this attribute that has been added my local IIS to web.config and deploy it so i don't need to do this every time i perform a deployment.

      <clientCache cacheControlMode="DisableCache" /> 

To disable caching in Silverlight "xap" file from IIS, Here is the article that i'm referring to:

Hope this tip helps.


Friday, August 26, 2011

Error occurred in deployment step 'Activate Features': 0x800700570 0

Hi Folks,

While i was developing a feature receiver in SharePoint 2010, I was trying to deploy my solution using VS 2010 and i was getting this error:

Error occurred in deployment step 'Activate Features': 0x800700570 0

And this happens actually when VS 2010 was trying to activate the feature, So i expected the problem from the Feature receiver i have that has code in "FeatureActivated" method. so, to be able to debug your feature receiver and exactly point the problem which throws the error while activating your feature, Do the following:

On your SharePoint Project, From Solution Explorer, Open project properties and change the following:
Active Deployment Configuration from Default to No Activation.

The point behind this, the feature will be deployed but not activated. So, you will be able to deploy and the debugger process is attached in VS then when you start activating the feature you will start debugging your feature receiver and fix the issue that you have in your code.

Hope this helps.


Wednesday, August 24, 2011

How to Open/Close Modal Dialogs in SharePoint 2010

SharePoint 2010 comes with a new modal dialogs feature that allows you to Open Modal windows from you application pages or ribbons. In this post i will highlight on how to open and close Modal Dialogs in SharePoint 2010.

If you have an Application page and you want to open up a modal dialog this is what you want to write in JavaScript using COM (Client Object Model) :

In your page, Add the following button to open modal dialog:

input onclick="openPopup();" title="Open Modal" type="button" value="Open Modal Dialog"

On you Page Head "PlaceHolderAdditionalPageHead" content add the following JavaScript function implementation "openPopup":

function openPopup() {
var options = {
url: '/_layouts/MYSPDemo/DialogPage.aspx',
title: 'Modal Dialog',
allowMaximize: false,
showClose: true,
width: 600,
height: 500


DialogPage is an application Page in your solution as specified above, Now try to deploy you solution and click on your button, your application page is showing as modal dialog... THIS IS AWESOME !!

To close you modal window, this is the line you need to add on you cancel or close button on your page:

SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, "Cancelled");

Hope this helps, To get the full documentation for ModalDialog using Client Object model, here is the KB url:

Mostafa Arafa

Sunday, August 14, 2011

Building PPS solutions in SharePoint 2010

Hi All,

During giving my session in SharePoint "The Conference" in DC, I provided some few links for my attendees that helps them to start working with PerformancePoint Services in SharePoint 2010.

To start working with SharePoint 2010 that has SP 2010, Office 2010, SQL 2008 & Project Server 2010.

There is an Information Worker VM to start working with PPS in SharePoint 2010:

To get a started with SQL2008 experience and BI, here is a training kit to start working with BI:

Mostafa Arafa

Tuesday, August 02, 2011

Fix It: The query could not complete because the data source is not in a performancePoint trusted location

Hi Folks,

If you are running PPS Dashboards and reports in your BI center site and when you are trying to view your dashboard/scorecards/reports and you have got this error:

" The query could not complete because the data source is not in a performancePoint trusted location"

The cause of this error is:
1) You system admin only listed specific trusted data sources in your farm.
To adjust this by adding your data connection library that is being used by your dashboard, do the following:
- Open central adminstration.
- Click on Manage service applications.
- Click on PerformancePoint service Application.
- Click on Trusted Data Source Locations, You will see "Only Specific Location" is selected and your data connection library is not listed
- Add your Data Connection library to the list, for example:
- Click on validate icon to make sure that you are putting a valid path.
- Click on Ok.
- Refresh your dashboard,scorecards or reports and everything will start working again.

Hope this helps.

Mostafa Arafa

Enable Non-Business Intelligence Center Sites with BI capabilities in SharePoint 2010

Hi Folks,

I'm getting questions about how to enable BI PerformancePoint features on Non-Business Intelligence Center Sites in SharePoint 2010. To enable PPS BI features in other SharePoint 2010 site templates, please do the followings:

1) Navigate to the site you would like to add PPS BI features to it.
2) From Site Settings --> Click on Site Settings.
3) Under Site Collection Administration, Click on Site Collection features.
4) Enable the following features:
a) PerformancePoint services Site Collection Features.
b) SharePoint Server Publishing Infrastructure.
c) SharePoint Server Enterprise Site Collection Features.
Note: You should have Enterprise SharePoint License to enable PPS BI Features in your farm, These features are not available in Standard or SPF editions.

Now, you prepared your site to use PPS features in SharePoint 2010.

Navigate to SharePoint home page and click on libraries, and click on create you will be able to see/select "PerformancePoint Data Connection" library that you use to store PPS data connections.
After creating the library, do the following:
1) Select library settings.
2) Click on Add from existing site content types and select "PeformancePoint Data Source" from the list under PerformancePoint Group.
3) We want to set PP data source to be the default content type for this library, so on library settings page click on "Change new button order and default content type" link and select PP DS.

4) Navigate to the list and click on New Document, select "PP Data Connection", PPS designer will be launched and you will be able to configure your data source and store it in the library.

Tip: Just notice that the items in data connection library has an approval workflow, Make sure to approve newly created data connections.

Happy SharePointing !!

Mostafa Arafa

SharePoint Saturday "The Conference" DC 2011

Hi Folks,

We would like to share with all SharePointers who are willing to attend the SharePoint Saturday The Conference DC from 11th-13th August 2011 please register right now and check out the list of all sessions by SharePoint Experts, MCM, MVPs and Industry Information Worker (IW)

This is the biggest SharePoint Saturday event; In addition to the lineup of great speakers/sessions; the event will have workshops that deliver hands-on experience to the attendees.

What's different about SPSTC DC :
A community-focused, educational event filled with sessions from respected SharePoint professionals and executives covering a wide range of technical and business topics.

Where ?

Northern Virginia Community College

Annandale Campus, Annandale, VA

(Visit the website here.)

I will deliver a session under Dev/ITPro track with title :

Building BI solutions using Performance Point Services in SharePoint 2010
Speaker(s): Mostafa Elzoghbi
Session Level: 300
Session Type: IT Pro / Developer
In this session I will cover PPS architecture & design fundamentals in SP 2010 and how to build BI solutions using SharePoint 2010 BI Center, BIDS, and Report Builder 3.0 with different data sources using DBs and Cubes. In addition to build, design, deploy Custom SSRS Reports within SharePoint. Tips in Configuring PPS application service in SharePoint 2010 and Reporting Services in SharePoint 2010.
A demo driven session to create custom KPIs, Scorecards, Custom Reports and Dashboards.

For more information, check out the website:

See you all there !!

Mostafa Arafa

Friday, July 15, 2011

SharePoint Saturday NYC: PPS solutions in SharePoint 2010

Hi All,

On 30th of July 2011, We will have SharePoint Saturday Event in New York City at Microsoft-Manhattan Office. Don't miss this opportunity to meet with SPS NYC speakers line up with very informative sessions. Please check out the event website:

I will present in this event with a session name : Building PerformancePoint Services Solutions in SharePoint 2010.

In this session I will cover PPS architecture & design fundamentals in SP 2010 and how to build BI solutions using SharePoint 2010 BI Center, BIDS, and Report Builder 3.0 with different data sources using DBs and Cubes. In addition to build, design, deploy Custom SSRS Reports within SharePoint. Tips in Configuring PPS application service in SharePoint 2010 and Reporting Services in SharePoint 2010.

A demo driven session to create custom KPIs, Scorecards, Custom Reports and Dashboards.

Session Details page:

Don't miss this event and see you all there...

Download Presentation Url:

Mostafa Arafa

Thursday, June 02, 2011

Export ASP.NET Form to PDF

Hi All,
I was trying to export the content of an ASP.NET page in my project to PDF, and after i spent few hours to figure out how to achieve this using standard Resposnse.Output() with pdf format, I ended up having different errors & bugs without successfully export a simple html page to pdf.

Having complex page with complex controls, you need simply to install iTextSharp PDF tool, easy and free tool to export your page to pdf.

Here is the steps:
1) Install iTextSharp tool :
2) Add itextsharp.dll in your project.
3) Create your function to export to PDF as follows:

        protected void ExportToPDF()  
                // Start exporting page content
                string attachment = "attachment; filename=MostafaElzoghbi.pdf"; 
                Response.AddHeader("content-disposition", attachment); 
                Response.ContentType = "application/pdf";    
                StringWriter stw = new StringWriter();   
                HtmlTextWriter htextw = new HtmlTextWriter(stw); 
                // We want to render the whole page, you can change this with the control name or portion you want to export. 
                Document document = new Document();       
                PdfWriter.GetInstance(document, Response.OutputStream);   
                StringReader str = new StringReader(stw.ToString()); 
                HTMLWorker htmlworker = new HTMLWorker(document);  
If you get this error: A control has to be placed inside a form tag with runat=server attribute.

Just add this function in your code to override the pre render validation step in forms:

public override void VerifyRenderingInServerForm(Control control)
 { /* Do nothing */ }

Hope this helps.

Mostafa Arafa

Monday, May 23, 2011

Upload Video to Facebook in C#

HI Folks,
If you tried to upload a video to facebook using facebook sdk in C#, You will face a problem that the provided method UploadVideo in LegacyRestApi.cs file accepts the full physical path of the file to be uploaded. For ASP.NET developers and since we are using AsyncFileUpload Control to select your files, this control provides only the file name and not the full physical path because of security constraints applied on all browsers. I have updated the source code and ask the codeplex product facebook sdk team to include this in the future release. and I'd like to share the updated code for this method in my blog for all facebook .NET Developers, Hope this helps.

C# Code:

public static string UploadVideo(string accessToken,string fileName, byte[] fileBytes)
   var mediaObject = new FacebookMediaObject 
       FileName = fileName,     
       ContentType = "video/3gpp" 
    try {         
              var fb = new FacebookClient(accessToken);     
              var parameters = new Dictionary<string, object>();   
              parameters["method"] = "video.upload";       
              parameters["caption"] = "video upload using rest api";   
              parameters["source"] = mediaObject;          
              var result = (IDictionary<string, object>)fb.Post(parameters);   
              var videoId = (string)result["vid"];        
              Console.WriteLine("Video Id: {0}", videoId);   
              // Note: This json result is not the orginal json string as returned by Facebook.    
              Console.WriteLine("Json: {0}", result.ToString());     
              return videoId;      
       catch (FacebookApiException ex) {     
            // Note: make sure to handle this exception.       
Codeplex discussion entry:


Tuesday, May 17, 2011

Fix It: Sys.WebForms.PageRequestManagerParserErrorException when using update Panel in Facebook Apps

Hi All,

I was developing a Facebook application using Facebook C# SDK and i have an update panel in my page i'd like it to update a grid in it based on selected index changed event for a drop down list.

The problem is that i have the update panel was throwing an exception when i was trying to change the selected index of a drop down list, the error is :
Sys.WebForms.PageRequestManagerParserErrorException when using update Panel

This error is vague, to know exactly what is the problem of the update panel, Install Fiddler which is the best tool for any web developer should have to inspect http requests/responses.

After installing and open Fiddler to inspect all http round trips on my development machine, I found the actual error that was returned from the server is:
Given URL is not allowed by the Application configuration.
So the solution for this problem is a missing or incorrect configuration in your Facebook application. Open the configuration of your Facebook application and select website tab and set the website url for your local Facebook application is running:
Site URL : http://localhost/

1) If you set the port number in the site url this won't fix the problem, Just set the localhost without any ports and this will fix the update panel problem is not updating because of the javascript error.
2) You can have SelectedIndexChanged event as AsyncPostBackTrigger in the update
panel and no issues with this because i read some posts were saying it has to be SyncPostBack
which is not actually right.
Hope this helps.

Mostafa Arafa

Monday, May 16, 2011

Automatic HTTPS redirect in Windows 2008 R2

Hi All,

I was trying to setup automatic redirect from HTTP to HTTPS for my hosted web application in IIS 7.0/7.5 Windows 2008 R2. I spent good time trying to find out a working solution for this problem.

If you tried a solution with custom error pages 403 in IIS to redirect the http to https, this won't work in windows 2008 R2 IIS 7.0/7.5 server, as stated here:

Please follow these steps to have a working solution:
1) Install URL Rewrite 2.0 on your webserver, download url:

2) After installing url rewrite module in IIS, Open IIS Manager and select your website, you will find a newly added icon "Url Rewirte"

3) Make sure to install SSL certificate on your site and site has https binding on port 443.

4) on SSL settings in IIS, un check Require SSL check - IMPORTANT, because this will overwrite the settings you will configure on URL Rewrite and will throw http 403.4 error.

5) Don't add any custom error pages for 403 as mentioned on some blog posts, if you have please remove it.

6) double click on URL rewrite and click on add rule.

7) Select Blank rule and click on ok.

8) On Name field give name to the rule: Redirect to HTTPS

9) Set the following values on the form:
- Requested URL: Select Matches the pattern
- Using: Regular Expression
- Pattern: (.*)
- Under Conditions, Click on Add and type:
Condition Input: {HTTPS}
Check if input string: Matches the pattern
Pattern: ^OFF$
- Under Action section:
Action Type: select Redirect
Redirect URL: https://{HTTP_HOST}{REQUEST_URI}
If you tried this url: https://{HTTP_HOST}/{R:1} as stated in some blogs, this won't work as well.
Redirect Type: See Other (303)

And then click on Apply.

From IIS Manager, Try to browse the application using HTTP, The IIS will direct you to HTTPS automatically.

Hope this helps.


Mostafa Arafa