Friday, October 31, 2014

SHAREPOINT SECURITY ACCOUNT SEPARATION AND CONFIGURATION


I’m going to offer the approach I take on this task. I’ll highlight all of the different accounts I typically create, where/how to assign them in the farm, and even a few that are often overlooked due to their almost hidden nature. I’ve been applying this same approach to most farms I’ve configured recently, even my own development images.
As a side-note, I used to run with very little separation in my development virtual machines… it’s a development virtual, it doesn’t need a high level of security separation right? But lately I’ve been applying the same level of service account separation to my development images as I would for any production system. I do this because I both want to catch security related bugs in my custom solutions early in the development process, and I just plain hate seeing that red Health Analyzer bar telling me my farm has issues every time I visit Central Admin :)
These are the accounts I recommend creating in AD:
  • sp_Install
  • sp_Farm
  • sp_Admin
  • sp_Sites
  • sp_UserProfile
  • sp_UserCode
  • sp_Service
  • sp_Search
  • sp_SearchCrawler
  • sp_Cache (If SharePoint 2013)
  • sp_SuperUser
  • sp_SuperReader
Vary the naming on these to suit you or your organizations likes, policies, etc. on naming convention. I’ve often gone with more descriptive naming, such as sp_DistributedCache instead of just sp_Cache. I’ve also sometimes name them for the environment, such as SP2010_Farm or SP2013_Farm (which you may notice in some of my screenshots). Can be important if you’re in an organization that has multiple SharePoint rollouts and you want, or don’t want, to do any credential sharing. You get the idea.
The first account, sp_Install, is going to be your super privileged account that will perform the SharePoint installation and run the Products and Technology Wizard. This account will need local administrator rights on every server in the farm, plus securityadmin and dbcreator rights to the SQL server.
Chances are, if you’re already looking at a prebuilt SharePoint farm prior to reading this article, it’s too late to do this one. Not a biggie. A lot of farms start off with the sp_Farm account serving this dual purpose of also being the installation account. The thing to remember under that circumstance, however, is there’s a good chance this means that your existing sp_Farm account could still be in the local administrators group… something the Health Analyzer will gripe about. As a best practice the farm account should not be a part of the local administrators group. This is where having a separate install account is nice, as it keeps you from having to put the farm account back into the local administrator group again later if you’re going to install any SharePoint service packs or cumulative updates, then removing it again when done. It also keeps you from the temptation of just leaving the farm account in the local administrator group all the time.
Assuming this is a fresh install, and you just performed your installation using sp_Install, the next thing you’re going to want to do is set sp_Farm as your Farm Account. First step is that this account will need to be registered as a Managed Account. There are a number of other service accounts that also must be Managed Accounts, so we can just set them all at the same time.
A special note about the account sp_UserCode, which is for the Sandbox Code Service. This account must also be added to the Performance Log Users and Performance Monitor Users groups on each machine that will be running the Sandbox Code Service. Without these permissions the service won’t run. The SharePoint Central Administration site will report that it’s running, but if you take a look at the actual Windows Service “SharePoint User Code Host” it will be in a stopped state, and will immediately stop every time you try to manually start it.
These following accounts need to be setup as Managed Accounts in SharePoint:
  • sp_Farm
  • sp_Sites
  • sp_UserProfile
  • sp_UserCode
  • sp_Service
  • sp_Search
  • sp_Cache (if SharePoint 2013)
