Quantcast
Channel: nikpatel.net
Viewing all 86 articles
Browse latest View live

Adjust Cache Size of the SharePoint 2013 Distributed Cache Service Part I – Overview

$
0
0

Note: This article is part of series of articles showcasing different approaches & variations to adjust cache size of the SharePoint 2013 Distributed Cache service using PowerShell commands – Set-AFCacheHostConfiguration and Update-SPDistributedCacheSize.

This is overview article and provides background information on why and what method you should use to adjust cache size of SharePoint 2013 Distributed Cache Service.

Next Article in this series -

Fine tuning and adjusting Distributed Cache size on SharePoint 2013 farm would be one of the most frequent and often ignored SharePoint administrative tasks. If you are the SharePoint administrator managing SharePoint 2013 farm, you must take Distributed Cache service seriously. Microsoft has released first ever official warning in SharePoint Products history – “The Distributed Cache service can end up in a non-functioning or unrecoverable state if you do not follow the procedures that are listed in this article – http://technet.microsoft.com/en-us/library/jj219613.aspx. In extreme scenarios, you might have to rebuild the server farm.”

There are various aspects of managing Distributed Cache service but one of the most important would be allocating proper memory & adjusting cache size for Distributed Cache service. There are various reasons why you would adjust default Cache Size of SharePoint 2013 Distributed Cache Service.

  • When SharePoint Server 2013 is installed, it assigns the Distributed Cache service 10% of the total physical memory on the server. The Distributed Cache service uses half of that memory allocation for data storage (also known as cache size, 5% cache size), and the other half of that memory allocation is used for memory management overhead. When the cached data grows, the Distributed Cache service uses the entire 10 percent of the allocated memory. In most cases, initial 5% cache size may not be enough and you may require to increase cache size to support various SharePoint features. e.g. when you install SharePoint 2013 on 8 GB RAM (8192 MB RAM), it would allocate 410 MB (5% of 8GB RAM) to the Distributed Cache size. This may not be enough to support 50 concurrent user’s My Site activities and it may require to increase the Distributed Cache size.
  • On a server that has more than 16 GB of total physical memory, allocate a maximum of 16 GB of memory to the Distributed Cache service. If you allocate more than 16 GB of memory to the Distributed Cache service, the server might unexpectedly stop responding for more than 10 seconds. If the cache host’s size is larger than 16GB/8GB, garbage collection could take long enough to cause a noticeable interruption for clients. This is interesting and most probably more common scenario in Production farm. e.g. If server running Distributed Cache service have 32 GB RAM allocated, you must change Distributed Cache memory allocation to maximum to 16 GB (8 GB Cache Size).
  • During ongoing SharePoint farm maintenance, when you add physical memory to the server, Distributed Cache service does not automatically recalculate the 10% memory allocation. So, when you increase or decrease the total physical memory on the server, you have to manually increase or decrease the Distributed Cache service’s memory allocation.

You may ask, Ok, I understood why I need to adjust default cache size of SharePoint 2013 Distributed Cache Service but what would be ideal cache size allocated to my SharePoint server running Distributed Cache service. In most cases – I would say it depends.

  • If you are running Distributed Cache on one of the application servers running Search, it would be hard to calculate ideal memory allocation. Microsoft recommends not running Distributed Cache on application servers along with Search and other service applications.
  • If you are running Distributed Cache on dedicated server, I would suggest to work through Microsoft formula.
    • For 24 GB RAM SharePoint server running only Distributed Cache service in dedicated mode, you shouldn’t be allocating more than 8 GB RAM cache size (remember 16 GB is max recommended total memory allocation) to the Distributed Cache.
    • For 16 GB RAM SharePoint server running only Distributed Cache service in dedicated mode, you shouldn’t allocate more than 7 GB RAM cache size (16 GB – 2 GB for server OS memory = 14 GB Distributed Cache memory allocation) to the Distributed Cache.
  • If you are running Distributed Cache on collocated mode on web front end servers, please plan to ensure additional memory required by SharePoint foundation Web Application service and any other additional incoming user requests processes overhead.

TechNet has brilliant guidelines on how to change and measure Distributed Cache Size on SharePoint 2013 but as always, it’s missing some of the finer details. Although there are various different PowerShell commands available to adjust memory allocation for Distributed Cache SharePoint Service (App Fabric Cache Windows Service) including Update-SPDistributedCacheSize (SharePoint 2013 cmdlet), Set-AFCacheHostConfiguration (Windows Server AppFabric 1.1 cmdlet), and Set-CacheHostConfig (Windows Server AppFabric 1.0 cmdlet), TechNet has demonstrated only somewhat limited but much more preferred Update-SPDistributedCacheSize approach. In my article, I won’t explain adjusting Distributed cache size using Set-CacheHostConfig command. SharePoint 2013 Distributed Cache is based on Microsoft AppFabric 1.1 for Windows Server. Not only because Set-CacheHostConfig may not work (works fine in Single Server SharePoint farm VM for developer machines, haven’ tested for multi-cache hosts scenarios) but it’s previous version of Windows Server AppFabric 1.0 cmdlet.

Josh Gavant from Microsoft has brilliant two parts article to explain difference between these two commands and when and why you would choose one option or other. Essentially, you would run Update-SPDistributedCacheSize (preferred approach for SharePoint Distributed Cache service as per TechNet) when you would like to configure same cache memory size on all the Cache host on Cache cluster  and use Set-AFCacheHostConfiguration (equally works great and my preferred approach) when you would like to adjust cache memory allocation to different sizes for different Cache host in Cache cluster.

In next articles of this series, I will walk through different scenarios & use cases and step by step guides to change cache size using both Set-AFCacheHostConfiguration and Update-SPDistributedCacheSize commands. In my book, both options are valid but one option might be better than other in your given scenario.

Stay tuned for two more articles on this series!!!!

Additional Resources


Filed under: Distributed Cache, SP2013 Admin

Adjust Cache Size of the SharePoint 2013 Distributed Cache Service Part II – Using Set-AFCacheHostConfiguration Command

$
0
0

Note: This article is part of series of articles showcasing different approaches & variations to adjust cache size of the SharePoint 2013 Distributed Cache service using PowerShell commands – Set-AFCacheHostConfiguration and Update-SPDistributedCacheSize.

This is 2nd article in this series and provides step by step guide for SharePoint Admins to configure Distributed Cache size using Set-AFCacheHostConfiguration command and high level guidance on why and when you should use this command.

Use Cases

  • If you have servers in your distributed cache cluster with different RAM allocated to physical or virtual machine and Set-Update-SPDistributedCacheSize may not be viable option to allocate same RAM on inadequate servers.
  • If you have application servers running as inactive cache host part of cache cluster for Distributed Cache administrative purpose and you would like to avoid resizing or adjusting default cache size on inactive cache hosts.

Pros

  • You can specify different cache sizes for each host
  • Works great where you have different physical or virtual RAM allocated to the cache hosts

Cons

  • This is not SharePoint cmdlet and may not gain any respect from hardcore seasoned SharePoint professional. Additionally, keep an eye on future SharePoint service packs where it may dependent on future version of Microsoft AppFabric version which may have different cmdlets. e.g. Microsoft AppFabric 1.0 for Windows Server had Set-CacheHostConfig and Microsoft AppFabric 1.1 for Windows Server has Set-AFCacheHostConfiguration to change memory cache information. Since Set-Update-SPDistributedCacheSize is SharePoint wrapper for AppFabric cmdlet, it’s safe to assume Set-Update-SPDistributedCacheSize would work for future service packs.

Syntax

Set-AFCacheHostConfiguration – Updates the configuration settings for a Cache host to the specified values. This cmdlet is part of Microsoft AppFabric 1.1 for Windows Server caching powershell cmdlets. Only CachePort and ComputerName is required field. Notice this command would not only allow you to adjust Cachesize but allows you to adjust advanced settings like lead host, high watermark, and low watermark settings.

Set-AFCacheHostConfiguration [-ComputerName] <String> [-CachePort] <Int32> [-ArbitrationPort <Int32> ] [-CacheSize <Int64> ] [-ClusterPort <Int32> ] [-HighWatermark <Int32> ] [-IsLeadHost <String> ] [-LowWatermark <Int32> ] [-RefreshNow] [-ReplicationPort <Int32> ] [ <CommonParameters>]

Scenario

I have a multi-server farm with 2 WFEs (Niks-SP13-Web1, Niks-SP13-Web2) and 2 App Servers (Niks-SP13-App1, Niks-SP13-App2). When I have installed SharePoint 2013 on all servers in farm, it started Distributed Cache by default on all the servers. I have stopped Distributed Cache service on all Application servers from Services on Server page on central admin. Having stopped Distributed Cache service on all Application servers, these servers would be part of Cache cluster and allows us to manage Distributed Cache from the Application Servers using PowerShell. If your server isn’t part of Cache Cluster, you can’t login to the server and run Distributed Cache commands to adjust the memory allocation.

Initially I had allocated 4 GB RAM to 2 WFEs virtual machines and 5 GB RAM to 2 App Servers virtual machines during SharePoint installation. During default Distributed Cache configuration, SharePoint has allocated 205 MB (5% of 4 GB) to the Distributed Cache running on WFE servers. As I have mentioned earlier, I have stopped Distributed Cache on application servers from Services on Server Page on central admin. After a while, I have reallocated RAM to my virtual machines with 3 GB RAM to 2 WFEs servers and 4 GB RAM to 2 App Servers. Because of underlying Virtual machine RAM changes, I need to reallocate Distributed Cache size to all WFE servers.

Here is how my SharePoint farm looks like prior to attempting to change Distributed Cache Size.

0_DS_et-AFCacheHost

Step by Step Guide to change Distributed Cache Size

  • To Adjust Memory allocation of Distributed Cache on Web Front End Servers, log in to the Application Server hosting Central Admin using SP_Install account
  • Open the Windows PowerShell or SharePoint PowerShell Management Window as an Administrator.
  • Set the context of your PowerShell session to a particular cache cluster. Note that you must run this command before using any other Cache Administration commands in PowerShell

Use-CacheCluster

  • Retrieve the initial cache information by running this command from one of the cache host. This will allow us to view number of Cache hosts in Cache cluster, active Cache hosts in Cache cluster, and current memory allocated to Cache hosts. If you have never adjusted Cache size after your SharePoint installation, default memory allocated to Distributed Cache host should be 5% of initial RAM of server.

Get-CacheHost
Get-AFCacheHostConfiguration -ComputerName Niks-SP13-Web1.niks.local -cacheport 22233
Get-AFCacheHostConfiguration -ComputerName Niks-SP13-Web2.niks.local -cacheport 22233
Get-AFCacheHostConfiguration -ComputerName Niks-SP13-App1.niks.local -cacheport 22233
Get-AFCacheHostConfiguration -ComputerName Niks-SP13-App2.niks.local -cacheport 22233

In my case, I have 2 web front end & 2 application servers running as part of Cache Cluster. You may notice only that Distributed Cache is running only on web front servers but application servers are still part of Cache cluster.

1_DS_et-AFCacheHost

When I installed SharePoint on these servers, I had allocated 4 GB RAM to the web front end server virtual machines & 5 GB RAM to the application server virtual machines. Since default memory allocation for Distributed Cache is 5%, you may notice that Distributed Cache size for web front end server is 205 MB (5% of 4 GB) and application server is 256 MB (5% of 5 GB)

2_DS_et-AFCacheHost

  • Manually Stop Distributed Cache Service on all WFEs from the Services on Server Page in Central Admin. Alternatively, you can login to all WFE servers and run following command to stop the Distributed Cache from the WFE servers. Please note that you must run this command from all the WFE servers and ensure Distributed Cache is stopped on all the servers in the farm.

$instanceName =”SPDistributedCacheService Name=AppFabricCachingService”
$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName -and ($_.server.name) -eq $env:computername}
$serviceInstance.Unprovision()

I have manually stopped Distributed Cache service on both web front servers from Services on Server page on Central Admin. Notice that Distributed Cache is no longer showing up on the Servers in Farm page in Central Admin.

3_DS_et-AFCacheHost

  • Update Cache Size on all WFEs by running this command from one of the cache host (e.g. application server hosting central admin) using Use Set-AFCacheHostConfiguration. As I said earliar, beauty of this command is it allows us to configure Cache Size for specific Server.

In my sample test case, I have readjusted & decreased total RAM allocated to my virtual machines – 3 GB RAM to each web front end servers & 4 GB to each application servers. In this step, since our WFE have 3GB RAM allocated, we will allocate Maximum 1 GB (1024 MB) to Distributed Cache. Cache size should be half of maximum Distributed Cache allocated memory. In our case, it will be 512 MB. We won’t adjust Distributed Cache size on any application servers.

Set-AFCacheHostConfiguration -ComputerName Niks-SP13-Web1.niks.local -cacheport 22233 -cachesize 512
Set-AFCacheHostConfiguration -ComputerName Niks-SP13-Web2.niks.local -cacheport 22233 -cachesize 512

4_DS_et-AFCacheHost

  • Manually Start Distributed Cache Service on all WFEs from the Services on Server Page in Central Admin. Alternatively, you can login to all WFE servers and run following command to start the Distributed Cache from the WFE servers. Please note that you must run this command from all the WFE servers and ensure Distributed Cache is started on all the servers in the farm

$instanceName =”SPDistributedCacheService Name=AppFabricCachingService”
$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName -and ($_.server.name) -eq $env:computername}
$serviceInstance.Provision()

I have manually started Distributed Cache service on both web front servers from Services on Server page on Central Admin. Notice that Distributed Cache shows up on the Servers in Farm page in Central Admin.

