How to re-provision SharePoint user profile sync without loosing any user data

Here you have to remember on things to disable the “My Site Cleanup Job” before resetting the Sync database, otherwise you run the risk of it deleting all the user profiles in the farm as we found out during a reset: http://technet.microsoft.com/en-us/library/ff681014.aspx#resetSync
User profile sync serves as a staging area for data, and the data in profile store and social databases is the data consumed by the user profile service. So if the right steps are followed, you should be able to reset the sync service and related databases, without harming the user profile data. Here are a set of suggested steps:

1) Login as farm account
2) Backup the User Profile DB and the User Profile Sync DB
3) Stop the SharePoint Timer service:
PS D:\> net stop sptimerv4
4) Delete the data in the Sync DB using the following PowerShell script:
PS D:\> Get-SPDatabase
5) Copy the GUID associated with the User Profile Sync DB in the command line below
PS D:\> $syncdb=Get-SPDatabase -Id
6) Execute these commands, in exactly the following order. This is not a script. So please cut and paste each of these commands one by one.
PS D:\> $syncdb.Unprovision()
PS D:\> $syncdb.Status=’Offline’
PS D:\> Get-SPServiceApplication
#Copy the GUID associated with the User Profile Service and paste it after “Id” in the next command:
PS D:\> $upa=Get-SPServiceApplication -Id $upa.ResetSynchronizationMachine()
PS D:\> $upa.ResetSynchronizationDatabase()
7) Provision the Sync DB:
PS D:\> $syncdb.Provision( )
8 ) Add the User Profile Synchronization service account (farm account) as the dbowner on the Sync DB (using SQL Server Management Studio).
9 ) Start the SharePoint 2010 Timer service
PS D:\> net start sptimerv4
10) Start the User Profile Synchronization Service in the Central Administration UI.
11) After the User Profile Synchronization Service is started, reset IIS.
PS D:\> iisreset
12) Create connections to data sources in the Central Administration UI.
13) Run full user profile synchronization.

Posted in General Interest | Leave a comment

Difference between Team site and Publishing site SharePoint or Publishing feature enabled Team site

Difference between Team site and Publishing site SharePoint or Publishing feature enabled Team site

Publishing functionality is a set of two features, one at the Site Collection level and one at the Site level. You can activate them on any site like Team site, Document Center, Wiki site etc… You will find all the info on what publishing adds in that link, but here I want to showcase some reasons why I use Publishing for my clients.

The publishing site with workflow template is used similarly to the publishing site template to create sites designed to present web-based content. However, The publishing site with workflow template extends these capabilities by provisioning the resources need when content must be approved before it is made available to site users.once you create a site from this template you can configure the appropriate approval workflow to manage the content approval process.

The approval workflow is enabled by default only in the Publishing Site with Workflow site template. It can be used for content approval on a Web Site or an Intranet solution where the content must be reviewed before publication.

Note that the landing page of your team-site will be replaced by the standard publishing site, which will have the same look and feel as when you create a publishing site.

Usually we use Publishing site when we want to have a public facing site or an extranet that is exposed to the internet. And we use a Team site with Publishing enabled, when we want to keep things internal, but have more options for customizing you’re branding of your intranet.

Here is short details:

The Team site has the classic default list:

Announsement,Calendar,Links and Tasks

It also has plenty of document and page libraries. This kind of site is ready to work on for a team

Team site has a couple of text layouts, Publishing site have much more complex page layouts.

Simple moderation consists of the yellow bar, which gives us the page status (draft, checked out, approved, etc.). The Submit/Schedule buttons gives us the options to set the page as ready to be published where approvers can review the page before publishing it.

Posted in General Interest | Leave a comment

Edit Page option Grayed out

There are some of the other ways you can try.

  1. First one is there is a hack, just append ?ToolPaneView=2 or ??ToolPaneView=2 to the end of the URL. See if you are able if not.
  2. Check and  make sure that Publishing is turned off from the Site Features
  3. Third is checkout the page manually by by Navigate to Site Settings -> Site Content -> Site Pages -> Click on “…” next to page name -> Click on “…” -> Check out

Then try “Edit Page”

Posted in General Interest | Leave a comment

SharePoint 2013, Office Web Apps 2013 and Excel Service application issue

What is the Issue?

If you Installed office web app server and associated it with your SharePoint farm, now you have you SharePoint 2013 farm connected to a WAC 2013 farm and then you use all your Excel skills and starts retrieving data from other data sources.

You would be able to see the preview of Office documents in Search result, Preview of office documents in SP Document library and you will be able to edit the office documents word, excel, PowerPoint in web Browser.