Managed Accounts can be registered via Central Administration -> Security -> “Configure managed accounts”:
They can also be added using the PowerShell cmdlet Set-SPManagedAccount.
Managed Accounts are accounts that can be configured to have passwords reset on a set schedule, automatically by SharePoint, if desired. There are a number of services in the farm that only accept picking a Managed Account from a dropdown. So, whether you plan to utilize the password resetting feature or not, these particular accounts will need to be registered with the system prior to them being available for selection in the aforementioned dropdowns.
After setting up the Managed Accounts lets go and start assigning some services. Head to Central Administration -> Security -> “Configure service accounts”:
From this page you can perform a large amount of the security separation:
Using the dropdown, select Farm Account and let the page refresh. Then, from the dropdown below, select the sp_Farm account and hit OK. This may take some time as this is a big reassignment. If you happened to use sp_Farm as your installation account, this will already be set with no need for any reassignment.
Continue on using this page to reassign all of the other accounts as well:
Assign sp_UserProfile to the User Profile Syncronization Service
Assign sp_UserCode to the Sandbox Code Service
Assign sp_Service to:
  • all Service Application Pools
  • the Web Analytics Service
  • the Claims to Windows Token Service
Assign sp_Cache to the Distributed Cache Service (if SharePoint 2013)
Assign sp_Search to:
  • SharePoint Server Search
  • SharePoint Foundation Search
Assign sp_Sites to all Web Application Pools
Next, let’s assign the Search Crawler account. For the sp_SearchCrawler assignment you have to go into the Search Application Management page and click on the account next to “Default content access account”:
After this assignment double check User Policy for all of the web app(s) to make sure that sp_SearchCrawler has Full Read. This should have automatically been applied when making the assignment back in Search Administration, but it never hurts to double check. Plus, there is another task we need to perform while we’re in User Policy. For each web application, assign sp_SuperUser Full Control and sp_SuperRead Full Read via User Policy. These two accounts are used for the Web Object Cache as highlighted by this article: http://technet.microsoft.com/en-us/library/ff758656(v=office.15).aspx
To finish configuring the Web Object Cache you then need to crack open SharePoint Management Shell on one of the servers and enter the following:
$wa = Get-SPWebApplication -Identity “Your Web App URL here”
$wa.Properties["portalsuperuseraccount"] = “YOURDOMAIN\sp_SuperUser”
$wa.Properties["portalsuperreaderaccount"] = “YOURDOMAIN\sp_SuperReader” 
$wa.Update()
The Web Object Cache is something that a lot of farms don’t have setup, and the only hint SharePoint gives you about it not being configured is an error message that shows up every so often in the Event Viewer on the servers.
Jumping back to search, make sure that the sp_SearchCrawler account has permissions to search user profiles. Select the User Profile Service Application (highlight the row, don’t click the link), click Administrators ribbon button, and add the crawler account with the “Retrieve People Data for Search Crawls” permission:
And that should do it!

Wednesday, October 29, 2014

10 Things you can do to make SharePoint Secure

1 - Run the Microsoft Security Assessment Tool & Best Practice Security Analyzer Tool from Microsoft

10 Things you can do to make SharePoint Secure
Too often, we assume we “know” everything already and skip some very basic changes that can help immensely. Check out these two security tools to get you started:
Microsoft Security Assessment Tool
The Microsoft Security Assessment Tool (MSAT) is a risk-assessment application designed to provide information and recommendations about best practices for security within an information technology (IT) infrastructure.
Best Practice Security Analyzer Tool from Microsoft
The Microsoft Baseline Security Analyzer provides a streamlined method to identify missing security updates and common security misconfigurations.

2 - Only enable the required Windows Services where you need them

10 Things you can do to make SharePoint Secure
The fewer Windows Services there are to attack or use to attack your server there are, the better. Disable those that are not required to run your server, remembering that different SharePoint servers may have different needs. Identify those you do not need and stopped them from being used for a security attack.

3 - Only enable the required SharePoint Services where you want them to run

10 Things you can do to make SharePoint Secure
Like the previous mention about Windows Services, the same applies to SharePoint Services. If you do not need to use one of them, then stop it to not only reduce the surface for attacks but also improving SharePoint’s performance.

4 - Create multiple Service Accounts, that do not have Domain or Server Administration Permission