5_DS_et-AFCacheHost

  • Verify your final Cache Cluster configuration, memory allocation to each servers in the farm running following command. Please notice that since we ran Set-AFCacheHostConfiguration command, all the WFE servers should have newly adjusted 8GB memory allocated and all the application & search servers have only intiial 5% memory allocated. Since Distributed Cache is not running on application & search servers, memory allocated to Distributed Cache is never used but it would allow you to run Distributed Cache PowerShell commands from Central Admin Server.

Get-CacheHost
Get-AFCacheHostConfiguration -ComputerName Niks-SP13-Web1.niks.local -cacheport 22233
Get-AFCacheHostConfiguration -ComputerName Niks-SP13-Web2.niks.local -cacheport 22233
Get-AFCacheHostConfiguration -ComputerName Niks-SP13-App1.niks.local -cacheport 22233
Get-AFCacheHostConfiguration -ComputerName Niks-SP13-App2.niks.local -cacheport 22233

As you may notice, Distributed Cache on web server has been increased from 205MB to desired 500 MB but application server cache size stayed default value.

6_DS_et-AFCacheHost

Hopefully this step by step guide will show you approach to change Distributed Cache size on your SharePoint 2013 farm. Stay tuned to learn how to change Distributed Cache size using Microsoft’s preferred approach in my next article!!!!


Filed under: Distributed Cache, SP2013 Admin

Adjust Cache Size of the SharePoint 2013 Distributed Cache Service Part III – Using Set-Update-SPDistributedCacheSize Command

$
0
0

Note: This article is part of series of articles showcasing different approaches & variations to adjust cache size of the SharePoint 2013 Distributed Cache service using PowerShell commands – Set-AFCacheHostConfiguration and Update-SPDistributedCacheSize.

This is 3nd and last article in this series and provides step by step guide for SharePoint Admins to configure Distributed Cache size using Set-Update-SPDistributedCacheSize command and high level guidance on why and when you should use this command.

Previous Article in this series -

Use Cases

  • If you have servers in your distributed cache cluster with same RAM allocated to physical or virtual machine. Additionally, all the cache hosts in cluster are active.

Pros

  • This is SharePoint cmdlet and preferred approach by Microsoft. Additionally, Microsoft do recommend that you must ensure memory allocation assigned to the Distributed Cache service is the same on all servers that are running the Distributed Cache service. It’s just unfortunate, this may not be applicable in real world scenarios and you may have servers with different physical or virtual RAM on the farm.

Cons

  • Sets all cache hosts to the same size
  • Must require same physical or virtual RAM allocated all the cache hosts to function correctly

Syntax

Set-Update-SPDistributedCacheSize – Reconfigures the allocation of memory that is dedicated to the Distributed Cache service. Use this cmdlet to allocate memory to the Distributed cache service. This cmdlet is part of SharePoint 2013 powershell cmdlets. CacheSizeInMB is required parameter. Notice that there is no parameter to specify server name. This cmdlet applies same cache size to all the cache hosts in the cache cluster.

Update-SPDistributedCacheSize [-CacheSizeInMB] <UInt32> [-AssignmentCollection <SPAssignmentCollection>]

Scenario

I have a multi-server farm with 2 WFEs (Niks-SP13-Web1, Niks-SP13-Web2) and 2 App Servers (Niks-SP13-App1, Niks-SP13-App2). When I have installed SharePoint 2013 on all servers in farm, it started Distributed Cache by default on all the servers. I have stopped and removed Distributed Cache service on all Application servers by running Stop-SPDistributedCacheServiceInstance -Graceful and Remove-SPDistributedCacheServiceInstance command. The reason for removing application servers from Distributed Cache cluster is we want to manage Distributed Cache memory using Update-SPDistributedCacheSize, which unfortunately treats all the servers in the cluster same and sets same memory regardless cache host is active or inactive.

Having removed Distributed Cache service on all Application servers, these servers won’t be part of Cache cluster and we will lose ability to manage Distributed Cache from the Application Servers using PowerShell. Please note that you can still use Update-SPDistributedCacheSize, if Distributed Cache is stopped (not removed) on application servers like 2nd article in this series. Unfortunately Update-SPDistributedCacheSize doesn’t allow different cache sizes for each host  & apply same Cache size to all inactive cache hosts, which wouldn’t be best practice. That’s the reason, if you are planning to use Update-SPDistributedCacheSize, my preference would be remove the cache host from cache cluster instead of stopping the Distributed Cache service on cache host.

In my environment, Initially I had allocated 4 GB RAM to 2 WFEs virtual machines and 5 GB RAM to 2 App Servers virtual machines during SharePoint installation. During default Distributed Cache configuration, SharePoint has allocated 205 MB (5% of 4 GB) to the Distributed Cache running on WFE servers. As I have mentioned earlier, I have removed Distributed Cache on application servers using Remove-SPDistributedCacheServiceInstance cmdlet. After a while, I have reallocated RAM to my virtual machines with 3 GB RAM to 2 WFEs servers and 4 GB RAM to 2 App Servers. Because of underlying Virtual machine RAM changes, I need to reallocate Distributed Cache size to all WFE servers.

Here are the commands I have used to stop the Distributed Cache service gracefully and remove the server from the Cache cluster.

1_DS_Update-SPDistributedCacheSize

Here is how my SharePoint farm looks like prior to attempting to change Distributed Cache Size.

0_DS_Update-SPDistributedCacheSize
Step by Step Guide to change Distributed Cache Size

  • To Adjust Memory allocation of Distributed Cache on Web Front End Servers, log in to the Web Front End Server using SP_Install account. Please note that you can’t manage Distributed Cache from application server like 2nd article because application server aren’t part of the Cache Cluster.
  • Open the Windows PowerShell or SharePoint PowerShell Management Window as an Administrator.
  • Set the context of your PowerShell session to a particular cache cluster. Note that you must run this command before using any other Cache Administration commands in PowerShell

Use-CacheCluster

  • Retrieve the initial cache information by running this command from one of the cache host. This will allow us to view number of Cache hosts in Cache cluster, active Cache hosts in Cache cluster, and current memory allocated to Cache hosts. If you have never adjusted Cache size after your SharePoint installation, default memory allocated to Distributed Cache host should be 5% of initial RAM of server.

Get-CacheHost
Get-AFCacheHostConfiguration -ComputerName Niks-SP13-Web1.niks.local -cacheport 22233
Get-AFCacheHostConfiguration -ComputerName Niks-SP13-Web2.niks.local -cacheport 22233

In my case, I have 2 web front end servers running as part of Cache Cluster.

2_DS_Update-SPDistributedCacheSize

When I installed SharePoint on these servers, I had allocated 4 GB RAM to the web front end server virtual machines. Since default memory allocation for Distributed Cache is 5%, you may notice that Distributed Cache size for web front end server is 205 MB (5% of 4 GB)

3_DS_Update-SPDistributedCacheSize

  • Manually Stop Distributed Cache Service on all WFEs from the Services on Server Page in Central Admin. Alternatively, you can login to all WFE servers and run following command to stop the Distributed Cache from the WFE servers. Please note that you must run this command from all the WFE servers and ensure Distributed Cache is stopped on all the servers in the farm.

$instanceName =”SPDistributedCacheService Name=AppFabricCachingService”
$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName -and ($_.server.name) -eq $env:computername}
$serviceInstance.Unprovision()

I have manually stopped Distributed Cache service on both web front servers from Services on Server page on Central Admin. Notice that Distributed Cache is no longer showing up on the Servers in Farm page in Central Admin.

3_DS_et-AFCacheHost

  • Update Cache Size on all WFEs by running this command from one of the cache host using Update-SPDistributedCacheSize. As you may notice, it doesn’t require server name as parameter, it would set same Cache Size on all cache host on the farm including application servers if they are part of Cache cluster.

In my sample test case, I have readjusted & decreased total RAM allocated to my virtual machines – 3 GB RAM to each web front end servers. In this step, since our WFE have 3GB RAM allocated, we will allocate Maximum 1 GB (1024 MB) to Distributed Cache. Cache size should be half of maximum Distributed Cache allocated memory. In our case, it will be 512 MB.

Update-SPDistributedCacheSize -CacheSizeInMB 512

5_DS_Update-SPDistributedCacheSize

  • Manually Start Distributed Cache Service on all WFEs from the Services on Server Page in Central Admin. Alternatively, you can login to all WFE servers and run following command to start the Distributed Cache from the WFE servers. Please note that you must run this command from all the WFE servers and ensure Distributed Cache is started on all the servers in the farm

$instanceName =”SPDistributedCacheService Name=AppFabricCachingService”
$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName -and ($_.server.name) -eq $env:computername}
$serviceInstance.Provision()

I have manually started Distributed Cache service on both web front servers from Services on Server page on Central Admin. Notice that Distributed Cache shows up on the Servers in Farm page in Central Admin.

5_DS_et-AFCacheHost

  • Verify your final Cache Cluster configuration, memory allocation to each servers in the farm running following command.  Please notice that since we ran Update-SPDistributedCacheSize command, all the cache hosts in the cluster will have same 512 MB memory allocated.

Get-CacheHost
Get-AFCacheHostConfiguration -ComputerName Niks-SP13-Web1.niks.local -cacheport 22233
Get-AFCacheHostConfiguration -ComputerName Niks-SP13-Web2.niks.local -cacheport 22233

7_DS_Update-SPDistributedCacheSize

Hopefully this step by step guide will show you approach to change Distributed Cache size on your SharePoint 2013 farm. Good luck!!!!


Filed under: Distributed Cache, SP2013 Admin

Nik’s SharePoint Fest 2013 Chicago Session Decks are Available

$
0
0

Thanks for everyone who has made to my session at the SharePoint Fest Chicago 2013. I was really surprised with turnout and full jam packed session. I knew it would interest most of attendees as building News application or Knowledge center in corporate intranets are one of the most common use cases for SharePoint.

I have built three different kind of Corporate News Application in three different versions of SharePoint in last few years – SharePoint 2010, SharePoint Online 2010, and SharePoint 2013 and all of them built with different flavors and requirements. One common need for all environment were decoupled authoring and publishing features.

With SharePoint 2013, new publishing method called “Cross-Site Publishing” has made building Corporate News application easier than ever with decoupled architecture for both authors and end users. As promised, here is my session deck available through Slide Share. Feel free to download and reach out to me if you have any questions.

It was such a great time spent with the SharePoint Community and Slalom team!!!


Filed under: SP2013 General, Speaking

SharePoint 2013 March Update, Invalid FormDigest, Taxonomy Field in Publishing Page Layout, ValidateTerms 500 Error, and “There was an error processing the request” Error

$
0
0

Recently I came across interesting error “/_vti_bin/TaxonomyInternalService.json/ValidateTerms 500 (Internal Server Error)” while referencing managed metadata taxonomy field in the publishing page layouts. I have couple of managed metadata fields referencing managed metadata term store. While updating published pages, I was getting popup box with error message stating “There was an error processing the request”.

Error Processing Managed Metadata TermStore

Error Processing Managed Metadata Detailed

As you may have noticed, I have previously blogged an article – SharePoint March 2013 Public Update, Invalid FormDigest, Client.SVC ProcessQuery 403 Forbidden and it was dejavu for me. I remembered I had came across similar client side web service call issue on the March 2013 Update while editing published page articles. Based on previous experience, my first instinct was to look at the FormDigest and sure enough, that was the culprit.

Resolution => Upgrade to August 2013 CU => As I have done with the “Client.SVC ProcessQuery 403 Forbidden” issue, this issue seems to have been introduced into the product in the March 2013 CU for both SharePoint 2010 and SharePoint 2013. Upon upgrading my current environment to August 2013 CU, I was able to fix this issue.

Additional Resource - http://sharepoint-community.net/profiles/blogs/sharepoint-2010-publishing-page-error-there-was-an-error


Filed under: SharePoint 2013, SP2013 DEV

Issues with SharePoint 2013 March 2013 Update for Publishing Sites

$
0
0

As most of us in SharePoint industry aware, SharePoint March 2013 Update is the new baseline update for SharePoint 2013 farms and all the servers must be upgraded to March 2013 Update before patching to later Service Packs and Cumulative Updates.

Unfortunately, if you are using SharePoint Publishing Features to host articles and web content management features, you will encounter multiple issues and your authors won’t able to update articles in several scenarios. I have came across several issues – e.g. Calling CSOM APIs or referencing Managed Metadata Fields from Page Layouts.

Please review these two articles, understand the logic behind, and plan to patch your SharePoint farm to latest service pack or CU. At the time of writing this article – I was able to fix these issues by upgrading to the August 2013 CU.

Hope this will avoid several hours of headache for some of you out there.


Filed under: SharePoint 2013, SP2013 DEV

No-nos, Gotchas, Warnings, Best Practices, and Things to Remember for SharePoint 2013 Distributed Cache Service

$
0
0

Someone told me at SPC12 that Distributed Cache in SharePoint 2013 is User Profile Sync Service in SharePoint 2010. If you are seasoned SharePoint professional, you know that doesn’t bring smile on your face. ;)

After reading Microsoft’s TechNet articles, one would assume that statement made at SPC12 was 100% on money. Reading TechNet articles on Distributed Cache, one should feel like they are walking on terrain of landmines and one wrong step could bring down the SharePoint farm and un-stabilize the SharePoint 2013 environment. If you still haven’t got the point, read this – Microsoft has raised first ever warning in SharePoint Products history stating “The Distributed Cache service can end up in a non-functioning or unrecoverable state if you do not follow the procedures listed in TechNet article. In extreme scenarios, you might have to rebuild the server farm“.