But you won’t be able to see the excel Pivot table or Excel sheet’s data that is coming from outside [external data source] unfortunately your data will not refresh and you will get error.

There is conflicts between office web app Server and Excel Service application in SharePoint Issue is using Both Excel Service application and office web app server in SharePoint

For instance this is what you will get if you try to display a Power View worksheet:

When this issue occurs?

When we install office Web app server and associated it with SharePoint farm.

And our SharePoint Farm is configured with Excel Service application to utilize excel features in SharePoint.

So here if we have already configured the Excel Service application on SharePoint farm to use excel calculation service or render Excel Pivot table, you will be in trouble

We can use one of them either we can use office web app server or Excel Service Application.

 Excel Service Application in SharePoint, Why we need it?

Excel Service application is a feature of SharePoint that enable us to view and interact with Excel workbook in web browser window similar to how we use Excel Sheet on our local computer.

Excel Service application in SharePoint uses a built in calculation engine to connect to external data and render the data in Excel Sheet, Pivot table, queries and Formulas.

Excel Service uses server technology to provide Excel Calculation and similar functionality in browser window.

Excel Service was introduce in SharePoint 2007 Version and still we are using with latest version even in SharePoint online.

Office Web App Server in SharePoint, Why we need It?

Office Web App Server and Excel Service in SharePoint have a lot of common but they are not the same.

Both office web app Server and Excel Service application enable us to view Excel workbook in a browser window and both enables us to interact with Excel features and explore data in Excel on the web browser.

What is difference between two?

Excel Service application support external data connection, data models and ability to intract with items that use data model such as (Excel PivotChart report, Excel Pivot table, reports and timeline controls)

But office web app Server does not support external data connection or the ability to interact with reports that fetching the data out of the SharePoint such as external data source using BCS or other RDBMS. Office web app server provides feature to view and interact with excel workbook in browser as Excel Service application does.

Excel Service application provides more business intelligent functionality than office web app Server.

But Excel Service application does not support to create and Edit Excel workbook in Browser window, simply you can’t edit the Excel data in Browser.

Is there any service Limitation or what is Culprit?

“Office Web Apps 2013 cannot read data from external data sources” if your any Excel web part that fetching data outside from SharePoint like using BDC or BCS any other data source.

And Excel Service application does not support to create and Edit Excel workbook in Browser window, in other way if we say like user can’t edit the Excel workbook data in web Browser.

It means both have their own limitation and own specific features, and both have conflicts we can’t use both of them to achieve the similar functionality.

Let’s come to Solution now?

A common solution but that described most of the blogs is to remove only the Excel Web Access functionality from office web app Server to leverage the Excel Service application’s functionality so that we can show our excel data that is coming from external data source.

But in this case we will not be able to leverage the office web app server‘s functionality like excel preview and editing excel data in browser, not a good solution

What we need to do? To apply above solution Go to SharePoint Server machine [where you Central Admin hosted]

Go to SharePoint Management Shell by go to Start – All Programs – SharePoint 2013 Products – Click on SharePoint Management Shell

And type paste the following command.

Remove-SPWOPIBinding –Application Excel

Now you are able to use Excel Service feature and able to render all your excel Sheets that getting data from External data source as earlier you used to do. The Problem is

You are not using the office web app server’s cool features that provides to

View the preview of excel file, in SharePoint Search result or by Go to SP document library Click on three small dot … to see the document property and you will see the Previews of office document but you wont see the preview of Excel File, bad right.

 

See the snap shot here.

Office Document Priew Image

 

Editing in Browser no, you cant, see this.

EditinginBrowser

Then what is better solution : using this you can use all good features of Excel Service application and all good feature of office web app server, cool hmm ?

 

Better Solution to stop rendering Excel files in Office Web Apps 2013

SharePoint is very cool and SharePoint 2013 allows us to do suppressions for the different WOPI Bindings. What we would like to do is to suppress the WOPI Binding that is responsible for viewing of Excel files this means only for viewing the Excel sheet we will use Excel Service application.

What you need to do ?

Go to SharePoint Management Shell by go to Start – All Programs – SharePoint 2013 Products – Click on SharePoint Management Shell

And type paste the following command.

New-SPWOPISuppressionSetting -Extension XLSX -Action View

This command will suppress the WOPI Binding for the extension XLSX (Excel files) and for the WOPI Action View. If we now have Excel Services running in our SharePoint farm then Excel Services will be responsible for viewing Excel (XLSX) files. But Office Web Apps 2013 will be responsible for previews (in search and document libraries) and editing of the files.

You don’t have to do anything else, no IISRESET (this must be the only time you don’t need this for a SharePoint config change!) or anything else.