10 Things you can do to make SharePoint Secure
Both SharePoint and Windows Services use accounts to do what they need to do. Some services require more access than others to do what they need. For example, a search account needs at least Read on everything in your SharePoint to successfully crawl. However, it isn’t ideal to grant this kind of power to one specific account. Like this service, along with others like it, create multiple service accounts and grant them just the rights needed to do what they need to do. This way, if one of them is compromised, it is not your entire SharePoint farm at risk. And while we’re on the matter, make sure passwords are not the same for all of them and complex enough not to be guessed.

5 - Use DNS URLs, not Server name for access

10 Things you can do to make SharePoint Secure
Make sure there is no reference to your servers in the url people will use to access SharePoint. Make use of Alternate Access Mapping and ensure everyone and everything is always using DNS names. Giving away the name of your server allows them to better target their attacks.

6 - Only use known ports for access, such as 80 or 443, then control access via Firewalls

10 Things you can do to make SharePoint Secure
Though you may think configuring SharePoint on ports different than the common HTTP and HTTPS defaults will help you, you’re better off letting the firewall do the job.

7 - Do not disable the Windows Server Firewall

10 Things you can do to make SharePoint Secure
Just because it makes it easier does not mean it is “better”. Windows Server Firewall is that built-in software in Windows to protect the server from within; it is an added level of security and works exactly as it’s intended to.  The Windows Firewall allows you to set different rules depending on the network profile currently active. Since this is a SharePoint Server and not a laptop, you will always be running on that one, making its configuration relatively easy. You should only allow connections required for SharePoint to work and connect to things like AD and Office Web Apps.

8 - Utilize the “ViewFormPagesLockdown” feature

10 Things you can do to make SharePoint Secure
Let’s look at not turning on this feature first, open your web search engine and look for “View All Site Content”. If your SharePoint sites are made available anonymously, you’re opening up the door for attacks. Bare in mind that it’s a lot easier to attack things we know exist, not locking down your SharePoint admin pages like View All Site Content for anonymous users allows them to know what exists. The ViewFormPagesLockdown feature, active with Publishing Sites by default allows you to do just that, lockdown the view form pages.

9 - Protect external entry points via firewall rules

10 Things you can do to make SharePoint Secure
Because of how vast SharePoint is, it’s important to protect it from any possible and unwanted external connections. Only open the ports necessary for your visitors or SharePoint services if connected with the cloud in a hybrid scenario.

10 - Allow Permissions only at the levels where needed, Farm, Service, Web, Site Collection, Site and Content.

10 Things you can do to make SharePoint Secure
SharePoint is secure by default; it’s what we do to it that turns it unsecure in most situations. There are different Permission Levels and you can create your own as well, these define what kind of access exists. Then, you grant groups these Permission Levels on SharePoint objects that can use them by breaking their permissions inheritance and set their own. In SharePoint, you don’t see what you don’t have access to, but on the flip side you can use Search to see everything you have access to quite easily. It’s important to understand how this works and plan accordingly. 

SharePoint 2010 database migration to SharePoint 2013


There’s been a lot of discussion about how to prepare and plan for a migration, what it involves, what are the best practices. In this article, let’s get our hands dirty a little bit. Recently I had to do another complete upgrade to SharePoint 2013, and I took the opportunity to capture a few notes and screenshots.
So. Your SharePoint 2013 farm is installed and ready. Today is the day: You migrate your content. What do you do?

Prepare your upgrade to SharePoint 2013

There are excellent TechNet articles about the SharePoint migration process. Very much recommended reading, not to say mandatory:
Step by Step SharePoint 2010 database upgrade to SharePoint 2013

Survey your existing farm

To be fair, you should have done this a while back. For the sake of having a complete picture, I’ll just go over the major points you should look at when you take stock of what content needs to be part of the journey.

Farm Solutions

Before the actual migration, you will want to have clear idea of all farm solutions installed on your SharePoint 2010 servers.  Do you have a plan for every custom or 3rdparty package? Do they exist in 2013 versions or do they work as is? Any missing feature will be reported as such during the upgrade, and can potentially cause issues.
Don’t forget to check Sandbox solutions, if you have them on your farm.
Step by Step SharePoint 2010 database upgrade to SharePoint 2013
For each of those added solutions, you will want an inventory of which site collection and web site uses what. This can potentially be time consuming to compile but might save you headaches later.
Step by Step SharePoint 2010 database upgrade to SharePoint 2013