I don’t recall Microsoft ever issued warnings in this matter in previous four releases of the product which could bring down the farm, not even for User Profile Service in SharePoint 2010. Having worked on complex SharePoint 2013 farm over the last year, I have noticed that these warnings will surface it’s ugly head one time or another. Unfortunately many of core SharePoint 2013 features are dependent on Distributed Cache and disabling this service is not an option at this moment. If you ever notice that users can’t post anything in their my site news feed or people can’t login properly, either your Distributed Cache is lacking memory cache or Distributed Cache is dead and you may force to make necessary memory allocation changes for Distributed cache or revive dead Distributed Cache service.

Here are the major No-nos, Gotchas, or Warnings SharePoint admins should keep in mind regarding Distributed Cache service. Please note that most of these information directly derived from TechNet, Steve Peschka, and Josh Gavant‘s articles.

By default, 10% of Total RAM and 5% of Total RAM allocated to Cache Size to Distributed Cache Service

When SharePoint Server 2013 is installed, it assigns the Distributed Cache service 10 percent of the total physical memory on the server. The Distributed Cache service uses half of that memory allocation for data storage (also known as cache size, 5% cache size), and the other half of that memory allocation is used for memory management overhead. When the cached data grows, the Distributed Cache service uses the entire 10 percent of the allocated memory. http://technet.microsoft.com/en-us/library/jj219613.aspx

Never Administrator the Distributed Cache Service from the Services Snap-in in Administrative Tools

The Distributed Cache depends on Windows Server AppFabric as a prerequisite. Do not administer the AppFabric Caching Service from the Services window in Administrative Tools in Control Panel. Do not use the applications in the folder named AppFabric for Windows Server on the Start menu. Always administrator Distributed Cache using PowerShell or using Central Administration Services on Server Page. http://technet.microsoft.com/en-us/library/jj219613.aspx

Total memory allocation for Distributed Cache host shouldn’t be more than 16 GB

On a server that has more than 16 GB of total physical memory, allocate a maximum of 16 GB of memory to the Distributed Cache service. If you allocate more than 16 GB of memory to the Distributed Cache service, the server might unexpectedly stop responding for more than 10 seconds. If the cache host’s size is larger than 16GB/8GB, garbage collection could take long enough to cause a noticeable interruption for clients. If you require more memory, you can configure the Distributed Cache service to run on several application servers or dedicated Distributed Cache servers. As far as server specs, for dedicated Distributed Cache servers, your Virtual or Physical Server RAM shouldn’t be more than 24 GB (16 GB allocated to Distributed Cache and other for OS). – http://technet.microsoft.com/en-us/library/jj219572.aspx and http://blogs.msdn.com/b/besidethepoint/archive/2013/03/27/appfabric-caching-and-sharepoint-2.aspx

Dynamic memory is not supported in SharePoint 2013 environments nor App fabric servers.

The Distributed Cache service can run on either a physical or virtual server. When using virtualization, do not use Dynamic Memory to manage shared memory resources among other virtual machines and the Distributed Cache servers. The memory allocation for virtualized Distributed Cache servers must be fixed. http://technet.microsoft.com/en-us/library/jj219572.aspx

Plan to run Distributed Cache in Dedicated Mode

The Distributed Cache service can run in dedicated or collocated mode. When running in dedicated mode, the Distributed Cache service is started and all other services are stopped on the server. In collocated mode, the Distributed Cache service is running along with other services on the server. Dedicated mode is the recommended mode in which to deploy the Distributed Cache service. Review Steve Peschka’s article – http://blogs.technet.com/b/speschka/archive/2013/08/29/dedicating-servers-to-distributed-cache-in-sharepoint-2013.aspx

Developing code against the Distributed Cache of SharePoint 2013 is NOT supported

If you are using custom applications in SharePoint Server 2013 which use the AppFabric client APIs, or are creating custom caches, you should create a separate AppFabric cache cluster to support your custom applications. Do not use the AppFabric cache cluster supporting your SharePoint Server 2013 farm. Run your separate AppFabric cache cluster for your custom applications on separate servers from the servers dedicated to your SharePoint Server 2013 farm.  Microsoft has stated that additional named caches should not be deployed to the SharePoint AppFabric cluster (i.e. by using the New-AFCache cmdlet). If you need a cache for a custom solution, you’ll need to deploy a separate AppFabric cluster (or server) and create the cache there. Then point your solution at the external AppFabric cluster. There’s also no supported way to add your own cached items to SharePoint’s named caches. http://technet.microsoft.com/en-us/library/jj219572.aspx & http://blogs.msdn.com/b/besidethepoint/archive/2013/03/27/appfabric-caching-and-sharepoint-2.aspx

Install Windows AppFabric using SharePoint Server 2013 prerequisite installer

It is important to note that SharePoint 2013 RTM uses Windows AppFabric 1.1 for Distributed Cache Service. When the SharePoint Server 2013 prerequisite installer runs, it installs Windows Server AppFabric 1.1. This is the recommended approach for installing Windows Server AppFabric on a server that is running SharePoint Server 2013. If you already have Windows Server AppFabric 1.0 installed on the server (SharePoint 2013 Preview was based on Windows Server AppFabric 1.0) before you run the prerequisite installer, you must uninstall Windows Server AppFabric before you run the prerequisite installer. If an administrator decides to install Windows Server AppFabric manually, the administrator must install the CacheAdmin, CachingService, and CacheClient features, and use the /gac switch. For more information see Automated Installation (AppFabric 1.1 Caching) in the MSDN Library. http://technet.microsoft.com/en-us/library/jj219572.aspx

Plan to have Memory Allocation to all Distributed Cache Host are Same

You must ensure that the memory allocation assigned to the Distributed Cache service is the same on all servers that are running the Distributed Cache service. An administrator can change the memory allocation for the Distributed Cache service by using the Update-SPDistributedCacheSize or Set-AFCacheHostConfiguration cmdlet. http://technet.microsoft.com/en-us/library/jj219572.aspx and http://nikpatel.net/2013/09/24/adjust-cache-size-of-the-sharepoint-2013-distributed-cache-service-part-i-overview

To have Distributed Cache working on more than one servers, the first server with Distributed Cache needs to have its firewall set to allow for Inbound ICMP (ICMPv4)

If you are using more than one cache host in your server farm and they are not in same subnet, you must configure the first cache host running the Distributed Cache service to allow Inbound ICMP (ICMPv4) traffic through the firewall. If an administrator removes the first cache host from the cluster which was configured to allow Inbound ICMP (ICMPv4) traffic through the firewall, you must configure the first server of the new cluster to allow Inbound ICMP (ICMPv4) traffic through the firewall. http://technet.microsoft.com/en-us/library/jj219572.aspx  and http://blogs.technet.com/b/speschka/archive/2013/01/11/configuring-multiple-distributed-cache-servers-in-sharepoint-2013.aspx and http://blogs.technet.com/b/uktechnet/archive/2013/05/07/guest-post-distributed-cache-service-in-sharepoint-2013.aspx

Plan to update Distributed Cache memory allocation while updating physical or virtual RAM on Cache host

When you add physical memory to the server. The Distributed Cache service does not automatically recalculate the 10% memory allocation, so when you increase the total physical memory on the server, you have to manually increase the Distributed Cache service’s memory allocation. http://technet.microsoft.com/en-us/library/jj219613.aspx

Use skipRegisterAsDistributedCachehost parameter to configure Dedicated Distributed Cache Host in SharePoint Farm

When you run PSCONFIG or SharePoint Products Configuration Wizard to configure SharePoint on server in the farm, it will start Distributed Cache service by default and server will be added as a Cache Host. As an alternative to the default configuration, an administrator can install SharePoint Server 2013 without registering the Distributed Cache service on servers not intended to be part of the cache cluster. This can be achieved by using the skipRegisterAsDistributedCachehost parameter with the New-SPConfigurationDatabase or the Connect-SPConfigurationDatabaseWindows PowerShell cmdlets, or when running psconfig.exe at the command line. This parameter is optional. – http://technet.microsoft.com/en-us/library/jj219572.aspx

Use Add-SPDistributedCacheServiceInstance to add Cache Host in the Distributed Cache Cluster

If a Distributed Cache Service is missing for a particular server in Central Administration, you need to run “Add-SPDistributedCacheServiceInstance” from a SharePoint PowerShell window on the server it is missing on. It is important to note that adding server instance using Add-SPDistributedCacheServiceInstance resets cache size to 5%. Whether you use AppFabric or SharePoint cmdlets to modify cache host size, note that if you uninstall and reinstall the Distributed Cache Service Instance on a server (i.e. by running Remove-SPDistributedCacheServiceInstance and then Add-SPDistributedCacheServiceInstance) the cache host size will be reset to the default (5% of physical memory at time of installation). If removing and adding the cache service instance is part of your maintenance cycles, make sure to also modify the cache size afterwards if needed. – http://technet.microsoft.com/en-us/library/jj219613.aspx and http://blogs.msdn.com/b/besidethepoint/archive/2013/03/27/appfabric-caching-and-sharepoint-2.aspx

Plan to avoid Farm Account to run Distributed Cache Service

When AppFabric is installed as part of the SharePoint pre-requisites, the server farm account (e.g. Niks\sp_farm) is set as the service account of the AppFabric Caching service. The Distributed Cache service depends on the AppFabric Caching service. This will eventually trigger a violation of a Health Analyzer Rule. You must plan to change the service account of the AppFabric Caching service to a managed account. Primarily it can be same service account (e.g. domain user account – Niks\sp_svcapp) used to run all other Service Applications in the farm. On the side note, if you use AutoSPInstaller, this step is automatically configured by the AutoSPInstaller and Distributed Cache will run under domain service account other than Farm Account. http://technet.microsoft.com/en-us/library/jj219613.aspx – and http://blogs.technet.com/b/uktechnet/archive/2013/05/07/guest-post-distributed-cache-service-in-sharepoint-2013.aspx

Plan to stop gracefully and remove server from Distributed Cache cluster during patching and maintenance of the SharePoint server in the farmRun Stop-SPDistributedCacheServiceInstance –Graceful and Remove-SPDistributedCacheServiceInstance before shutting down the server for patching. Run Add-SPDistributedCacheServiceInstance after patching is done. It is also important to remember that adding server instance using Add-SPDistributedCacheServiceInstance resets cache size to 5% and you must resize the cache size using Update-SPDistributedCacheSize or Set-AFCacheHostConfiguration. Do not use this approach to stop the server if you need to update cache memory size. Instead manually start/stop Distributed Cache service from Service on Server page or start/stop service instance using PowerShell command. To adjust the memory cache for host, plan to use approached previously mentioned in my articles – http://nikpatel.net/2013/09/24/adjust-cache-size-of-the-sharepoint-2013-distributed-cache-service-part-i-overview/

SharePoint doesn’t provide high availability to Distributed Cache component of the farm

SharePoint (as of August 2013 CU) does not provide any high availability for its caches. It is important to note that Cached data stored in one server may not available on another Distributed Cache server in farm. If the server where that item has been stored in memory is lost or shut down ungracefully, that cached item will be lost. This is generally not a problem for cached items because they are authoritatively stored in the database except items in feed cache – Tags and document follow activities.

The Feed Cache depends on the Distributed Cache service. Tags and document activities are saved only to the Feed Cache. Tags and document activities are not persisted to content databases. When the Distributed Cache service is stopped, tags and document activities are lost. If these cached items are lost they won’t be able to be regenerated and will no longer appear in users’ feeds. To avoid losing items from the cache and/or having to retrieve them again, you can use the Stop-SPDistributedCacheServiceInstance cmdlet with the -Graceful switch. When the graceful shutdown of the Distributed Cache service method is used, all cache data is moved from one server to another server before the Distributed Cache service is stopped. For this to be effective, there must be space on the other servers to accommodate these items. Also note that if shutting down the entire cluster, such as to change the cache host size, there’s no way to avoid losing all of the feed caches items.

When the Distributed Cache service is started, repopulation occurs when the feed cache repopulation timer job runs. It is important to note that retrieving cached items all over again involves a performance hit. There could be interruptions and delays while the caches are being refilled. http://technet.microsoft.com/en-us/library/jj219613.aspx & http://blogs.msdn.com/b/besidethepoint/archive/2013/03/27/appfabric-caching-and-sharepoint-2.aspx

Additional References

Good luck managing this beast!!!!!!


Filed under: Distributed Cache, SP2013 Admin

My Sites Infrastructure Planning for SharePoint 2013 On-Premises Farm

$
0
0

It is important to plan My Site Infrastructure for SharePoint 2013 farm and fine tune default setting to ensure SharePoint 2013 supports number of My Sites databases and storage quota for each My Site.

Here are the major areas you must consider while deploying My Site Infrastructure on your SharePoint 2013 On-Premises farm.

My Site Host Site Quota

  • Consider Setting the Quota of My Site Host site. By default, this setting is unlimited. Plan to configure My Site Host Quota to ensure it doesn’t grow out of control.
  • If Site Quota is not enough – Users can’t add a profile picture, post pictures in feeds, provision a personal site etc.
  • Check your My Site Host Usage and Site Quota using SPD, log in with My Site Collection Admin ID – http://sharepointyankee.com/2011/12/28/how-much-storage-space-is-my-site-collection-using/

Number of My Site Databases

  • Check the number of My Site databases at the Central Admin -> Application Management -> Databases -> Manage Content Databases -> My Site Web App
  • Default Maximum Number of Sites created Per Database is 5000.
  • Plan to consider capacity planning for My Site Databases. e.g. If you are rolling out My Site Infrastructure for 50000 users, you must plan for changing the default setting or adding more databases depending upon the size of the database. Plan to ensure database size shouldn’t exceed more than 100 GB as per Microsoft’s content database sizing recommendation.