How to Verify if Excel files are rendered by Office Web Apps

If we want to check like Excel files are rendered using Office Web app server or Excel Calculation Service application we can easily take a look at the URL.

When you click on any Excel File and open it in browser check the URL

When Office Web Apps is responsible for the rendering the URL will look something like this:
https://server/_layouts/15/WopiFrame.aspx?sourcedoc=/Documents/excel.xlsx&….
And when Excel Calculation Service application is rendering the document it should look like the following:
https://server/_layouts/15/xlviewer.aspx?id=/Documents/excel.xlsx&…

 

You can also check the WOPI suppression settings using the Get-

SPWOPISuppressionSetting cmdlet if you have shell access to the SharePoint farm.

If you want you’re Office Web Apps viewing back…

No doubt in this anytime we can revert back to using the Office Web Apps for rendering of the Excel files. This is done using the

Remove-SPWOPISuppressionSetting cmdlet.

 

Conclusion Sir Ji:

Basically for every farm where you are using BI features such as Excel Services and/or PowerPivot you need to do this WOPI suppression setting. But if you don’t have these requirements you should stick to using Office Web Apps 2013, to avoid unnecessary Service Applications and take advantage of the features in WAC that are not available in Excel Services.

 

 

 

 

Posted in General Interest | Leave a comment

Inventory report of All SharePoint site’s Document Libraries, Document Sizes

The Script will generate the report and show the each document, folder size in all of the SharePoint Document library on SharePoint Site.

The script is really quite straightforward – it simply iterates through all Web Applications, Site Collections, Webs, Document Library, and finally, each Document. I skipped any List that is not a Document Library (as well as the Central Admin site) and then build the report and exported in CSV file that you can open in Excel to use the Excel Pivot table.

The code is also taking care for the list view threshold if you have more items it will bring only 2000 items in one query so performance point of view you no need to worry when you run on production server.

What you have to do

  1. Copy the code and save as .ps1 file with any name
  2. Open the file and change the site collection URL [The site you want to generate the report]
  3. Execute the script, that’s it.

The generated report from Utility excel sheet looks like below.

CSV File Output (1)

You can make the Pivot table from the generated output file like below

Pivot Table Audit Version Report for Doc Library (1)