Web Apps

By now you should know which web applications will be migrated. Take particular note of their authentication methods:
Any web app still in Classic mode will need to be upgraded to Claims on SharePoint 2013
Alternatively, you can change it while it is still running on your 2010 farm, if you feel safe doing so. We will come back to that later.

Copy your content database from 2010 to 2013

Here you have two main options: Pause your 2010 farm to take a cold copy of the content databases, or perform a live copy. Since we want to test with minimal downtime, we take the second choice with the help of SQL Server’s Copy-only backup feature:
Step by Step SharePoint 2010 database upgrade to SharePoint 2013
That will allow you to take a live backup of your DB without interfering with your normal backup schedule, which would do pesky things like clearing your change logs and compromising your disaster recovery plans.
After that you simply restore that backup to your SharePoint 2013 SQL Server, optionally under a new name. No sweat.

Create a target web application

When migrating a SharePoint 2010 content database to upgrade to SharePoint 2013, you need to hook it to an existing web application, obviously. However, most of the time your DB to migrate will include a root site (situated at the path “/” on that web application).
If you have several site collections at the same path, or in fact any web site in your web application with identical paths, conflicts will arise and some of your sites will be inaccessible. But you want to keep the same paths as before, otherwise any paths specified in your content (Links lists, for example) will be broken.
You also want to create your new web application with the same authentication mode as in 2010. If you didn’t upgrade from Claims to Classic in SharePoint 2010, you now need PowerShell to create a Classic mode web application in SharePoint 2013, as they are considered obsolete.
So then, the trick is to make a brand new web application, and just remove its content database (all this through Central Administration). It can live without any DB for now.

Test and Upgrade your migrated database

Let’s recap:
  • You have attached your SharePoint 2010 content database in your SharePoint 2013’s SQL server
  • You have a new web application with no associated content database
You can now test and upgrade (as required) your migrated database. To do so, again we look to PowerShell. The following command will inspect your database and produce a detailed report of upgrade issues found:
Step by Step SharePoint 2010 database upgrade to SharePoint 2013
This is the point where you want to install all third party and in-house customizations. Then re-test your database. Repeat until there are no errors reported, or at least none that you will not be able to live with.

Mount your new database

Next, you can upgrade your database. You can run the upgrade by itself, or as you attach it to your web app. The latter is the preferred process.
But you can’t just add a SP2010 content database to SP2013 through the UI. You will need your tech guy’s favorite swiss-army tool: PowerShell. The command to use is Mount-SPContentDatabase.
Step by Step SharePoint 2010 database upgrade to SharePoint 2013

Browse your upgraded sites

We’re almost done!
You should now be able to browse your new, migrated site. At the beginning it will still present the SharePoint 2010 look and feel, with a small difference:
Step by Step SharePoint 2010 database upgrade to SharePoint 2013
You will see this nice colored banner at the top. The first link will take you to the first step of the site collection upgrade process (TechNet).

Index your new content

All right! Your content is all migrated and upgraded, and ready to use! Let’s throw the search crawler at it now
Step by Step SharePoint 2010 database upgrade to SharePoint 2013
Not bad, one hour for about 24,000 documents, many of them PDFs. And no errors! I can now take advantage of the much improved SharePoint 2013 Search Center on all my content.
All in all, this upgrade to SharePoint 2013 migration went pretty well. There are some third party web parts that I will discuss with the farm’s admin, and a complete Site Template solution which I don’t think will be functional in 2013, given the huge changes in the UI. But even that site’s content is fully browsable and usable as it is now, so likely it will remain in 2010 mode

Wednesday, October 22, 2014

Publishing Save/Close not working



Error
An unexpected error has occurred.
Correlation ID: e3c9c2a2-87b4-40d2-b283-a9ad0eb50541
Date and Time: 10/22/2014 8:44:07 PM