My Site Personal Site Quota

Max Size of My Site Databases

  • You must ensure you would adhere Microsoft Content database sizing guidelines. My Site databases shouldn’t exceed more than 100 GB.
  • Calculate based on previous two data values => Total Database Space required = Number of My Site Databases * My Site Personal Site quota.
  • Based on previous example, if you are rolling out My Site to 50000 users and each has 1 GB My Site, you would need 50 TB database space. With Microsoft’s content database recommendation of 100 GB, you would need 500 My Site databases. This is why My Site is one of the most compelling reasons to move to the cloud. At the time of writing this article, Microsoft allows 25 GB per My Site in the cloud.

Hopefully these information will provide you enough ammunition to plan My Sites for the on-premises farm and why rolling out My Sites to the cloud is compelling business case.


Filed under: SP2013 Admin

Configure ULS Logs for Troubleshooting SharePoint

$
0
0

Here is the quick tip on how to turn on & off ULS Logs for Troubleshooting. This is mostly self-reminder note for me.

  • Download ULSLogViewer from MSDN, this is one of my all time favorite tool which doesn’t install anything on the SharePoint servers  – http://archive.msdn.microsoft.com/ULSViewer/Release/ProjectReleases.aspx?ReleaseId=3308
  • To ensure you can start tracing errors for troubleshooting, You must enable logging. By default you may have been logging Errors but plan to configure Verbose logging to ensure you have all the detailed information your would need for troubleshooting. Please note that verbose would fill up the disk space. Plan to disable as quickly as possible after troubleshooting is completed. To enable logging, Go to Central Admin – Monitoring -> Diagnostic Logging -> Select All categories or whatever you are interested -> Select “Verbose” in both least critical event to report event log & trace log. Although event log is not required, I prefer to log into event logs as well to ensure I have more than one tool for troubleshooting.
  • As soon as you would turn on Verbose logging, it should start logging C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\LOGS (if that’s your default directory, plan to offload logs on the production environment).  You should see logs are filling up fast as soon as you turn on the Verbose logging.
  • To view the errors, Open the logs from File-> Open From -> ULS for real time feed => C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\LOGS\
    • You can find error & correlationid => Edit -> Find
    • You can filer log with correlationid => Edit -> Modify filter
  • Plan to disable verbose logging or reset to Error logging once troubleshooting is done. To disable logging, Go to Central Admin – Monitoring -> Diagnostic Logging -> Select All categories or whatever you are interested -> Select “None” in both least critical event to report event log & trace log. It should stop filling up logs in the LOGs folder

Hope this helps both newbies and veterans out there. Enjoy!!!!!


Filed under: SP2007 Admin, SP2010 Admin, SP2013 Admin

Best Free Online Video Training available for SharePoint 2013 and Office 365 Professionals

$
0
0

I wanted to list out all the top SharePoint 2013 and Office 365 free video training resources available as of today. Microsoft has done outstanding job with SharePoint 2013 release and it’s unfortunate not many people know about all those resources released over the last year.

Hopefully this will help someone to have 1-stop place to get trained with latest and greatest in SharePoint field. I will try my best to keep the links up to date if it ever changes.

#1 => TechNet – SharePoint 2013 training for IT pros

http://technet.microsoft.com/en-us/sharepoint/fp123606.aspx

SP2013 IT Pro Training

#2 => MSDN – Developer training | apps for Office and SharePoint

http://msdn.microsoft.com/en-US/office/apps/fp123626

SP2013 DEV Training

#3 => Microsoft Virtual Academy – Tuning SQL Server 2012 for SharePoint 2013 Jump Start

http://www.microsoftvirtualacademy.com/training-courses/tuning-sql-server-2012-for-sharepoint-2013-jump-start#?fbid=2gpZeTlCxl7

MVA SQL 2012 for SP2013 Training

#4 => Channel 9 MSDN – SharePoint Conference 2012 Session Videos

http://channel9.msdn.com/Events/SharePoint-Conference/2012

Channel 9 SPC12 Videos

#5 => Office 365 Ignite Training

http://ignite.office.com/guides

Office 365 Ignite

#6 => Office 365 Developer and IT Pro Training

http://blogs.technet.com/b/miketag_sharepoint_blog/archive/2013/01/23/office-365-developer-and-it-pro-training.aspx

Office 365 DEV and IT Pro Training

#7 => Microsoft Virtual Academy – Developing Microsoft SharePoint Server 2013 Core Solutions Jump Start

http://www.microsoftvirtualacademy.com/training-courses/developing-microsoft-sharepoint-server-2013-core-solutions-jump-start#?fbid=xne90rRJ2Go

SP2013 Core Solutions MVA Jumpstart

 

Enjoy!!!!


Filed under: Office 365, SharePoint 2013

Handy SharePoint Administrative URLs Reference

$
0
0

As most of SharePoint Professionals, I have been keeping list of handy URLs to navigate through my day to day tasks. Recently I have came across this blog article – Famous SharePoint URLs and Locations and felt like everyone has their own go-to list of URLs. This article has excellent list of famous SharePoint URLs but one thing I felt it was missing was whether they would work for Site Collection or Sub Site.

Here are the list of all the handy SharePoint URLs I have been keeping track of. Let me know if I have missed anything or any of your favorites.

  • Site Collection URLs
    • Get the SharePoint Version -  {SiteCollectionURL}/_vti_pvt/Service.cnf
    • Get the Site Collection User Information List – <SiteCollectionURL>/_catalogs/users/detail.aspx  or <SiteCollectionURL>/_catalogs/users/simple.aspx
  • Site URLs
    • Login with different user – {SiteUrl}/_layouts/closeConnection.aspx?loginasanotheruser=true
    • Get the Site Security All People List – {SiteUrl}/_layouts/people.aspx?MembershipGroupId=0
    • SharePoint Foundation – Site Summary Analytics – {SiteUrl}/_layouts/usage.aspx
    • SharePoint Foundation – Site Usage Analytics – Monthly Summary Reports – {SiteUrl}/_layouts/usagedetails.aspx
    • Set up missing default groups post site creation – {SiteUrl}/_layouts/permsetup.aspx
    • Taxonomy Hidden List – {SiteUrl}/Lists/TaxonomyHiddenList/AllItems.aspx
  • Page URLs
    • Get the Web Part Maintenance Page – <WebPart ASPX Page>?Contents=1
    • Open the Web Part Page in Edit Mode – <WebPart ASPX Page>?ToolPaneView=2
  • Publishing Site URLs
    • Get the Publishing Site Manager – {SiteUrl}/_layouts/sitemanager.aspx

References

Hope it helps


Filed under: Office 365, SharePoint 2007, SharePoint 2010, SharePoint 2013, SP2010 Online, SP2013 Online

Magical SPUtility Class – A Hidden Jewel for SharePoint Custom Development

$
0
0

I have been using SPUtility ever since I have started building Custom SharePoint Applications but once in a while I come across SPUtility functions to solve problems which I normally either find myself in the corner or scratch my head to solve  issues.

With this article, I will try to outline some of my favorite SPUtility functions and which scenarios you may be able to use.

SendEmail - Sends an email to specified email address

Sending email from ASP.NET application requires understanding of location of SMTP Server and Ports. Since SharePoint email & SMTP information is configured as Outgoing Email in Central Administration. SPUtility has outstanding function which would use Current Site Collection context to send an email using Outgoing Email configuration.

private void SendEmailResults(string toAddress, string subject, string body)
{
SPUtility.SendEmail(SPContext.Current.Site.RootWeb, false, false, toAddress, subject, body);
}

MapToIcon - Returns the Icon URL for any list item (e.g. document, pages, or list item)

There are times you may need to retrieve Icon for current document or list URL. e.g. while building Custom Search applications, search API won’t return Icon URL as managed property. There is DocIcon crawled property but it would return nothing but extensions of the documents. Thanks to SPUtility MapToIcon function, we have solution which would return IconURL as long as you have access to the current document or list item URL. Thanks to I LIKE SHAREPOINT for this wonderful tip.

private string getIconUrl(string itemUrl)
{
return "/_layouts/images/" + SPUtility.MapToIcon(SPContext.Current.Web, itemUrl, string.Empty, IconSize.Size16);
}

GetLocalizedString - Get Localized String from Resource Files

While building multi-lingual applications, there are times where you would need to access localized label from the Resource Files stored in the 14-Hive Resource or IIS AppResources Folder. Additionally, if you ever deploy resource files in the subfolders (not at the root of Resources folder), SPUtility function works great even your Resource files are stored in sub folders.

private string getLocalizedString(string label)
{
return SPUtility.GetLocalizedString("$Resources:" + label.Trim(), @"Company.Webparts\ResourceFileName", Convert.ToUInt32(System.Globalization.CultureInfo.CurrentUICulture.LCID));
}

Filed under: Uncategorized

Protected: PowerShell Script to Configure App Management Proxy for Workflow Manager in Multi-Server SharePoint 2013 farm

$
0
0

This post is password protected. You must visit the website and enter the password to continue reading.


Filed under: SP2013 Admin

How did I build SharePoint Home Lab Server: Part I – Shopping PC Parts

$
0
0

Over the last summer with the new SharePoint 2013 hardware requirements, I built home lab to host my personal SharePoint virtual machines. One of the main goals was to have 64 GB RAM (or at least 32 GB RAM) to support SharePoint Multi-Server Farm VMs to replicate similar environment as my customers.

Although I wanted to build lab for a while (exactly since 2009, early SharePoint 2010 days), Lenny Ankireddi (one of my colleagues) had a great jumpstart and with his little help looking over his 32 GB lab specs, Ray’s TechNet Blog, and excellent step by step NewEgg videos, I was on my way to do homework on my lab specs. At the end of 3 weeks research, I had ordered my SharePoint Lab parts ready to be assembled.

0_Intro

If you are following this article and want to avoid any research, you can use my Specs to build full blown 64 GB home lab or further read this article to get detailed guidance on different components of the home lab and walking with me on my memory lane to see how I had built my PC from scratch. Keep in mind, building home lab from scratch requires lots of research, careful planning, and lots of dedicated time. It’s buy vs build decision (I let you make that decision) and you have to decide whether it’s worth the effort. For me, it was more of learning experience and ultimately loved building what I exactly wanted and how I wanted.

It’s Important Set Goals and for me it was simple enough:

  • Computer with 64 GB RAM Support
  • Total Cost – Less than $2500

Before diving into details of Computer Parts Buying Process, here are High Level Steps & Important Things to Remember for SharePoint Lab

  • Make sure all the parts are compatible with each other before confirming your purchase. I would double check or triple check all the compatibility. Single mistake means starting over whole process or long wait on phone with supplier.
  • Narrow down on CPU/Processor – Manufacturer (AMD vs. Intel), 32 GB RAM or 64 GB RAM, # of Cores, Hyper-Threading Support, Virtualization Support
  • Motherboard – Must be compatible with CPU Socket type (e.g. LGA 1155 or LGA 2011) and CPU Type (Core i7/i5/i3), Must decide Form Factor and Board Size, Must decide Amount of RAM supported, Must decide Number of Ports and Verity of Ports needed for Peripherals
  • Memory/RAM – Must be compatible with Motherboard RAM size (32 GB vs 64 GB), RAM Speed, and Number of Slots.
  • Hard Drive – Go for HDD for general storage and SSD for running VMs, SSDs are must for SharePoint VM performance, Since SSDs or smaller than HDD, ensure if Case has inbuilt SSD Mounting Kits, Ensure SSD has SATA III interface and motherboard matches connectors
  • Computer Case – Must be compatible with Mother Board Size & Form Factor & Dimensions – Typically comes in three flavors – Mini ITX, Micro ATX, and full ATX

Part#1 => CPU/Processor

1_Intel Core i7-3930K

  • CPU/Processor should be your first decision in whole PC building process.
  • First step is to decide which Manufacturer – AMD vs. Intel – Intel performs better, AMD is cheaper, It was no brainer for me to focus on only on Intel CPUs
  • Two main things to check – Number of Cores & Clock Speed, Number of Cores are more important for SharePoint labs, SharePoint is CPU Intensive and at least quad-core would be minimal, Clock speed is more important for gamers – most of the games don’t use more than 1 core. It is also important to note that 6 core or 8 core CPU might be expensive for home labs.
  • Plan to go for 3rd generation Intel processors if you can. On the flip side, it shouldn’t be major criteria for SharePoint labs because some of the 2nd Gen Chips may over perform 3rd generation – 3rd Gen Ivy Bridge (Tick) vs. 2nd Gen Sandy Bridge (Tock)
    • Ivy Bridge is better for gaming, expensive than Sandy bridge but Sandy bridge is only 3-5% slower than ivy bridge for non-gaming operations
    • Ivy Bridge has much improved heat sensitivity and voltage sensibility for better scaling, it may require additional heat sink since Ivy Bridge may overheat quickly compared to Sandy Bridge
  • Plan to look for overclocking option if needed, again it shouldn’t be major criteria – K series processors are unlocked
    • Available in both Ivy Bridge and Sandy Bridge
    • Other series are not unlocked, No need for overclocking CPU or memory but nice to have this option
  • Look out for Hyper Threading Support, This is must – Core i5 vs. Core i7
    • Available in both Ivy Bridge and Sandy Bridge
    • Core i7 supports HT – Allows OS to recognize 1 physical core as two logical cores. in other words, it shows up as 8 CPUs even though it’s quad-core
  • Look out for 64 bit and virtualization Support which most of CPU does
  • Look out if Heat Sink and Fan are included in package
    • Most of CPUs has heat sink & fan packaged except OEM item, in that case – you have to buy additional heat cooling device. Additionally, heat sink/fan comes with CPU are not powerful, Look for aftermarket Heat Sink fan for stronger CPU cooler, do need to apply Heat Sink Thermal Paste especially for ivy bridge CPU, may not be needed initially
  • LGA1155 vs. LGA2011 sockets, please take a note of which socket you are buying. It is important to note that Motherboard (next major decision in buying process) must match this socket type -
    • LGA2011 are almost double price because LGA1155 max out at 32 GB and LGA2011 max out at 64 GB, Please take a note of Core vs RAM, 64 GB may mismatch memory/CPU ratio for quad-core HT CPU (8 cores with hyper thread) or dual-quad-core CPU (8 core) , 64 GB for 8 Cores means no more than 8 GB per VM for NUMA boundary. Since I am not going to allocate more than 8 GB RAM on any of my VMs, I would be able to run SharePoint VMs not only efficiently but very powerful/complex farm with 64 GB RAM, LGA2011 are large monster processors compare to LGA1155, which are more popular in Intel mainstream market.
  • My Decision Making Process – Based on my needs, I had narrowed down two options- Sandy Bridge Intel Core i7-3930K and Ivy Bridge Intel Core i7-3770K. Although I wanted Ivy Bridge processor, I was happy to explore better Sandy Bridge chips if I need. Since I wanted Hyper Threading Support, I had narrowed down to Core i7. Although Ivy Bridge option is much cheaper than Sandy Bridge option, 64 GB support for LGA2011 socket & 6-Core HT was the winner in my book. Probably this is one of the hardest decision you may make in early part of your Specs decision. Additionally, many of the decision you make for CPU/Processor decides RAM & Motherboard decisions for you later in the PC parts shopping process. At the time of when I was buying, there wasn’t any Ivy Bridge chip available in market which would support LGA2011, 64 GB Socket otherwise I would have definitely gone for 3rd generation Intel Chips.
  • My Final Choices -