Here is the script :

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint"# Get a reference to the target site 
write-host "Script Started, Please wait..." 
Function Get-SPWebApplication() 
{    
  Param( [Parameter(Mandatory=$true)] [string]$WebAppURL ) 
  return [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($WebAppURL) 
} 
Function global:Get-SPSite() 
{ 
  Param( [Parameter(Mandatory=$true)] [string]$SiteCollURL ) 
  
   if($SiteCollURL -ne '') 
    { 
    return new-Object Microsoft.SharePoint.SPSite($SiteCollURL) 
   } 
} 
   
Function global:Get-SPWeb() 
{ 
 Param( [Parameter(Mandatory=$true)] [string]$WebAppURL ) 
  $site = Get-SPSite($WebAppURL) 
        if($site -ne $null) 
            { 
               $web=$site.OpenWeb(); 
            } 
    return $web 
} 
#EndRegion 
  
 Function GenerateVersionSizeReport() 
 {   
    #Define 'Web Application URL' as Mandatory Parameter 
    Param( [Parameter(Mandatory=$true)] [string]$WebAppURL ) 
   
 #Get the Web Application 
    $WebApp=Get-SPWebApplication($WebAppURL$rootSite = New-Object Microsoft.SharePoint.SPSite($WebAppURL) 
     #Write the CSV Header - Tab Separated 
 "Site Collection Name `t Site Name`t Library `t File Name `t File URL `t File Type `t Created Date `t Created By `t Last Modified `t Modified By `t No. of Versions `t Latest Version Size(MB) `t Versions Size(MB) `t Total File Size(MB)" | out-file VersionSizeReport.csv 
  #Arry to Skip System Lists and Libraries 
 $SystemLists =@("Pages""Converted Forms""Master Page Gallery""Customized Reports",  
                 "Form Templates""Images""List Template Gallery""Theme Gallery""Reporting Templates",  
         "Site Collection Documents""Site Collection Images""Site Pages""Solution Gallery",  
                               "Style Library""Web Part Gallery","Site Assets""wfpub") 
   #Get Last Year's Same day! 
 $DateFilter=([DateTime]::Now.AddYears(-1)) 
    #Loop through each site collection 
      #Loop through each site in the site collection 
     foreach($Web in $rootSite.AllWebs) 
   { 
            #Loop through  each List 
            foreach ($List in $Web.Lists) 
            { 
                #Get only Document Libraries & Exclude Hidden System libraries 
                if (  ($List.BaseType -eq "DocumentLibrary") ) 
                { 
write-host "Report generating is in Progress.....!" 
write-host "Report generating is in Progress for the Library Name:  " + $List.Title 
 
$spQuery = New-Object Microsoft.SharePoint.SPQuery 
$spQuery.ViewAttributes = "Scope='Recursive'"$spQuery.RowLimit = 2000 
$caml = '<OrderBy Override="TRUE"><FieldRef Name="ID"/></OrderBy>'  
$spQuery.Query = $caml  
 
do 
{ 
    $listItems = $List.GetItems($spQuery) 
    $spQuery.ListItemCollectionPosition = $listItems.ListItemCollectionPosition 
    foreach($ListItem in $listItems) 
    { 
             
          #Consider items with 5+ versions And apply Date Filter 
                        if ( ($ListItem.Versions.Count -gt 0) -and ( $ListItem['Modified'-lt $DateFilter)) 
                        { 
          $versionSize=0 
  
                            #Get the versioning details 
                            foreach ($FileVersion in $ListItem.File.Versions) 
                            { 
                                $versionSize = $versionSize + $FileVersion.Size; 
                            } 
       #To Calculate Total Size(MB) 
       $ToalFileSize= [Math]::Round(((($ListItem.File.Length + $versionSize)/1024)/1024),2) 
         
                            #Convert Size to MB 
                            $VersionSize= [Math]::Round((($versionSize/1024)/1024),2) 
         
       #Get the Size of the current version 
       $CurrentVersionSize= [Math]::Round((($ListItem.File.Length/1024)/1024),2) 
 
 
 #Get Site Name  
                            if ($Web.IsRootWeb -eq $true)  
                            {  
                                $siteName = $Web.Title +" - Root";  
                            }  
                            else  
                            {  
                                $siteName$Site.RootWeb.Title + " - " + $Web.Title;  
                            }  
  
                            #Log the data to a CSV file where versioning size > 0MB! 
try 
{ 
                            if ($versionSize -ge 0)  
                            { 
                          
                                "$($WebAppURL) `t $($Web.Title) `t $($List.Title) `t $($ListItem.Name) `t $($Web.Url)/$($ListItem.Url) `t $($ListItem['File Type'].ToString()) `t $($ListItem['Created'].ToString()) `t $($ListItem['Author'].ToString()) `t  $($ListItem['Modified'].ToString()) `t $($ListItem['Editor'].ToString()) `t $($ListItem.Versions.Count) `t $CurrentVersionSize `t $($versionSize) `t $($ToalFileSize)" | Out-File VersionSizeReport.csv -Append 
                            } 
} 
catch 
{ 
write-host "Got error to write, skiping ..." 
} 
                        }            
} 
} 
while ($spQuery.ListItemCollectionPosition -ne $null) 
 }  
  } 
          } 
  $Web.Dispose()           
   } 
 $rootSite.Dispose()             
  GenerateVersionSizeReport "http://ptcpasaspapp01/sc6" 
    #Send message to console 
    write-host "Versioning Report Generated Successfully!" 
$userinput = Read-Host "Press Enter or any key to close this window"
Posted in General Interest | Leave a comment

Best Practices SharePoint Client object Model

As full trust code is deprecated in SharePoint 2013, and Microsoft is pushing SharePoint Online and the App model and here we are bound to use Client object model so, many developers are finding that they must move from the server side object model to the client side object model (CSOM) With this, there are a number of challenges: many features are missing in the client object model, and many tasks that were once easy are now difficult. Hre are some points that we must consider when we work with CSOM

Best Practice 1. We should only request what we want [ and here again we must request everything we want in one go]

Example: We must explicitly request every property of every object we want. This is really a fundamental basic of CSOM programming – after all, it’s designed to be used across a network. If you only need a user’s Title and LoginName, then only request those:

 var objUser = clientContext.Web.CurrentUser;

clientContext.Load(obUser, user => user.Title, user => user.LoginName);

 later on in our code if we need to send the user an email, then add their email address to the earlier request. Don’t go back to the server twice! The cost of always requesting an additional property is miniscule in comparison to going all the way to the server and back an extra time later on.

Best Practice 2. Run ClientContext.Executequery or ClientContext.ExecuteQueryAsync before accessing any item properties.

Example: a. var clientContext = SP.ClientContext.get_current();

b. var web = context.get_web();

c. var currentUser = web.get_currentUser();

d. groupCollection = currentUser.get_groups();

e. context.load(currentUser);

f. context.load(groupCollection,

 ‘Include(Title,Id,Users.Include(Id,Title,LoginName))’);

g. context.executeQueryAsync(function () {

h.    var termArray = [];

i.    var groupEnumerator = groupCollection.getEnumerator();

j.    while (groupEnumerator.moveNext()) {

k.       var oGroup = groupEnumerator.get_current();

l.       var groupName = oGroup.get_title();

m.       termArray.push({ groupName: groupName });

n.       }

o.    }

p.    , function (s, a) {

q.       Console.log(a.get_message());

r. });

This example is based on the JavaScript object model. Line ‘a’ gets the current SharePoint context, Line ‘b’ gets the web object, ‘c’ gets the current logged in user, and ‘d’ gets all the groups current user belongs to. If you notice, all four statements are dependent on each other.

Until Line ‘d’, none of the objects are retrieved yet. The next two statements are instructions to load the objects and statement. In Line ‘g’, ‘executeQueryAsync’ is actually responsible for retrieving the objects and the properties.

For example:Note: This is a client side code in C#.

a. ClientContext context = new ClientContext(“http://siteCollUrl”);

b. Web web = context.Web;

c. context.Load(web, w => w.Title);

d. context.ExecuteQuery();

e. GroupCreationInformation grpCreationinfo =

 new GroupCreationInformation();

f. grpCreationinfo.Title = web.Title + “_NewGroup”;

g. grpCreationinfo.Description = “New group creation”;

h. web.SiteGroups.Add(grpCreationinfo);

i. context.ExecuteQuery();

In the above example, the web’s title is used to create a group. Because the web’s title is of type value, we need to use ExecuteQuery to retrieve the title first and then create the group.

Objects like Web, ClientContext are passed by reference which is they are not copied. So there is no need to worry about performance. However pasing ClientContext object as a parameter between methods make more sense as we can then load whatever objects we want from it inside the method.

Best Practice 3. Use an exception handling scope to catch exceptions

Example: The below example shows how to create and use an exception handling scope with an ExceptionHandlingScope object. The scenario is to update the description of a list and also enable folder creation. There is a possibility that the list might not exist.
// Starting with ClientContext, the constructor requires a URL to the
// server running SharePoint.
ClientContext context = new ClientContext(“http://SiteUrl”);

ExceptionHandlingScope scope = new ExceptionHandlingScope(context);

using (scope.StartScope())
{
using (scope.StartTry())
{
List fooList = context.Web.Lists.GetByTitle(“Sample”);
fooList.Description = “In Try Block”;
fooList.Update();
}
using (scope.StartCatch())
{
// Assume that if there’s an exception,
// it can be only because there was no “Sample” list.
ListCreationInformation listCreateInfo = new ListCreationInformation();
listCreateInfo.Title = “Sample”;
listCreateInfo.Description = “In Catch Block”;
listCreateInfo.TemplateType = (int)ListTemplateType.Announcements;
List fooList = context.Web.Lists.Add(listCreateInfo);
}
using (scope.StartFinally())
{
List fooList = context.Web.Lists.GetByTitle(“Sample”);
fooList.EnableFolderCreation = true;
fooList.Update();
}
}

context.ExecuteQuery();  

Best Practice 4. We must call Call ExecuteQuery Sparingly

Example: Again, an obvious one. But there are scenarios where you will be calling ExecuteQuery where you don’t need to. In case you didn’t know, ExecuteQuery is the method that causes all of your requests to go to the server in a single batch, so it’s slow!

In the below example a look at this scenario. If we are creating a list, we might think we need to write code as follows:

List list = web.Lists.Add(…);

ctx.ExecuteQuery(); //Create the list

ctx.Load(list, l => l.DefaultViewUrl); // Request the new list’s URL

ctx.ExecuteQuery(); // Get the new list’s DefaultViewUrl

In fact, you don’t need that first ExecuteQuery. It’s not intuitive, but you can create the list, get its URL, and submit both requests in one go:

This is an example of the type of creative way you can help prevent performance issues by minimizing the number of times you call ExecuteQuery.

Best Practice 5. Caching Data in the Session

Example: If every page in our app is requesting the same data from SharePoint, then we can store it temporarily in the user session cache. This will prevent having to make a round trip to the SharePoint server on every page request. Additionally, since it’s in the user session cache, it is scoped to each user individually. If we want to cache application-wide data, you can store it in the Application cache. See this MSDN article for more information.

So, let’s assume a scenario where each page checks whether or not the user is allowed access to it based on whether they are a site administrator:

public bool CheckPrivileges()

{

    var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);

    using (var clientContext = spContext.CreateUserClientContextForSPHost())

    {

        var currentUser = clientContext.Web.CurrentUser;

        clientContext.Load(currentUser, u => u.IsSiteAdmin);

        clientContext.ExecuteQuery();

        return currentUser.IsSiteAdmin;

    }

}

We can simply wrap that CheckPrivileges method in another that performs session caching:

Hide   Copy Code

public bool CheckPrivilegesWithSessionCaching(HttpContextBase httpContext)

{

    string key = “IsSiteAdmin”;

    var keys = httpContext.Session.Keys.Cast<string>().ToList();

    if(keys.Contains(key))

    {

        return (bool)httpContext.Session[key];

    }

    else

    {

        bool result = CheckPrivileges(httpContext);

        httpContext.Session[key] = result;

        return result;

    }

}

Note that if we are storing large amounts of data, this solution won’t scale well (since it is ‘In Memory’ caching) – we could store cached data in our database instead.

Additionally, we cannot assume that data will be available in the session cache – it could be cleared by ASP.NET at any time, or, due to load balancing it could be cached differently on separate servers. As long as you go back to SharePoint to retrieve it when necessary, this shouldn’t be a problem.

Best Practice 6. Use CAML Query to Filter Retrieval of List Items

Example: If we are retrieving some items from a list, it is tempting to retrieve all items and then filter it in our code. However, we can use CAML queries to perform the filtering server side. It can be a little bit awkward (coding in XML) but it’s worth getting right for the potential speed increases we will see, especially for large lists.

For example, this is the lazy way to get list items:

CamlQuery query = CamlQuery.CreateAllItemsQuery();

var items = list.GetItems(query);

And here’s a formatted CAML query with a where clause:

CamlQuery query = new CamlQuery()

{

    ViewXml = string.Format(“<View><Query><Where><Eq><FieldRef Name='{0}’ /><Value Type=’String’>{1}</Value></Eq></Where></Query></View>”,

                        “FirstName”, “Eric”)

};

 var items = list.GetItems(query);

Note the ‘View’ outer tag which is required when querying with CSOM, unlike the server object model version.

Here’s another trick – we can actually get all folders, subfolders and/or files from a document library, in a single query, by specifying RecursiveAll:

CamlQuery allFoldersCamlQuery = new CamlQuery()

{

    ViewXml = “<View Scope=’RecursiveAll’>”

                        + “<Query>”

                        + “<Where>”

                        + “<Eq><FieldRef Name=’FSObjType’ /><Value Type=’Integer’>1</Value></Eq>”

                        + “</Where>”

                        + “</Query>”

                    + “</View>”

};

In the above query, Scope is set to RecursiveAll. Also, I’m setting the field FSObjType=1 – this means that only folders are returned. If you want only items, set FSObjType=0. If you want both files and folders, omit it entirely.

You can actually go even further – retrieving all items from multiple lists, by enumerating through the lists and using a caml query on each. The important thing is that you only call ExecuteQuery once, at the end.

Best Practice 7. Use conditional scope to test for preconditions before loading data

Example: To conditionally execute code, set a conditional scope by using a ConditionalScope object. For example, retrieve the list property when the list is not null. You will also need to add usingstatements for System.Collections.Generic and System.Linq. Also, add an alias to the using statement for the Microsoft.SharePoint.Client namespace so you can refer to its classes unambiguously. For example, using SP = Microsoft.SharePoint.Client;.
C#
// Starting with ClientContext, the constructor requires a URL to the
// server running SharePoint.
ClientContext context = new ClientContext(“http://SiteUrl”);

SP.List list = context.Web.GetCatalog(ListTemplateType.WebPartCatalog);
BasePermissions perm = new BasePermissions();
perm.Set(PermissionKind.ManageLists);

ConditionalScope scope =
new ConditionalScope(context,
() => list.ServerObjectIsNull && context.Web.DoesUserHavePermissions(perm).Value);
using (scope.StartScope())
{
context.Load(list, l => l.Title);
}
context.ExecuteQuery();

label1.Text = scope.TestResult.Value;

if (scope.TestResult.Value)
{
label1.Text = list.Title;
}  

Posted in General Interest | Leave a comment

Sandbox solution for o365 public site, access URL to Upload solution

https://<ourdomainname>-public.sharepoint.com/_catalogs/solutions, but why the Microsoft removed the link from site setting page of 0365 public site, long story short, lets have a look.

Without Sandboxed solutions, there is no way to add a custom web part to the site. The Web Part Gallery link is gone from the site setting page  so we can’t upload a custom web part definition. Even if we could, the web part would have to be just a variation of an out of the box web part with, perhaps some predefined settings. Without solutions, there’s no need to monkey with the existing web parts.

Sandboxed solutions are resource throttled. We can see why Microsoft would remove the use of Sandboxed solutions due to throttling capabilities. In a public site scenario, anonymous users can access the site. If our web site has a certain functionality that will cease to execute after a throttle threshold has been hit, it’s conceivable to think that a form of attack could be done by an anonymous user to force the site to hit the throttle threshold on a daily basis. Upping the throttle level only delays the inevitable while removing the throttle opens the door to unnecessary load on the system as a whole. Nixing the whole sandboxed solutions from the start fixes the problem completely.

Anything that a web part can do, a SharePoint App can do. With the addition of the SharePoint App Store, the need for custom web parts has diminished. Additionally, with the App store, the functionality of the apps can be offloaded to other servers which hosts the app thus reducing the strain on the Office 365 front end servers. These front end servers can focus on doing what they’re fine-tuned to do, serve web pages without balancing resources for executing the custom business logic of the sandboxed solutions.

After all this, if we are still bent on installing that Sandboxed Solution to your public Office 365 SharePoint site, fear not, there are some options/hacks. At the time of this article, though the O365 team cleverly removed the link to the Solution library from the Site Settings page, it doesn’t necessarily mean that the functionality is ACTUALLY gone. By directly navigating to the library, you could be able to upload and activate your solution. To access the library directly, use the following URL:

https://<ourdomainname>-public.sharepoint.com/_catalogs/solutions

Here, you will see the Solutions library that you’ve grown to love. Feel free to upload the solution and activate it at will while keeping in mind the resource throttling issue mentioned earlier.

Apart from the Sandbox solution link what else we can have is

Now that we know that some links are simply removed from sight and the functionality is not pulled, what other links should be available? Let’s see if we can find some of the relevant ones…

  • Web Part Gallery  – https://<yourdomainname>-public.sharepoint.com/_catalogs/wp  – Accessible – You can also still select New from the Ribbon, find a whole slew of additional web parts and populate them to your site.
  • Site Content Types  – No Access
  • Site Collection Features  – No Access
  • Site Features  – No Access

List Templates – https://<yourdomainname>-public.sharepoint.com/_catalogs/lt  – Accessible

Posted in General Interest | Leave a comment

Minimal-Download-Strategy-Feature-SharePoint 2013

New feature in SharePoint 2013
What it does: This feature Improve SharePoint site’s performance when user navigate from one request to another request, it reduces page load time by sending only the differences when users navigate from one page to new page in SharePoint site. This feature The Minimal Download Strategy is by default enabled on Team sites, Community sites and a few others in SharePoint 2013

Minimal Download Strategy (MDS) is a new technology in SharePoint 2013 that reduces the amount of data that the browser has to download when users navigate from one page to another in a SharePoint site. When users browse an MDS-enabled site, the client processes only the differences (or delta) between the current page and the requested page. Figure 1 shows the sections that change from page to page and therefore require an update. The delta usually includes the data in the (1) content areas, as well as other components such as (2) navigation controls.

You can identify a site that has MDS enabled by looking at the URL. An MDS-enabled site has the (3) _layouts/15/start.aspx page in the URL followed by a hash mark (#) and the relative URL of the requested resource, For example, the following is the MDS-formatted URL for the page newpage.aspx:

https://sp_site/_layouts/15/start.aspx#/SitePages/newpage.aspx

It is equivalent to the following non–MDS-formatted URL:

https://sp_site/SitePages/newpage.aspx

This functionality comes with Site feature and provide plug gable capabilities so that we can activate or deactivate on site.
How it works: Once the MDS features feature is enabled [activated on site] all pages of the SharePoint sites rendered through /_layouts/15/start.aspx
This start.aspx is responsible to loading the pages from site using the MDS. The start.aspx has a specific javascript object asyncDeltaManager (defined in start.js) basically it parse the URL and looks for the # and takes the path following that and dynamically loads the page

Subsequent requests to pages are dynamically loaded through the asyncDeltaManager object. Once a link is clicked it will invoke a method in the JavaScript object which creates the MDS URL and appends the query string parameterAjaxDelta=1. A request is created and downloaded asynchronously and only the “delta” is returned to the client and assembled and rendered using JavaScript.
The PageRenderMode control
There is one control called PageRenderMode that can be used on a master page, web part page or page layout. This control has one property called RenderModeType which can have one of two possible values;Standard or MinimalDownload. If the control is placed on a page and have the property set to Standard – it will prohibit the page from being rendered using MDS. If the control is not present or if it’s property is set to MinimalDownload it can participate in MDS rendering. So this control can be used on specific (master)pages to prohibit MDS.

A word of caution here, if you’re using the Design Manager to generate master pages, this control will automatically be inserted into the generated artifacts.
Another gotcha here is that even if you have the PageRenderMode control set to MinimalDownload whenever the publishing features are enabled and you have the ribbon on the page, specifically when using the PublishingRibbon in your master page, SharePoint will automagically inject, during runtime, the PageRenderMode control with the property set to Standard.

Posted in General Interest | 1 Comment

User is not removing from SharePoint 2013 site, showing user name in People picker after deleting from Active directory

In SharePoint all versions User Information List (UIL) in a site collection from SharePoint 2010 and 2013. SharePoint stores user information in the UIL to extract data when this user is being searched by the people picker.

The people picker extracts information from multiple locations:

– The User Information List and
– Active Directory

The people picker does not extract information from the User Profile Service Application (UPSA). The UPSA syncs information from the AD and updates the UIL but it does not delete the user from it. Like if we delete the user from AD it will not delete from UIL

If we delete the user from the Active Directory and navigate back to SharePoint to see what happened.

– we no longer can log on with that user
– we can still find “deleted user name” with the people picker.

– The permissions are still visible for the deleted user in SharePoint site

We need to delete this user from the Site Collection so this user won’t be found by the people picker and the permissions will be deleted for the deleted user from SharePoint site.

Solution

Even we can’t just click on the user and delete him because we’ll be redirected to the My Site (the My Site will be scheduled for deletion in 14 days by the My Site Cleanup Timer Job) default time

You will have to add the following right behind the URL, we need to go to Uuser Information List by typing the following URL and need to delete the user from there

SharePoint 2010

<URL>/_layouts/people.aspx?MembershipGroupId=0

SharePoint 2013

<URL>/_layouts/people.aspx?MembershipGroupId=0

or

<URL>/_layouts/15/people.aspx?MembershipGroupId=0

we can now choose the user

and click on “Actions –> Delete Users from Site Collection

After deleting the user From UIL we can now

– no longer log on with “Deleted user”
– no longer find him using the people picker
– no longer find his permissions because they have been deleted

Downside is that you’ll receive the following error till next 14 days. While clicking on this user at documents

Posted in General Interest | 1 Comment

Site Collection Administrator and Site Owners in SharePoint 2013, little confusion when we assign the Security principle.

Please find to the point conclusion about the both, it took time to understand me but be clear by following analysis.

Below things are only about Site Collection Owners

  • Are controlled via `Central Administration | Application Management | Change site collection administrators’
  • When you create a site collection, Windows SharePoint Services automatically lists you as the site collection owner.
  • You must have at least one and maximum of two owners and they become both “Site Collection Owners” and “Site Collection Administrators”
  • Both must be users (groups are not allowed)
  • Will receive email in case of e.g. quota limits reached, or site not being used (this is configured by Farm admin)
  • Site collection owners and secondary owners are also site collection administrators. However, owners and secondary owners are the only users who receive e-mail notifications for events, such as the pending automatic deletion of inactive sites. By default, site collection owners also receive requests for access from users who have been denied access. A user who is a member of the Administrator site group can use the Site Administration pages to change the e-mail address that receives requests for access.
  • If you remove a person who is “Site Collection Owner” as part of modifying “Site Collection Administrators” in Site Settings in the Site Collection he/she is removed from “Site Collection Owners” as well. If it’s the Primary Owner then the Secondary Owner becomes Primary Owner, if there is no Secondary Owner, the first user in the list of Site Collection Administrators become new Primary Owner

Below things are only about Site Collection Administrators.

  • Are controlled via Site Settings | Site collection administrators
  • Have full permissions in the site collection
  • They can view, add, delete, or change all content within those sites as well. They can add and remove users from sites and send invitations to those sites
  • Can be users or groups
  • Configured via Site Collection administration not from SP Admin

 Note: The————– Owners group of a site (THERE IS A OWNERS GROUP IN YOUR SITE GO TO SITE LEVEL PERMISSIONS IT IS ON THE LEFT PANEL) is not the same as the site collection owners(SITE COLLECTION OWNERS IS NOT IN THE SAME PLACE OF YOUR SITE LEVEL OWNERS GROUP, YOU WILL NOT FIND SITE COLLECTION OWNERS IF YOU GO TO YOUR SITE LEVEL PERMISSIONS YOU WILL NOT FIND A GROUP FOR THEM, CAN NOT BE SET THERE), which themselves are called site collection administrators in the Central Administration(NOW, THE SITE COLLECTION OWNERS ARE CALLED ADMINS IN SP ADMIN) user interface, even though site collection owners receive email notifications that the site collection administrators do not

Posted in General Interest | Leave a comment