Go back to siteGo back to site

Solution Steps:

$web = get-spweb "http://servername/sites/sitename"
$correctId = $web.Lists["Pages"].ID
$web.AllProperties["__PagesListId"] = $correctId.ToString()
$web.Update()
$web.AllProperties["__PublishingFeatureActivated"] = "True"
$web.Update()

SharePoint 2010 Error – You must specify a value for this required field

One issue that come up when using custom master pages is this error when editing a Team site page and then trying to save the it.
Image
All that causes this is simply a Place holder missing from the Main area of your master page. Even if you’ve moved it to a asp:Panel and declared it as false at the bottom of your master page you’ll still get the error. All is needed is to move content place holder <asp:ContentPlaceHolder id=“PlaceHolderPageTitleInTitleArea”runat=”server”></asp:ContentPlaceHolder> within the s4-bodyContainer div , within the s4-ca div seems to work best. Save the master page and that’s that no more irritating message.
You’ll notice this adds the page title to your master page you will either need to style it, place it in the area you want to display this or hide it if you don’t want to display it

Friday, October 17, 2014

SharePoint User Profile Service Migration from SharePoint 2010 to SharePoint 2013

Identify User Profile Service Databases -

    • User Profile Service Application_ProfileDB_ID
    • User Profile Service Application_SocialDB_ID
    • User Profile Service Application_SyncDB_ID
Note : Managed Metadata Service must be migrated before mingrating user profile service

  • Taking Back Ups of the Identified Databases 
    • Log in to you SQL Management Studio and take backups of the above mentioned Databases (good practice is to make them read only before taking backlups -> right click->properties->option->set read only)



    • Right click on the DB and select Back up - add the path you want the back ups to be stored 



                                                                             01