Part#2 => Motherboard

2_ASUS Sabertooth X79 LGA 20113_ASUS Sabertooth X79 LGA 2011_2

Part#3 => Memory/RAM

4_CORSAIR Vengeance 64GB

  • Once you have CPU/Processor and Motherboard finalized, everything else start falling in place. Although you still have to ensure all the remaining parts of compatible with Motherboard, decision making process is simple and choices are limitless.
  • Manufacturer – You won’t find a huge difference between brands. Popular brands include Crucial, Corsair, Kingston, PNY, OCZ, G.Skill, Mushkin, and Patriot.
  • Make sure it’s compatible with motherboard RAM speed and RAM Size (e.g. Go for 240-Pin DDR3 SDRAM, Make sure capacity matches your CPU – 32 GB (4 x 8GB))
  • DDR3 1600 offers the best performance/price ratio, Anything faster than that is an overkill for SharePoint labs, unless you are a planning to use for games as well.
  • Depending on Channels on the motherboard, either buy two sets of RAM (dual channel) or three sets of RAM (triple channel)
  • Plan to buy whole set of memory card packs, don’t buy into multiple sets
  • My Decision Making Process – As I said earlier, Amount of Memory, Memory Size, and Number of Slots of the motherboard makes buying RAM process very easy. Once I have narrowed down the results on Newegg, it was more of choice of how it would look & feel once on the motherboard and I wanted to match overall look & feel.
  • My Final Choices

Part#4 => GPU/Graphics Card/Video Card

5_MSI N640GT-MD1GD3 GeForce

Part#5 => SSD Hard Drive

6_Kingston HyperX 3K SH103S37_Rosewill RDRD-11003 SSD HDD Mounting Kit

  • Manufacturer – Popular brands are SanDisk, Kingston, Samsung, Crucial, OCZ, Corsair, and Intel.
  • This is must and one of the most important purchase you would make for SharePoint VMs for faster performance.
  • Look out for at least Serial Rev 2 or 3
  • Plan to get the pair of 120 GB and pair of 240 GB
  • Look out for SSD Mounting kits – ensure mounting kits supports SSD size (e.g. 2.5″ SSD/HDD compatible), Since SSDs are smaller than HDD, ensure if Case has inbuilt SSD Mounting Kits otherwise plan to buy SSD Mounting Kits
  • Ensure it has SATA III interface, make sure motherboard matches connectors
  • My Decision Making Process – Although SSDs are important and getting cheaper, they are still expensive compared to HDD. Although I would have loved to have 580 GB SSD, I ended up buying 240GB Kingston HyperX. One of the major areas I was interested was Internal Hard Drive, Form Factor, and SATA III interface along with 240 GB Capacity while narrow down the vast amount of options on NewEgg.
  • My Choice – Kingston HyperX 3K SH103S3/240G 2.5″ 240GB SATA III MLC Internal Solid State Drive (SSD) (Stand-Alone Drive)

Part#6 => HDD Hard Drive

8_Western Digital WD Green WD20EZRX

  • Manufacturer – Western Digital, Seagate, Hitachi, Samsung, and Toshiba are popular brands
  • Have it at least 7200 RPM and SATA 6.0 Gb/s interface, make sure motherboard matches connectors
  • Although it’s optional, it’s cheap and great for hard drive storage and general data backup – 1-2 TB might be great start
  • Most drives will run on SATA 3.0Gb/s, though if you have 6Gb/s-capable SATA ports on your motherboard, you might want to pay extra for a SATA 6Gb/s hard drive.
  • My Decision Making Process – Just looked for something with 2 TB for storage purpose & compatible with motherboard connectors
  • My Choice – Western Digital WD Green WD20EZRX 2TB IntelliPower 64MB Cache SATA 6.0Gb/s 3.5″ Internal Hard Drive -Bare Drive

Part#7 => Optical Drive and USB 3.0 Flash Thumb drive

9_ASUS 24X DVD Burner

  • Manufacturer – Lite-On, Samsung, Sony, and LG are all great manufacturers
  • Plan for DVD burner at least since it’s cheap, although this is optional, thumb drive or external hard drive might be OK for boot
  • Since most of my software are on ISO format, you may not use CD/DVD drive
  • Make sure Motherboard has SATA interface, not old IDE interface
  • My Decision Making Process – Although this was optional, I wanted to buy one mainly because it’s cheap and most probably needed if I ever wanted to install older software. One of the item I ensured that it was compatible with motherboard connectors.
  • My Choice – ASUS 24X DVD Burner – Bulk 24X DVD+R 8X DVD+RW 12X DVD+R DL 24X DVD-R 6X DVD-RW 16X DVD-ROM 48X CD-R 32X CD-RW 48X CD-ROM Black SATA Model DRW-24B1ST/BLK/B/AS – OEM

Part#8 => CPU Fan & Heat Sink (CPU Cooler, Thermal Compound Paste, and Thermal material Remover & Surface Purifier)

10_Cooler Master Hyper 212 EVO11_Arctic Silver 5 High-Density

Part#9 => PSU – Power Supply Unit

12_Rosewill BRONZE Series RBR1000-M 1000W

Part#10 => Computer Case

13_Rosewill BLACKHAWK Gaming ATX Mid Tower 214_Rosewill BLACKHAWK Gaming ATX Mid Tower

Part#11 => LCD Monitor, Keyword and Mouse, Speakers and Ear buds

Part#12 => Cable Organization – Cable Ties, Twist Ties, and Zip Ties

Recap: Final list of all parts I have bought from Newegg.

After few days awaiting delivery, here are all the parts awaiting for next steps to be assembled. Here is the Second & Last Part of this series to see how I have assembled them.

15_Final

Resources:


Filed under: Uncategorized

How did I build SharePoint Home Lab Server: Part II – Assembling PC & Installing OS

$
0
0

Second part of this series is continuation of what I had started with first part to discuss end to end process of building SharePoint 2013 home lab. At the end of the first part, we were at the stage where all the parts were arrived from Newegg.com and ready to be assembled.

15_Final

Although first part of this article was detailed & very descriptive of different decision making process, this part is more of step by step guide of assembling picture guide.

Allocate Specific Time and Space

First thing first, unpacking PC parts and assembling them together can take 2-4 hours depending on your experience. If you have never done it, plan to allocate whole day (I am not kidding) because every step will take to you through unknown land and it can be overwhelming at times. Please plan to view newegg’s computer building process along with this article to get familiar with process as much as possible.

Whenever you are ready, plan to move all the parts to space where you want to build the computer. Plan to have flat surface near power supply where you can assemble and test the computer box as you build it. Once you move to the space where you would PC, unpack all the boxes of computer parts as you walk through in next steps discussed in this article. Don’t unpack all the boxes at the same time. Carefully open all the boxes with warranty papers and instructions along with stickers you can have it on your computer case to show off. :)

1_Ready to be Assemble

Step 1 => Unpack Motherboard and Install CPU on Motherboard

Unpack Motherboard – ASUS Sabertooth X79 LGA 2011 and put Motherboard on the box on the flat surface. Please be very careful where you put the Motherboard. Don’t put it directly on the table or flat surface. Plan to put it on the box itself to avoid any scratches. Very tiny little damage will make whole PC building experience worthless.

Next step is to unpack CPU – Intel Core i7-3930K and carefully install CPU on the Motherboard. If you are unsure, how to install your version of CPU on your version of Motherboard, there would be 100s of free videos on Youtube available. Please ensure you ground yourself before moving to installation steps. Here is the excellent video of how to install LGA2011 Intel Core i7 CPU Installation on the motherboard. I have followed this video to ensure I was careful enough to proceed with CPU installation on the motherboard – http://www.youtube.com/watch?v=H3myiMEW3EM

2_CPU Installed

3_CPU Installed 2

Step 2=> Install Heat Sink and Fan on the Motherboard

After CPU is successfully mounted, next step is Install and configure Heat Sink and Fan on the motherboard – COOLER MASTER Hyper 212 EVO and Arctic Silver AS5-3.5G. Before you mount the fan, there are couple of ways to apply thermal compound paste. You can use either one-dot approach or . Even though this video installs water cooler heat sink, I have used same approach for Air Heat Sink as well with fan. Here is the another video on how to install Coolermaster Hyper 212 Evo Review & Installation on LGA 2011 Socket Motherboard- http://www.youtube.com/watch?v=H_QVWBm4CI4

4_CPU Fan & Heat Sink Installed

5_CPU Fan & Heat Sink Installed 2

Step 3 => Install RAM

Next step is to unpack DIMMs – CORSAIR Vengeance 64GB (8 x 8GB) and install RAM carefully on the motherboard. Ensure they are snapped correctly on the Motherboard.

6_RAM Installed

7_RAM Installed 2

Step 4 => Install GPU

Next step is to unpack GPU – MSI N640GT-MD1GD3 GeForce GT 640. Connect fan and snap it on the motherboard on PCI Express slot. Plan to watch MSI GT 640 V3 – Unboxing Video – http://www.youtube.com/watch?v=K2ax7WqhyPY

Additionally, ASUS Sabertooth X79 comes with 40mm fan. After watching Installation of the 40mm Fan on the ASUS Sabertooth X79 Motherboard LGA2011 video – http://www.youtube.com/watch?v=4Jm5mDPK5TU, I was ready to jump on the next fun steps.

8_GPU Installed

Step 5 => Test the External Build – Connect Power Supply & Monitor

At this stage, core components of the Motherboard is installed and it’s ready to be transferred to the Computer Case for final packaging. It is one of the best practice to go through dry run and test the external build. One of the major benefits of this process is you can test the computer system and connections before going through final installation and packaging process. Unpack the Monitor and connect to the Motherboard. Unpack the power supply – Rosewill BRONZE Series RBR1000 and connect major components to the Motherboard. Some of the major connections are – 24-pin & 8-pin Main and CPU Supplemental Power Supply to Motherboard, Connect GPU PCI Power if needed, and connect Power Supply to main power extension.

Many motherboards comes with small speaker which you can use to ensure system is configured successfully while turning on the power. Install the speaker and start the power supply. Depending on the motherboard, you may have On/Off switch or two pins which required to short by Philips minus Screw Driver. If successful, system will boot up and all the fan will be running upon turning on the motherboard switch. If speaker is connected, it will beep upon the system boot up. Computer monitor will display Intel Processor and Installed RAM information. If speaker turned on with multiple bips and computer display CPU fan error, please ignore this message at this time. You can resolve this issue by changing the bios setting afterwards.

9_External Build Test

Step 6 => Internal Build – Moving Motherboard into Case & Final Installation of Motherboard, Power Supply, and HDD, SDD, and DVD Optical Drive

If everything is successful, it is time to disconnect Power Supply and Monitor from previous steps and Motherboard would be ready to be transferred to the Computer Case. Unpack Computer Case – Rosewill BLACKHAWK Gaming ATX Mid Tower.

Open the case and remove the side panel from where you have full opening to transfer all the computer components into the case. Here are the major steps I have followed:

  • First step is install the Power Supply with Fan facing bottom or outside of Computer Case. Mount the PSU with the screw comes from the PSU manufacturer.
  • Next major step would be installing Optical Drive (DVD Player). Open the front panel and align optical hard drive with case. I was fortunate enough to have snap slots. I had to just slip in the Optical Drive in the slot and it would snap & lock without screw.
  • Next steps are mounting HDD and SSD. Depending on the case, you may need SSD Mounting kit or if you are lucky enough like me, you can easily slip in both HDD and SDD to slots with screw less design. My case had mounting slots available for both 3.5” HDD and 2.5” SSD.
  • It’s time to transfer Motherboard to the Case. Unmount the GPU (which may affect your ability to install all the screws in the motherboard) from the Motherboard and transfer Motherboard carefully to the Case. Align your motherboard on the case and half-tighten screws from opposite end until all screws of Motherboard are on the case before fully tightening up.

