Solution of Problem “403 (Forbidden) with SP.RequestExecutor.js”

Standard

Well, Every day I learn something.

Today,when I was deploying some apps to Office 365,I’ve come across a situation interesting and wanted to dig in.

I was developing an app that uses a list to retrieve specific items and it was working perfect in my On-Premise environment.

When I deployed the same app to Office 365 Developer Site,I have received this error in my Chrome’s Developer Tools threw error something similar to “403 (Forbidden)” linking “SP.RequestExecutor.js” file.

Well that ruined me for a sec,I didnt expect it at all.

Then after some research I’ve found that: “Tenant” needs to be added as “Read” permission in “ApplicationManifest.xml” configuration.

Capture16

And the other problem for me was using Chrome Browser.When you deploy app to Office 365,you should always use “Internet Explorer” as default browser because by default it lets you to select “Trust-Don’t Trust” option which is needed to run the app which Chrome doesn’t.

Thats all.If you have come across the same situation,this is the trick.

Advertisements

Export-SPWeb script to get backup all lists and libraries

Standard

Wrote this Powershell script according to my company’s needs,but you can fork and use it if you like

Export-SPWeb Script to get backup of all lists/libraries in a site collection.

But I’ll also share it here:

Add-PSSnapin Microsoft.Sharepoint.Powershell

$site = Get-SPSite
$path = "C:\Backup2015\ListBackups"
$serverurlpath =""
$listurlpath=""
$listurlwithoutformat=""
$dosyapath =""
$itemURLNEW=""