02

  • Exporting the Encryption Key
    • In the Server where User profile Service is currently running opem CMD and go to "%Program Files%\Microsoft Office Servers\14.0\Synchronization Service\Bin\"
    • Enter “miiskmu.exe"
    • Select export key and click next
    • Enter your farm admin account details and domain and next.
    • Set the path where the key should be exported
    • Click Export

  • Restoring Databases in the new SQL server

      • Copy the backups to the new SQL server ( Its good to have in the same machine while restoring)
      • Open SQL management studio in the new SQL server
      • Check Device, Select the Paths of the Databases and click OK

                                                                                                             03



    • Creating User Profile Service and Mounting The Databases
      • Before Creating the Service Application, User Profile Service in stance should be started
        • Central Administration -> Manage Services on server -> Start User Profile Service

       

      •     Create new Application Pool for user profile service 
                             New-SPServiceApplicationPool -Name  UserProfileServiceAppPool 
               - Account Domain\Username

                 $applicationPool = Get-SPServiceApplicationPool 
               -Identity 'UserProfileServiceAppPool'
                                                                             

        •    Create User Profile Service, using the above application pool and the migrated Databases
                            $UserProfServ = New-SPProfileServiceApplication 
                -Name "User Profile Service Application" 
                  -ApplicationPool $applicationPool 
                  -ProfileDBName "Profile DB Name" 
                  -SocialDBName "Social DB Name" -ProfileSyncDBName "Sync DB Name"


      • Import Encryption Key
        • Save the Exported encryption key in the following location in the application server "c:\\Program Files\Microsoft Office Servers\15.0\Synchronization Service\Bin\"
        • Open CMD and go to "%Program Files%\Microsoft Office Servers\15.0\Synchronization Service\Bin\"
        • Run the following command
          • miiskmu.exe /i c:\\Program Files\Microsoft Office Servers\15.0\Synchronization Service\Bin\keyname {0E19E162-827E-4077-82D4-E6ABD531636E}
                                    Note : GUID is always the same 

      Tuesday, July 1, 2014

      Adding Delimiter between Reapting Table Fields (aka Double Eval)

      I have been working on a problem where Im attempting to capture a merged field from a Repeating Table (infopath form) and add a delimiter between each entry.  This is a Webform.
      The purpose of adding the delimiter is so that later on from sharepoint I can export to Excel for reporting purposes.
      Anyway the function I know Im supposed to use is the Eval function (actually it is supposed to be a double Eval function). 
      The structure looks like this
      eval(eval(group5, 'concat(../../my:MainTable/my:group5/my:Unit, ";")'), "..")
      This actually does work, but the problem its not cycling through the data, its just taking the first field and each time you add a new row it just adds the first entry again.
      for example
      If the first field is dog
      the second field is cat
      and the third field is bird
      it comes out dog;dog;dog;
      It basically ignores the second and thrid entry as if its ignoring the double eval.
      Can anyone see what Im doing wrong with this double eval?

      Help URL Video: https://www.youtube.com/watch?v=ij2KqMH8FCU 

      Monday, June 23, 2014

      Common Error: The site is not valid. The 'Pages' document library is missing.

      The site is not valid. The 'Pages' document library is missing.
      Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
      Exception Details: Microsoft.SharePoint.Publishing.InvalidPublishingWebException: The site is not valid. The 'Pages' document library is missing.
      The interesting piece here is that the Pages library indeed existed but could not be found.
      Background Information
      To understand this we need to look into how the Publishing feature find the Pages library in a Publishing site. As the Pages library does not need to have the name "Pages" - e.g. in German version it has the name "Seiten" SharePoint does not search for the Pages library by name.
      Instead the Publishing feature stores the unique ID of the Pages library in the __PagesListId property which resides in the property bag of the publishing site.
      The above listed error will occur if the value stored in the __PagesListId does not match the ID of the actual Pages library.
      What can cause this problem?
      Honestly: I don't know. I have not managed to forcefully cause such an inconsistency - if one of you has repro steps, please post a comment here!
      How to fix the problem?
      To fix the issue it is required to update the value of the __PagesListId property value to match the ID of the Pages library.
      This can be done (e.g.) through the following Powershell script:


      $web = get-spweb http://site-collection/path-to-affected-site
      $correctId = $web.Lists["Pages"].ID
      $web.AllProperties["__PagesListId"] = $correctId.ToString()
      $web.Update()

      Tuesday, March 25, 2014

      SharePoint: Adding hyperlinks to document libraries

      Sometimes you have external content that you would like to make available from your document library without uploading a file. Examples include documents in other SharePoint sites or libraries, and even links to other web pages including SharePoint pages and external web sites.

      Turns out SharePoint already has this built-in, just well hidden. There is a built-in Content Type called "Link to a Document". Just add this to your library and then just click the "New" dropdown and select "Link to a Document"! It will simply ask you for a document name and url. You can supply a URL to anything that starts with "http://", including both SharePoint documents and external web pages. It does not support a link to a network share such as "\\myfileserver\folder1\somedoc.doc".
      1. Display your library (Example: Shared Documents)
      2. Click Settings and Library Settings
      3. Click Advanced Settings
      4. Check "Allow management of content types" and then OK
      5. In the Settings page scroll down to Content Types and click "Add from existing site content types"
      6. Select "Link to a Document", click Add and then Click OK
      7. Go back to your library and click the New dropdown and select "Link to a Document"
      8. Enter a display name (Document Name) and the URL (must start with http://) and click OK
      So how does it work? The Content Type has a template that is an ASPX page that contains a server side control named SharePoint:UrlRedirector. When this page is rendered it simply redirects to the address listed in the items URL property. Also experiment with adding these built-in content types to your library:
      • Basic Page
      • Web Part Page
      • Dublin Core Columns (Do a web or wikipedia.com search for "Dublin Core")
      • Picture
      You can also add customized folders to the New dropdown. See here. Need to add custom columns / meta data to any of the above? Just create a new Content Type based on one of the above and add it to your library. See here.

      Note:
      First Enabled "SharePoint Server Publishing Infrastructure" features under in Site Action --> Site Settings --> Site Collection Administration