Step 7 => Cable Management & Connecting all components

One of the most challenging and creative part of computer building process is how to connect all the components with power supply and motherboard and how to still keep it beautiful without messing up all the wires look like Jungle. Plan to have Motherboard, PSU, and Case Guides handy if you need and how to move/tighten wires as needed.

For my configuration, here is high level steps I had followed.

  • From Front Panel, Connected 2 USBs, 1 Audio (Mic/HeadPhone – HD AC 97 cable), Power Switch, USB 3.0, and SATA Interface
  • Power Cables – SATA Cables to HDD, SSD, and Optical Drive, 24-Pin main power supply connector to Mother board, 8-Pin CPU Connector to motherboard
  • Data Cables from Motherboard – SATA  6.0 to HDD, SATA 3.0 to SSD, and SATA 6.0 to Optical Drive
  • Connect Motherboard Fan with 3-Pin connector on motherboard
  • Connect 4 Case Fans with Power Supply with Molex Cables (I was lucky enough to shipped with Power Supply, Please plan to buy extra if your Power Supply Manufacturer doesn’t provide them)
  • Once all the cables are connected, final step is carefully reinstall the GPU on the motherboard

14_Cable Mgmt 1

14_Cable Mgmt 2

14_Cable Mgmt 3

And, here is complete system!!!

10_Tranfer into Case

Step 8 => Test the Internal Build – Connect Power Supply & Monitor

It’s time to test the Internal Build. Connect the PC with Monitor and Turn on the Power Supply to ensure system boots up and display same message as External Build.

11_Internal Build Test

Step 9 => Complete the Installation – Cover up the Case

This is it. It’s done. Final step is put the panels of computer case back and connect all the peripherals like keyboard, mouse, monitor and it’s ready for OS Installation.

12_Final Packaged Product

13_Ready to be OS Installed

Step 10 => Configure and Optimize BIOS

Before you install Operating System, you must ensure BIOS is configured properly and uses all the resources efficiently. Please refer to motherboard guide for relevant information. Some of the major areas I had considered are follows:

  • System Date and Time
  • CPU Configuration – HT Support Enabled, Virtualization Enabled, 64-bit Supported
  • Booting Device – DVD Drive
  • Change AI RAM Settings to ensure RAM speed is properly configured as per installed RAM specs – XMP for RAM-1866 Mhz Speed
  • Link to Fix Fan Error – Set CPU Fan Profile to Manual and Increase Minimum to 50%. This should run fan atleast 1000 RPM to ensure BIOS doesn’t complain – http://vip.asus.com/forum/view.aspx?board_id=1&model=P7P55D&id=20100106201817046&page=1&SLanguage=en-us

Step 11 => Installing Operating System – Windows 8 64-bit Edition

Here are the high level steps I had followed to install Windows 8 Operating system. Alternatively, you can watch newegg’s computer building process on YouTube. Last step of this process is no-brainer but I wanted to document here for completeness of the article. Just install the operating system and get ready for Hyper-V installation as discussed here and you are on your way to create and host SharePoint Hyper-V VMs.

  • First step of the process is Installing Operating System. Download Windows 8 ISO file and make a bootable DVD for Windows 8. Here are the steps I had followed to create Windows 8 Bootable DVD in 5 Minutes using Imgburn Software – http://www.youtube.com/watch?v=BxIZa25bVXI. In my case, I wanted to ensure I install OS in 2 TB HDD. First steps I performed was to unplug SSD and partitioned HDD (C drive with 500 GB and D drive with 1.5 TB) during the Windows 8 Installation by booting up install disc from DVD drive to avoid accidental installation on SSD. This installs Windows 8 with default drivers comes with operating system on HDD.
  • Next step is to plug the SSD back and initialize the hard disk from computer management -> storage -> disk management screen. Format the SSD and configure drive volume for SSD. In my case, drive volume name was “VMs”.
  • Next major step the process is to install all the latest drivers required by the PC. Keep in mind that Computer Case, PSU, CPU, RAM, Storage/SSD/HDD, and optical drive doesn’t require any drivers. Most of the drivers are required for Motherboard (Chipset, Network/LAN, USB, and Audio) and Video Card drivers. My next step was to download latest drivers from Motherboard manufacturer (ASUS with Motherboard Model Number) and Video card manufacturer (Nvidio or MSI) for Windows 8, 64-bit operating system. There are couple of options to accomplish this task.
    • First option is download drivers from computer with internet connection by visiting manufacturer site (preferred approach because of latest drivers for specific OS) and copy to the thumb drive or optical drive and install on the PC.
    • Second option is use manufacturer provided CDs from Motherboard or GPU Vendor. In this case, install LAN driver from Motherboard CD, Connect NIC to the internet Modem, download latest drivers & install directly from the computer.
    • I had followed first option and installed drivers in following order – Chipset, LAN, USB, Audio, Video, and SATA.
  • One important step I normally follow at this stage is backup all the downloaded drivers along with Windows 8 bootable disk to avoid these steps again in future in case of reinstalling the Windows 8 operating system on the PC.
  • Next major step is Activate Windows 8 and perform Windows Update. Go to the Control Panel and run & rerun Windows Update until there are no more updates. Additionally, check the Device Manager to ensure all the drivers are installed.
  • Plan to install Anti-Virus at this stage of the installation. Microsoft has multiple free version of bare-minimum Anti-Virus software for different client OS – Microsoft Security Essentials for Windows 7 and Windows Defender in Windows 8. Alternatively, plan to have more robust Anti-Virus subscribed software.
  • Plan to install any software requires like Microsoft Office
  • Test and validate all the major vital programs on the PC including Internet connection, Audio, Video, and other settings.
  • It is important to backup image of final state of the PC before using it for SharePoint labs. This would allow you to restore the image without re-performing all the steps discussed prior to this step. Use Windows 7 File Recovering option from Control Panel to backup & restore the image. Plan to save backed up image on different drive than default C drive.

Resources:


Filed under: Uncategorized

Code Snippet – Programmatically Retrieve Localized SharePoint User Profile Properties Label

$
0
0

Please note this code snippet has been tested on SharePoint 2010 using Visual Studio 2012. It should work fine with SharePoint 2013.

If you are working on multi-lingual or support multiple languages in your SharePoint application, there might be at times, you may need to access localized version of SharePoint User Profile Properties.

As many of you may aware, SharePoint User Profile system allows an administrator to specify localized version of labels while creating User Profile Properties. I may have spent day or two and one or more sleepless night to figure out how to localize User Profile Properties using OOB approach before stumbling into localized display name option in User Profile Administration page and where Microsoft may have stored these localized data. As it turned out, these localized labels are stored in the User Profile database unlike other SharePoint localized technologies like .NET Resource files stored in the Resources directory in SharePoint Root or App_GlobalResources in IIS virtual directory.

As demonstrated below, you can manage localized labels of User Profile Properties in the Central Administration. Please note that you must enable language settings for specified lanaguages in Central Administration site to add localized labels for User Profile properties.

User Profile Properties

Localized User Profile Properties

As you can see, Localized values of User Profile Properties are stored in the User Profile Service Application’s Profile Database and PropertyListLoc Table.

User Profile DB - Localized Table

Let me first point out, Accessing these localized display labels are not straightforward. Microsoft.Office.Server.UserProfiles namespace has CoreProperty class to represent the definition of basic User profile property which is common across all the User Profile Properties. This class represents most values required to define User Profile Properties including Name, Display Name, IsAlias, IsMultiValued, IsSearchable etc. To retrieve localized label of User Profile Properties, what we are interested is => CoreProperty class’s CoreProperty.DisplayNameLocalized collection.

As happens often with SharePoint, there are multiple ways to access User Profile Properties through Server Side Object Model and depending on requirements, one option might perform better than other. In this article, I will demonstrate two different ways to access Localized Label of User Profile properties.

Option 1 => Accessing User Profile Properties CoreProperty Class using CorePropertyManager, Much Better Performance

Once you get access to the UserProfilePropertyManager, you can directly access CorePropertyManager which would allow you to search all the Core Properties for specific User Profile Property and returns object representing CoreProperty class for specific user profile property. This approach allows you to avoid iterating through all the User Profile Properties and yields much better performance.


/// <summary>
/// Get the localized label of User Profile Properties
/// Option 1 => Get the specific property to find the label (much better performance)
/// </summary>
/// <param name="userProfilePropertyName"></param>
/// <returns></returns>
private string getLocalizedUserProfilePropertiesLabel_FasterOption(string userProfilePropertyName)
{
string localizedLabel = string.Empty;

//Get the handle of User Profile Service Application for current site (web application)
SPSite site = SPContext.Current.Site;
SPServiceContext context = SPServiceContext.GetContext(site);
UserProfileConfigManager upcm = new UserProfileConfigManager(context);

//Access the User Profile Property manager core properties
ProfilePropertyManager ppm = upcm.ProfilePropertyManager;
CorePropertyManager cpm = ppm.GetCoreProperties();

//Get the core property for user profile property and get the localized value
CoreProperty cp = cpm.GetPropertyByName(userProfilePropertyName);
if (cp != null)
{
localizedLabel = cp.DisplayNameLocalized[System.Globalization.CultureInfo.CurrentUICulture.LCID];
}
return localizedLabel;
}

Option 2 => Accessing User Profile Properties CoreProperty Class using ProfileSubtypePropertyManager, Slower Looping Through Option

Another option is loop through all the User Profile Properties in the ProfileSubtypePropertyManager. All the User Profile Properties are categorized by Profile Subtypes. This option forces you to loop through User Profile Properties collection to access specified User Profile Property class and object representing CoreProperty class for specific user profile property.


/// <summary>
/// Get the localized label of User Profile Properties
/// Option 2 => Loop through all the user profile properties to find the label..
/// </summary>
/// <param name="userProfilePropertyName"></param>
/// <returns></returns>
private string getLocalizedUserProfilePropertiesLabel_SlowerOption(string userProfilePropertyName)
{
string localizedLabel = string.Empty;

//Get the handle of User Profile Service Application for current site (web application)
SPSite site = SPContext.Current.Site;
SPServiceContext context = SPServiceContext.GetContext(site);
ProfileSubtypeManager psm = ProfileSubtypeManager.Get(context);
ProfileSubtype ps = psm.GetProfileSubtype(ProfileSubtypeManager.GetDefaultProfileName(ProfileType.User));

//Get the properties by section
ProfileSubtypePropertyManager pspm = ps.Properties;
foreach (ProfileSubtypeProperty profileSubtypeProperty in pspm.PropertiesWithSection)
{
if (profileSubtypeProperty.Name.Trim().ToUpper() == userProfilePropertyName.Trim().ToUpper())
{
//Get the core property for user profile property and get the localized value
CoreProperty coreproperty = profileSubtypeProperty.CoreProperty;
localizedLabel = coreproperty.DisplayNameLocalized[System.Globalization.CultureInfo.CurrentUICulture.LCID];
break;
}
}
return localizedLabel;
}

Enjoy!!!!


Filed under: SharePoint 2010, SP2010 Code Snippets

Step by Step – How to Prepare SharePoint 2010 Developer VM for People Search

$
0
0

Recently, I was working on SharePoint 2010 environment and needed  to make Developer VM ready for People Search Customization. Here are the high level steps I had followed to configure People & Expertise Search on my VM. Please note that this article requires good level of understanding of how to configure required services and service applications mentioned in pre-requisites to support SharePoint 2010 search based applications. My intention of this article is reference for me to have whole process documented for me in future.

  • Pre-requisites
    • Make sure Managed Metadata Service and Managed Metadata Service Application is Configured (Although this is optional, it’s important to support Multi-value User Profile Properties). Refer to this article for detailed step by step guide.
    • Make sure User Profile Service and User Profile Service Application are Configured and User Profile Sync Service is Configured. Refer to this article for detailed step by step guide.
    • Make sure Search Service and Search Service Application is Configured is configured
    • Make sure Enterprise Search Center (site collection with Enterprise Search Center template) is created. Only Enterprise Search Center template allows you to search for people with OOB configuration
  • Prepare AD for People Search
    • Create Sample AD Users => Ensure all properties are filled out (visit all the tabs – General, Address, Telephones, Organization etc.)

 1_AD User 1-2_AD User

  • Upload Pictures to the AD without Outlook or Exchange
    • Make sure all pictures are 144×144 pixels and less than 10 KB
    • Download ADPhotos Trial Software to upload pictures to AD – http://www.dovestones.com/download/
    • Run ADPhotos tool and upload all the pictures to AD thumbnailphoto property

 2_AD Photos

  • Map User Profile Properties from User Profile Service Application Admin Page
    • Visit Manage User Profile Service Application and Click on Manage User Properties in People Section
    • Update following properties and map AD fields as mentioned below:
      • Mobile Phone => Mobile
      • Home Phone => home phone
      • Picture => thumbnailPhoto

 3_User Profile Admin

3-1_User Profile Properties

  • Perform User Profile Sync and Import Pictures
    • Run Full User Profile Synchronization
    • Run this PowerShell command to force SharePoint to update the User Profile Database – This will create the thumbnails that are used in My Sites and the User Profile Service. This creates thumbnails from the user profile images saved in the My Sites User Profile pictures library => Update-SPProfilePhotoStore –MysiteHostLocation http://sp2010vm/my -CreateThumbnailsForImportedPhotos 1
    • Ensure all the properties including Pictures are available in User Profiles
  • Provision My Sites for each users and ensure My Profile displays valid picture, user profile properties, and org browser.
    • Remember Org Browser is driven by Manager field. Please populate it in AD.
    • Plan to populate all the additional User Profile Properties like Skills, About Me, Ask Me About etc.

 4_My Site