foreach($web in $site.AllWebs){
    $serverurlpath=$web.Url
    $serverlistsurlpath=$web.ServerRelativeUrl -replace "/","\"
    $serverurlport = ([System.Uri]$serverurlpath).Port
    $serverurlhost = ([System.Uri]$serverurlpath).Host.Split('.-') -join "_"   

    if($serverurlport -eq "80")
    {
     if(!(Test-Path -Path ($path + "\" + $serverurlport)))
     {
      New-Item -Path ($path + "\" + $serverurlport) -Type Directory
     }    

     if(!(Test-Path -Path (($path + "\" + $serverurlport + "\" + $serverurlhost))))
     {
       New-Item -Path ($path + "\" + $serverurlport + "\" + $serverurlhost) -Type Directory
     }

     foreach($list in $web.lists)
     {      

        If (!(Test-Path ($path + "\" + $serverurlport + "\" + $serverurlhost + $serverlistsurlpath))) {
              New-Item -Path ($path + "\" + $serverurlport + "\" + $serverurlhost + $serverlistsurlpath) -Type Directory
        }            

        $itemURLNEW= "$($list.RootFolder.ServerRelativeUrl)"
        if($serverlistsurlpath -eq "\")
        {
          $dosyapath = "$path\$($serverurlport)\$($serverurlhost)$($serverlistsurlpath)$($list -replace "/","\").cmp"
        }

        else
        {
          $dosyapath = "$path\$($serverurlport)\$($serverurlhost)$($serverlistsurlpath)\$($list-replace "/","\").cmp"
        }   

        if(!(Test-Path ($dosyapath)) -and $list.Hidden -eq $false)
        {
           export-spweb $web.URL -ItemUrl $itemURLNEW -IncludeUserSecurity -IncludeVersions All -path "$dosyapath" -nologfile
        }
     }
    }   

    if($serverurlport -eq "1111")
    {
     if(!(Test-Path -Path ($path + "\" + $serverurlport)))
     {
      New-Item -Path ($path + "\" + $serverurlport) -Type Directory
     }    

     if(!(Test-Path -Path (($path + "\" + $serverurlport + "\" + $serverurlhost))))
     {
       New-Item -Path ($path + "\" + $serverurlport + "\" + $serverurlhost) -Type Directory
     }

     foreach($list in $web.lists)
     {   

        If (!(Test-Path ($path + "\" + $serverurlport + "\" + $serverurlhost + $serverlistsurlpath))) {
              New-Item -Path ($path + "\" + $serverurlport + "\" + $serverurlhost + $serverlistsurlpath) -Type Directory
        }            

        $itemURLNEW= "$($list.RootFolder.ServerRelativeUrl)" 

        if($serverlistsurlpath -eq "\")
        {
           $dosyapath = "$path\$($serverurlport)\$($serverurlhost)$($serverlistsurlpath)$($list -replace "/","\").cmp"
        }

        else
        {
           $dosyapath = "$path\$($serverurlport)\$($serverurlhost)$($serverlistsurlpath)\$($list -replace "/","\").cmp"
        }       

        if(!(Test-Path ($dosyapath)) -and $list.Hidden -eq $false)
        {
           export-spweb $web.URL -ItemUrl $itemURLNEW -IncludeUserSecurity -IncludeVersions All -path "$dosyapath" -nologfile
        }
     }
    }
}

Solution of “Application Server Role, Web Server (IIS) Role: configuration error”

Standard

For some reason SharePoint 2013’s prerequisite msi cant find which server manager to use and fails installation of Prerequisite files.

So you need to go Windows/System32, find servermanager.exe ,duplicate it and then rename it to servermanagercmd.exe

After this,re-run prerequisite installer,it will work.

Capture4

If it doesn’t,you haven’t enabled downloading setup files remotely in mmc(group policy editor) settings.

To do this;
1-You need to add “GP Editor” Snapin in MMC.
2-Go to Computer Configuration->Administrative Templates-> System
2-Update “Specify settings for optional…” policy as Enabled
3-Update “Contact Windows Update…” as selected
4-Click Apply

Working with MySQL – EF5 – MVC5 Alltogether

Standard

For MySQL part;

Never install the MySQL from Web Platform Installer.Get to MySQL’s website and download MySQL Installer.

This installer package installs everything you need about database-end including;

MySQL Connector
MySQL for Visual Studio
MySQL 5.5 Database

For EF5 part;

Install EF5 via Nuget like this;

Install-Package EntityFramework -version 5.0.0

This will install EF5 which works great with MySQL Connector.

For MVC5 Part;

Download MVC5 package from Microsoft download page if you haven’t already.

Add reference to EF5 libraries:
MySQL.Data.Entity (4.5 version) –> This is for EF5

“MySQL.Data.Entity for EF6”  libraries are for Entity Framework 6.But be cautious; this library may not be compatible with the connector you’re using.They need to upgrade MySQL Connector according to EF6 since there are lots of changes.

Web.config settings:

<entityFramework>
    <defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF5"></defaultConnectionFactory>
  </entityFramework>
  <connectionStrings>
    <add name="YourEntities" connectionString="metadata=res://*/Models.YourModel.csdl|res://*/Models.YourModel.ssdl|res://*/Models.YourModel.msl;provider=MySql.Data.MySqlClient;provider connection string= server=localhost;user id=root;password=yourpass;database=yourdb " providerName="System.Data.EntityClient" />
  </connectionStrings>

If you’re using EF6,downgrade it to EF5.

NodeJS Series #6: Event-Driven Programming

Standard

Hi Wizards,

Its been some time since I’ve left Hogwarts Magicians School for a small holiday.Now that Im back,im ready for some tricks.

But before that,i’d like to talk about Event-Driven Programming and in its place in NodeJS

What is Event-Driven Programming?

Event-driven programming is the term where the flow of the code is determined by events(click,load,etc…)
Its one of the basic milestone today’s popular programming languages such as C#,Java and many more I dont wanna fill up here.
In Node.js and moreover in any kind of Javascript project,you’ll be using or used event-driven process.Whether its page onload or button click event,this is something you have achieved with our without knowing.

Lets make an example to the classic event-driven process and how its done in NodeJS:

result = getJSONfromDestination();
binddata(result);

The operation above requires blocking I/O process (single thread operation that waits for previously working synchronous code )

Now lets take a look at how we do asynchronous way to do it(Non-blocking I/O process)

json_finished = function(result){
binddata(result);
}
getJSONfromDestination(jsonfinished);

As you can see,this is non blocking sample,because json_finished doesnt work first as you can imagine.
It starts working when you call getJSONfromDestination method and sending param as function to json_finished.

This is how Asynchronous operations are completed in mainly Javascript projects and widely used in NodeJS projects.In case of working step-by-step,we send params to functions to start working whenever & however we want.

You’ll be using frequently these kind of Asynchronous operations or in other terms “Event-Driven Programming” style in almost all of your JS oriented applications,not to mention coding like that is a “must-have” in NodeJS applications.

Next article,we will be experiencing a real world problem for detailed workaround.