4-1_My Profile

  • Perform Search Crawl and Validate People Search
    • Perform Full Crawl including My Sites and User Profiles
    • OOB People Search should return People Data including Pictures

    5-2_Search by Name

5_Search by Experties

That’s it!!


Filed under: SharePoint 2010

Step by Step – Configuring Least-Privileged User Profile Service Application and User Profile Sync Service in SharePoint 2010 Developer VM

$
0
0

Please note that this article refers to only SharePoint 2010 and SharePoint 2013 On-premises. Both User Profile Service and User Profile Syronization Service are pre-configured in Office 365 and SharePoint Online tenants.

Here are the high level steps you need to follow to configure User Profile Service Application and User Profile Sync Service in your SharePoint 2010 Developer VM and On-Premises farm. This article also applies to SharePoint 2013 On-premises multi-server farm as well but it can vary slightly depending on your farm configuration especially how SP_Farm account is used during UPS provisioning process and how it required logon local permission without having local admin rights. Alternatively you can download step by step visual guide from my Sky Drive folder.

Important Notes

  • Please plan to use this guidance only for Least-Privileged Developer VMs to learn how and what really happens under the hood when you configure User Profile Service and User Profile Sync Service. This is more of “How” article instead of “Why” article as a quick reference for me in future. For real-world multi-server farm building scenarios (or even hardcore Developer VMs), please plan to use automated PowerShell scripts like AutoSPInstaller.
  • It is also important to note that although I have used SP_Farm account (Bad practice according to Spencer Harbar) to configure these services upon logging into the server, preferred approach would be using SP_Install account or any other Farm Admin Account with sufficient privileges to configure Services and Service Applications (AutoSPInstaller uses this approach) using PowerShell or Upon logging into the server or using Central Admin from remote server. Discussions about whether to use SP_Install or SP_Farm or any other Farm Administrator account is out of scope of this article. Since this is Single Server Developer VM, I have used SP_Farm account. In real world multi-server farm scenario, I would use SP_Install and AutoSPInstaller to configure these services.

Scenario

Configure User Profile Service Application and User Profile Synchronization Service with NTLM Authentication in Single-Server Least-Privileged Developer VM.

Planning and Pre-requisites:

  • SharePoint Edition – SharePoint 2010 Standard or Enterprise, This feature is not available in SharePoint 2010 Foundation.
  • Service Application Dependency – Managed Metadata Service and Managed Metadata Service Application – Although this is not required, it’s recommended to ensure all the multi-value user profile properties dependent on Managed Metadata term store works correctly. Please refer to this article for detailed step by step instructions.
  • Logon Account to Configure Service Application – Access to SP_Install or any other Farm Administrator Account to login to the server for Service Configuration. I will be using SP_Farm account in this guide and SP_Farm is local admin on the machine. More specifically, SP_Farm account is domain admin on DC since I am configuring UPA and UPS on single server All-UP VM.
  • User Profile Service Application Pool Account Identity – SP_ServiceApps, either already created or access to AD to provision new domain user for service account. Additionally, this account must be configured as Managed Account in the Central Admin. (this step is discussed in this article but it’s already created for Managed Metadata Service Application)
  • User Profile Sync Service Account Identity – This must be SP_Farm account. After UPS is configured successfully, FIM windows services will be running under this account. SP_Farm account must be local admin during User Profile Sync Service provisioning process.
  • User Profile Sync Connection Service Account Identity – SP_UPS, either already created or access to AD to provision new domain user account. This account doesn’t need to be configured as Managed Account in the Central Admin since UPS doesn’t support Managed Accounts. (this step is discussed in this article) and this account must have “Replicate Directory Changes” Permission on the AD Domain. This account will be used to perform the user profile sync and won’t be used to run any services or application pools

High Level Steps:

  • Prepare the Service Accounts for the User Profile Service Application
  • Configure the User Profile Service and User Profile Service Application
  • Verify the User Profile Service Application Configuration
  • Prepare the Service Accounts for the User Profile Sync Service and Add Sample Users to Import in SharePoint User Profile System
  • Grant Replicate Directory Changes Permission to User Profile Sync Service Account in the Active Directory
  • Start the User Profile Synchronization Service
  • Verify User Profile Synchronization Service Started
  • Import the User Profiles from the AD using Sync
  • Verify the User Profiles Synchronization Process

Detailed Step by Step Directions:

Step 1 – Prepare the Service Accounts for the User Profile Service Application

For the Least Privileged Setup, create service application domain user account (e.g. Niks\sp_serviceapps). Majority of the service applications along with User Profile Service Application will run under this account identity. Ensure “User cannot change password” and “Password never expires” are checked.

1-SP Service App Account

Log in to the server as a farm account (e.g. Niks\sp_farm). Visit the Central Admin and register the “Niks\sp_serviceapps” as managed account. User Profile and other SharePoint Service Applications requires Service Application pool configured as Managed Account in the central administration.

2-Managed Account

Step 2 – Configure the User Profile Service and User Profile Service Application

Log in to the server as a Niks\sp_farm user. To setup User Profile Service Application properly, please ensure that User Profile Service is already activated on the farm. Please note that this step is NOT mandatory but much more preferred approach. If you don’t start User Profile Service prior to provisioning User Profile Service Application, it would start automatically for you.

Visit the Central Administration -> System Settings -> Manage services on server and verify that User Profile Service is started. This service gets started automatically. If it doesn’t start automatically, start the service manually.

3-Services on Server

4-User Profile Service Started

To setup new User Profile Service application, Navigate the Central Administration -> Application Management -> Manage Service Applications to create the new User Profile Service Application.

5-Manage Service Applications

Click New and select “User Profile Service Application”

6-New Service Application

On the new User Profile Service Application creation page, enter the service application name and Application Pool. Specify new Application Pool and use the “Niks\sp_serviceapps” as Application Pool identity.

7-1-User Profile Service App Settings

Specify Profile Database Name, Server, and Authentication Info.

7-2-User Profile Service App Settings - Profile DB

Specify Synchronization Database Name, Server, and Authentication Info.

7-3-User Profile Service App Settings - Sync DB

Specify Social Tagging Database Name, Server, and Authentication Info.

7-4-User Profile Service App Settings - Social DB

Specify Profile Synchronization Server Instance where User Profile Service will be activated. If you already have My Site Host site collection, please specify My Site Host URL. In my case, I haven’t configured My Site Host site collection. Please note that this step checks for valid My Site Host URL.

7-5-User Profile Service App Settings - My Site Info

Specify My Site Managed Path and My Site Naming Format.

7-6-User Profile Service App Settings - My Site Info

Upon clicking OK, Both User Profile Service Application and User Profile Service Application Proxy is created.

8-User Profile Service Application

Step 3 – Verify User Profile Service Application Configuration

After successful configuration, you can visit the User Profile Service Administration page by clicking the User Profile Service Application link. As you can notice stats on the right side of the screen, there are no user profiles. Also, notice that Profile Synchronization Settings are disabled.

9-User Profile Service Application Admin Page

For advanced SharePoint IT Pro related verification, please see Appendix A in downloadable document (link specified above) to understand what happens under the cover when you provision new User Profile service application.

In general, when SharePoint provisions new User Profile service application, it typically configures various components on the server:

  • Central Administration
    • User Profile Service is started and User Profile Service Application and Proxy is created
    • Both SharePoint Farm Account and Default Web Application Pool Account are added with Full Control Permission on the User Profile Service Application Permissions Page
    • Associate User Profile Service Application with Content Web Application
    • Service Application Pool is configured for User Profile service on the Configure Service Accounts page.
  • Active Directory
    • SharePoint Service Account is added to member of IIS_IUSERS and WSS_WPG group
  • IIS
    • New Service Application Pool is created
    • New WCF Endpoint for User Profile Service Application is configured.
  • SQL Server
    • New User Profile Service Application Databases – Profile DB, Social DB, and Sync DB are provisioned
    • SharePoint Service Account is added as Login account on the database Server
    • SharePoint Service  Account is configured with “db_owner” role on the all three User Profile Service Application databases
    • SharePoint Service Account is configured as WSS_Content_Application_Pools role in the SharePoint_Admin and SharePoint_Config database.
    • SharePoint Service Account doesn’t have any access to the content web application database

Step 4 – Prepare the Service Accounts for the User Profile Sync Service and Add Sample Users to Import in SharePoint User Profile System

To import the user profiles into the SharePoint environment, we need to configure the User Profile Sync Service. User Profile Sync service is a wrapper of provisioning of the Forefront Identity Manager (FIM) on the server.
To make sure My Sites, User Profiles, and People Search work more efficiently, login to the server using the “Niks\Administrator” and add More Users to the Active Directory using the Active Directory Services from the Start -> Administrative Tools -> Active Directory Users and Computers. Add User – Nik Patel. Copy the first user and create a small # of the users if you want.

10_Add Sample User

Login to the server as “Niks\sp_farm” and make sure “Niks\sp_farm” account is the local admin when you provision the User Profile Sync Service on the Server. Add the “Niks\sp_ups” service account in the AD. This account will run the User Profile Sync Service and Perform the User Profile Sync using the FIM.

11_Add UPS Account

Step 5 – Grant Replicate Directory Changes Permission to User Profile Sync Service Account in the Active Directory

In order to be able to sync with AD, you need to ensure User Profile Sync account (e.g. “Niks\sp_ups”) have “Replicate Directory Changes” permission. You will need this account name and password when you create a connection. Please do not proceed without having an account with these rights. This AD right is required for both full and incremental sync. Open the Active Directory Users and Computers snap-in. On the View menu, click Advanced Features. Right click on the domain object – niks.local and choose Delegate Control. To verify the Replication Directory Changes permission on the “Niks\sp_ups” object, right click on the domain object – niks.local and choose properties. Select the Security Tab and verify that “Replicating Directory Changes” permission was added to “Niks\sp_ups” account. See the attached guide for details.

12_Replicating Directory Changes

Step 6 – Start the User Profile Synchronization Service

To Configure the User Profiles Sync, Open the Central Administration. Click on Central Administration -> Manage Services on Server; provision the new User Profile Synchronization Service Application by clicking “Start”

13_Start UPS

Select user profile service application and specify the farm account – Niks\sp_farm password. Specify the User Profile Service Application instance if you have multiple User Profile Service Applications are running on farm. Additionally, please note warning in Red – If SharePoint Central Administration is deployed on this machine, you must recycle Internet Information Services after provisioning the User Profile Synchronization Service.

14_UPS runs under Farm Account

User Profile Synchronization Service status should be “Starting”. This step can take up to 10 minutes depending on the network and hardware configuration in the farm. Alternatively, you can monitor running jobs to see the progress of User Profile Sync service provisioning process by reviewing ProfileSynchronizationSetupJob on the Running Jobs page in Central Admin Monitoring section.

15_UPS Starting

16_Profile Sync Job

Refresh the Manage Services on the Server Page to see if User Profile Synchronization Service status is “Started”. It will take a while because this process provisions the FIM service on the server.

17_1_UPS Started

As specified earlier, run the IISRESET. It is required if FIM is installed on the same box as Central Admin.

17_2_IIS Reset

Step 7 – Verify User Profile Synchronization Service Started

Run Services Snap-in through Administrative Services -> Services or type the services.msc on the Run command. On services snap-in, verify that “Forefront Identity Manager Synchronization Service” and “Forefront Identity Manager Service” windows services are started set to automatic, and running under “Niks\sp_farm” account. Do not start them manually if they are not running and troubleshoot the issue.

18_1_FIM Services Started

Since I have started User Profile Sync service on the Developer machine hosting both SQL Server, often FIM windows service may fail to start during VM startup process because of its dependency on SQL Server services. Although this is not necessary in Production environment because SQL server is hosted on different servers, plan to have FIM services started with “Automatic (Delayed)” to ensure FIM services able to start on the Developer machine hosting both SharePoint and SQL servers.

18_2_FIM Services Delayed Start

Check the folder %Programfiles%\Microsoft Office Servers \14.0\Synchronization Service\MaData to see if there are two subfolders \ILMMA and \MOSS-XYZ (where XYZ is the name of your user profile service application). These folders should be empty at this time.

18_3_UPS MA Folder

Step 8 – Import the User Profiles from the AD using Sync

Open the Central Admin -> Application Management -> Manage Service Applications and Click on the “User Profile Service Application” to configure the AD Synchronization Connection. On the Manage Profile Service screen, click on the Manage User Profiles link to verify that there isn’t any profiles imported yet. On right side on stats, there are no profiles. You can also manage User Profiles, Audiences, User Profile Synchronization Connections, and My Sites from this page. Click on the “Configure Synchronization Connections” on the Manage Profile Service screen.

19_UPA Admin Page

Click on the “Create New Connection”

20_Create Sync Connection

Specify the User Profile Synchronization Connection Name, LDAP directory type – Active Directory, forest name – Niks.local, Authentication Provider – Windows for NTLM Authentication, and “Niks\sp_ups” as User to connect to the AD to sync the users. FIM will use this user to connect to the AD.

21_AD NTLM Connection

Click “Populate Containers”. Expand “Niks” domain, select “Users” and click Ok. Do not select all.

22_Populate Container

System may take while to create the AD synchronization connection. Once created, profile service should show new AD connection. If FIM services are not started, you may get error specifying MA Folder can’t be created while creating AD Sync Connection.

23_Create Connection

Based on the numbers of users and groups in your system, it may take much longer to sync users and groups. On the Manage Profile Services page, click on the “Configure Synchronization Settings” link. Select “Users Only”, Use SharePoint User Profile Sync and click Ok.

24_Configure Sync Settings

Now, you can synchronize the AD users to the SharePoint using “Start Profile Synchronization” link from the Manage Profile Service page. Select “Start Full Synchronization” and click Ok.

25_Start Profile Sync

If you refresh the Manage Profile Service page, you will see the Profile Import Status may show “Synchronizing”.

26_Profile Syncing

Profile Synchronization Process can take long time depending on number of user profiles needs to be imported along with network and hardware configuration. Alternatively, to monitor the Profile Synchronization, Please visit the C:\Program Files\Microsoft Office Servers\14.0\Synchronization Service\UIShell and Click on the miisclient.exe. Clicking miisclient.exe will open the FIM/Metaverse Manager which is used by the SharePoint Sync Service to import/export/sync the AD profiles with the SharePoint. Please review attached guide for more details. Refresh the User Profile Admin Page after several minutes (approx. 10 minutes). Once Profile Import Status is Idle, User Profile Synchronization is completed. On the right side of the screen, you can see the number of profiles imported and other stats. In this case, there are 11 User Profiles are imported.

27_Profile Sync is Done

Step 9 – Verify the User Profiles Synchronization Process

On Manage User Profiles link, you should find all the profiles are imported.

28_Profiles Imported

Difference between My All-UP VM Scenario and Production Multi-Server Farm Scenario

This article provides detailed instructions to configure UPA and UPS in All-Up SharePoint 2010 VM with DC, SharePoint, and SQL hosted on single server farm. In production environment, most likely you would be running DC and SQL on different servers other than SharePoint 2010 servers. There are couple of major differences how I would deploy UPS in multi-server production farm scenario which can differ than this article.

  • Logon Account – In this article, I have logged into the server using SP_Farm account which is local admin on the box to configure UPA and UPS service. In production environment, you would be logging in as SP_Install account to configure UPA and UPS service. I would use AutoSPInstaller to configure UPA service and manually follow steps from this article to configure UPS by logging in as SP_Install account on the UPS server.
  • SP_Farm Account Permissions – In this article, I have logged into the server using SP_Farm account which is local admin on the box to configure UPA and UPS service. In Production, SP_Farm account needs to be local admin only during UPS provisioning process. You can remove SP_Farm from local admin after UPS is provisioned. Additionally, SP_Farm account requires to have “Allow log on locally” right on the machine running the UPS service, which can be granted via Group Policy or Local Security Policy on the UPS Machine. If SP_Farm doesn’t have “Allow log on locally” right on the farm without SP_Farm being local admin on the box, FIM windows services may not start properly.
  • FIM and SQL Issues – Since I have provisioned UPS on the same server as SQL Server in my All-UP VM, I needed to make sure FIM windows services are started with “Automatic (Delayed)” status to ensure it starts after SQL Server windows services. In Production environment, most likely SQL Server would be running on different server than UPS service server. You don’t need to worry about changing FIM windows services status from “Automatic” to “Automatic (Delayed)” in the production environment with SQL and FIM windows services running on different servers.

Master References:

That’s it as far as Step by Step details of configuring User Profile Service Application and User Profile Sync Service. Don’t forget to check Harbar’s guides to understand “Why”. They are The best resources on the internet as far as User Profile Sync service for SharePoint 2010 and SharePoint 2013.


Filed under: SP2010 Admin, SP2013 Admin

Step by Step – Building Custom SharePoint 2010 Search Applications using KeyWordQuery API

$
0
0

Note: Download Code discussed in this article from Here.

SharePoint 2010 introduced new ways to query Enterprise Search data using KeywordQuery API. For developers, there are two options available for custom Search applications – FullTextSQLQuery (Executes Search SQL Syntax queries) and KeywordQuery (Supports querying both Enterprise Search Index for SharePoint 2010 Standard and Enterprise product and FAST Index for FAST Server for SharePoint 2010 product) APIs.

KeywordQuery API is preferred approach to query data from SharePoint 2010 Enterprise Search engine. Last October I had demonstrated how to use KeyWordQuery API to build Custom Portal Navigation SharePoint 2010 Web Part using Search API. Additionally, Please note that – with both FullTextSQLQuery and FASTQuery are deprecated or obsolate in SharePoint 2013, Microsoft has strengthed their investment in KeywordQuery API in SharePoint 2013.

Pre-requisites

  • You must configure Search Service Application on the Farm
  • You must run Full Crawl to create crawled properties for any custom SharePoint list or document library metadata
  • Create Managed Search Properties for any Custom Managed list or document library metadata and Run Full Crawl again

Solution

In this step by step guide, we will build Portal Navigation Web Part which would render  Site Collections Navigation by retrieving Site Collection data from Search Index.

0-Portal Navigation

Here are the high levels steps required for developers to build Custom Search Applications  using KeywordQuery API.

Step 1 – Create Visual Studio 2010 Solution based on SharePoint 2010 Empty Project Template

1-Visual Studio Project

Step 2 – Add SharePoint Project Item for Search Application UI & Logic
Depends on what kind of business requirements, plan to add either Custom Web Part (Standard Web Part or Visual Web Part) or Custom Page (Custom Application Page or Site Page).

In our example, we will add Custom Visual Web Part for Portal Navigation Application.

2-Custom Web Part

Step 3 – Reference two Search DLLs from the ISAPI directory

Plan to reference Search DLLs from the Visual Studio Project, Search DLLs are available at SharePoint Root in ISAPI folder

  • C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.Office.Server.dll
  • C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.Office.Server.Search.dll

3-Reference DLLs

Step 4 – Import Search Namespaces in the code components

Next step to import all the Namespaces required to instantiate and run KeyWordQuery object.

using Microsoft.Office.Server;
 using Microsoft.Office.Server.Search;
 using Microsoft.Office.Server.Search.Query; [KeywordQuery Class defined in this namespace]
 using Microsoft.Office.Server.Search.Administration;

4-Import DLLs

Step 5 – Instantiate the KeywordQuery object
You have two options, pass either current site collection (Classic MOSS 2007 way), or pass the Search Query and Site Settings Service proxy (New in SP2010) and instantiate KeywordQuery object

Option 1 =>

SearchQueryAndSiteSettingsServiceProxy settingsProxy = SPFarm.Local.ServiceProxies.GetValue <SearchQueryAndSiteSettingsServiceProxy>();
 SearchServiceApplicationProxy searchProxy = settingsProxy.ApplicationProxies.GetValue <SearchServiceApplicationProxy>("Search Service Application");
 KeywordQuery q = new KeywordQuery(searchProxy);

Option 2 (Preferred Method) =>

SearchServiceApplicationProxy proxy = (SearchServiceApplicationProxy)SearchServiceApplicationProxy.GetProxy(SPServiceContext.GetContext(SPContext.Current.Site));
 KeywordQuery q= new KeywordQuery(proxy);

5-Instantiate Search Service App Proxy

Step 6 – Set KeywordQuery Object Properties

Next step is to instantiate the KeyWordQuery Object and set the required properties. You can reference available properties on MSDN but here are the major properties you should be aware of.

  • QueryText – This is keyword query text (e.g. LastName:”Patel”)
  • ResultTypes – Search result types (default is Relevant Results)
  • HiddenContraints – Allows you to filter by search scope
  • RowLimit – By default, it returns only 50 records, Se this property required to be set to increase number
  • RowsPerPage – Paging
  • IgnoreAllNoiseQuery
  • TrimDuplicates – Trims duplicate results
  • EnableNicknames
  • EnablePhonetic
  • EnableStemming
  • EnableSpellCheck
  • EnableFQL (Allows you to run FAST Query lanaguage syntax on KeyWordQuery API on FAST Server for SharePoint 2010 server)

In our example, we will set the query to “ContentClass:STS_SITE”, which would return all the Site Collections in the specified scope sorted by Last Modified Date.

KeywordQuery keywordQuery = new KeywordQuery(proxy);
keywordQuery.ResultsProvider = SearchProvider.Default;
keywordQuery.ResultTypes = ResultType.RelevantResults;
keywordQuery.TrimDuplicates = true;
keywordQuery.RowLimit = 10;
keywordQuery.QueryText = "ContentClass:STS_SITE";
keywordQuery.SortList.Add("LastModifiedTime", Microsoft.Office.Server.Search.Query.SortDirection.Descending);
keywordQuery.HiddenConstraints = string.Concat("scope:\"", "All Sites", "\"");

6-Instantiate KeyWordQuery Object

Step 7 – Use SelectProperties string collection to Specify which Properties to Query in ResultSet

Use SelectProperties string collection to return custom managed properties
Out of the box, KeywordQuery API will return only default search properties such as Title, Author etc. To return managed properties, use SelectProperties string collection.

keywordQuery.SelectProperties.Add("Title");
keywordQuery.SelectProperties.Add("Path");

7-Select Properties

Step 8 – Execute KeywordQuery Object Execute() method and return ResultTableCollection which can be loaded in ADO.NET DataTable Object

ResultTableCollection results = keywordQuery.Execute();
ResultTable result = results[ResultType.RelevantResults];
DataTable dt = new DataTable();
dt.Load(result, LoadOption.OverwriteChanges);

8-ExecuteQuery
Step 9 – Bind ADO.NET DataTable Object data into ASP.NET or SharePoint Controls for UI

blSites.DataSource = dt;
blSites.DataTextField = "Title";
blSites.DataValueField = "Path";
blSites.DataBind();

9-Bind Result Set

Final Source Code

You can download Visual Studio 2010 Solution from Sky Drive here. Optionally, you can copy and paste from here.

Markup Code


<asp:BulletedList ID="blSites" runat="server" DisplayMode="HyperLink" />

C# Code


using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data;
using Microsoft.SharePoint;
using Microsoft.Office.Server;
using Microsoft.Office.Server.Search;
using Microsoft.Office.Server.Search.Query; //KeywordQuery Class defined in this namespace
using Microsoft.Office.Server.Search.Administration;

namespace SP2010VM.SearchSolutions.CrossSiteCollection_KQL_Farm
{
public partial class CrossSiteCollection_KQL_FarmUserControl : UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
//Instatiate Search Service Application Proxy
SearchServiceApplicationProxy proxy =
(SearchServiceApplicationProxy)SearchServiceApplicationProxy.
GetProxy(SPServiceContext.GetContext(SPContext.Current.Site));

//Instatiate KeywordQuery object and set the query
KeywordQuery keywordQuery = new KeywordQuery(proxy);
keywordQuery.ResultsProvider = SearchProvider.Default;
keywordQuery.ResultTypes = ResultType.RelevantResults;
keywordQuery.TrimDuplicates = true;
keywordQuery.RowLimit = 10;
keywordQuery.QueryText = "ContentClass:STS_SITE";
keywordQuery.SortList.Add("LastModifiedTime", Microsoft.Office.Server.Search.Query.SortDirection.Descending);
keywordQuery.HiddenConstraints = string.Concat("scope:\"", "All Sites", "\"");

//Specify which keyword query properties needs to be returned
keywordQuery.SelectProperties.Add("Title");
keywordQuery.SelectProperties.Add("Path");

//Execute the KeywordQuery query and load the results in the table
ResultTableCollection results = keywordQuery.Execute();
ResultTable result = results[ResultType.RelevantResults];
DataTable dt = new DataTable();
dt.Load(result, LoadOption.OverwriteChanges);

//Bind the table to the bulleted list
blSites.DataSource = dt;
blSites.DataTextField = "Title";
blSites.DataValueField = "Path";
blSites.DataBind();
}
}
}

References


Filed under: SP2010 DEV

My Sites Infrastructure Planning for SharePoint 2013 On-Premises Farm

$
0
0

It is important to plan My Site Infrastructure for SharePoint 2013 farm and fine tune default setting to ensure SharePoint 2013 supports number of My Sites databases and storage quota for each My Site.

Here are the major areas you must consider while deploying My Site Infrastructure on your SharePoint 2013 On-Premises farm.

My Site Host Site Quota

  • Consider Setting the Quota of My Site Host site. By default, this setting is unlimited. Plan to configure My Site Host Quota to ensure it doesn’t grow out of control.
  • If Site Quota is not enough – Users can’t add a profile picture, post pictures in feeds, provision a personal site etc.
  • Check your My Site Host Usage and Site Quota using SPD, log in with My Site Collection Admin ID – http://sharepointyankee.com/2011/12/28/how-much-storage-space-is-my-site-collection-using/

Number of My Site Databases

  • Check the number of My Site databases at the Central Admin -> Application Management -> Databases -> Manage Content Databases -> My Site Web App
  • Default Maximum Number of Sites created Per Database is 5000.
  • Plan to consider capacity planning for My Site Databases. e.g. If you are rolling out My Site Infrastructure for 50000 users, you must plan for changing the default setting or adding more databases depending upon the size of the database. Plan to ensure database size shouldn’t exceed more than 100 GB as per Microsoft’s content database sizing recommendation.

My Site Personal Site Quota

Max Size of My Site Databases

  • You must ensure you would adhere Microsoft Content database sizing guidelines. My Site databases shouldn’t exceed more than 100 GB.
  • Calculate based on previous two data values => Total Database Space required = Number of My Site Databases * My Site Personal Site quota.
  • Based on previous example, if you are rolling out My Site to 50000 users and each has 1 GB My Site, you would need 50 TB database space. With Microsoft’s content database recommendation of 100 GB, you would need 500 My Site databases. This is why My Site is one of the most compelling reasons to move to the cloud. At the time of writing this article, Microsoft allows 25 GB per My Site in the cloud.

Hopefully these information will provide you enough ammunition to plan My Sites for the on-premises farm and why rolling out My Sites to the cloud is compelling business case.


Filed under: SP2013 Admin
Viewing all 86 articles
Browse latest View live