Wednesday, April 8, 2015

How to find which is your default master page for non publishing sites

If you are working with a non publishing site there are probably multiple tweaks to find the master page, the one i find simple (if you have designer) is

1. select each master page in the gallery
2. the one for which "set as default master page" is disabled is the one which already is one





If you are working with a publishing site, finding the default master page is quite straight forward




Hide menu items in a SharePoint site

An interesting question today on technet forum on how we can avoid display of site contents menu in a SharePoint site for users with just read permissions.



My initial reaction was to use security trimming around this control but then there are more options targeted specifically to menu item controls.

So here are the steps

1. Open up the default master page in SharePoint designer. (How to identify default master page is a very dirty tweak but does work).

2. Navigate to the section where SharePoint:MenuItemTemplate are available (right after wssuc:Welcome control usually)

you will find this:





3. The permissingstrings property is the key - choose the permission string for which you want to enable this menu. I changed it to Add and edit list items permissions

  <SharePoint:MenuItemTemplate runat="server" id="MenuItem_ViewAllSiteContents"
 Text="<%$Resources:wss,quiklnch_allcontent_15%>"
 Description="<%$Resources:wss,siteactions_allcontentdescription%>"
 ImageUrl="/_layouts/15/images/allcontent32.png?rev=23"
 MenuGroupId="200"
 Sequence="240"
 UseShortId="true"
 ClientOnClickNavigateUrl="~siteLayouts/viewlsts.aspx"
 PermissionsString="AddListItems, EditListItems"
 PermissionMode="Any" />


4. Save the master page and reload the site collection


Now to have a good idea of all permissionstrings  that are possible, see this entry

Sunday, September 4, 2011

PortalSiteMapProvider was unable to fetch root node


Scenario:
An account with site collection admin privileges gets "access denied" message on accessing the page

Symptom:
Check ULS logs and you find the following message (note URL below depends on your default page)


PortalSiteMapProvider was unable to fetch root node, request URL: /default.aspx, message: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)),

Resolution
There could be multiple reasons for this, one possible reason is that your application pool account does not have full permissions to read the complete site collection.
  • Identify your web apps' app pool account using inetmgr
  • Login to central site administration
  • Go to Application management > Policy for web application
  • Choose the web application where the inaccessible site collection exists
  • Add a full control policy for the app pool account
Possible cause
Derived from resolution :) this could be because portal site map provider uses elevated privileges within its code and when you use elevate privileges it is always the app pool account that is used internally (you may see it as system account on the ui).

Sunday, August 28, 2011

Traces of history with vti_bin

vti_bin is the folder where you will find sharepoint svc files and asmx file and the very informative owssvr.dll.
Ever wondered what vti_bin stands for? and where the vti comes from...
Apparently it is a piece of history which reminds the roots of SharePoint in frontpage. vti is Vermeer Technologies Incorporated acquired by Microsoft long time ago.

Sunday, July 3, 2011

Test-SPContentDatabase - missing feature

A missing feature in content db refers to orphan references to uninstalled features.
Painful among these would be the features that are scoped at web.

One possible cause of this could be the way the feature was uninstalled. if the feature was uninstalled with powershell script logic
   $subwebs = get-spweb -site xxxxx
   foreach($web in $subwebs)
            disable-spfeature -identify yyyy -url $web.url

it will appear fine but fail in some farms where the number of sub webs in high use
 $subwebs = get-spweb -site xxxxx -Limit all

is the right way


but this is postmortem, what do we do about features that are missing at web levle

There are quite a few things you may have to do
1. Identify the missing feature
              you can do that by taking the feature id from test-spcontentdatabase command and searching it in dev environment or your source code repository

2. Re-install the missing feature
               bring it back to the environment - reinstall it

3. Deactivate properly at all web levels
                write powershell script to loop through and disable the feature at all levels

here is a sample code:

Add-PSSnapin Microsoft.SharePoint.PowerShell -EA 0
$featureid = $args[0]
$featuretocheck = Get-SPFeature -Identity $featureid
Write-Host "Checking for feature" $featuretocheck.DisplayName
$webapps = Get-SPWebApplication
foreach ($webapp in $webapps)
{
 Write-Host "looping through webapp" $webapp.url
 $sites = Get-SPSite -WebApplication $webapp -Limit ALL
 foreach ($site in $sites)
 {
  Write-Host "looping through site" $site.url
  $subwebs = Get-SPWeb -Limit ALL -Site $site
  foreach ($subweb in $subwebs)
  {
   Write-Host "verifying web" $subweb.title
   $feature = Get-SPFeature -Identity $featureid -Web $subweb -ErrorAction SilentlyContinue
   if ($feature)
   {
    Write-Host "Activated -" $subweb.title -ForegroundColor Red
    #Disable-SPFeature -Identity $featureid -Url $web.url   }
   else
   {
    Write-Host "Not Activated -" $subweb.title -ForegroundColor Green
   }
  
  }
 }
}

Friday, December 31, 2010

FileNotFound Exception while creating SPSite Object

The file not found exception could be one of the first SP 2010 exception any developer could face. For one it is surely something we did not encounter in 2007.

The usual suspects are well documented in many blogs:
http://edwin.vriethoff.net/2010/03/22/visual-studio-and-sharepoint-2010-new-spweb-returns-filenotfoundexception/

they are related to
1. project not compiled against .net 3.5
2. platform target not x64 or any

another 1 to look for is debug platform target is not x64. Check this in Project --> Properties --> Debug tab
If you have trouble setting this use the configuration manager, you can invoke the dialog from the debug drop down you see in tool bar.

I am not elaborating these much because that is not the point of this blog, I could find the above three solutions well documented else where

If your simple new SPSite (url) does not still work (mine dint) then start fiddling around for some clues at the usual places - eventvwr logs, 14 hive logs etc.,
what I found in eventvwr application logs is this


SQL database login for 'SharePoint_Config' on instance 'axxxxxxx' failed. Additional error information from SQL Server is included below.


Login failed for user 'xxxx\yyyyyy'.


That's it, this very informative error message can be thrown even if the user account under whose content ur code is running (logged in user if it is a console app) does not have login rights - and probably read access as well..
Go ahead and provide the necessary permissions - if u had broken ur head for 3 hrs to get around to this point, you would most likely end up giving sysadmin priv to the user and get past this error like i did, but pbly read on config and the content db shd be enough.

Tuesday, August 31, 2010

SharePoint 2010 Management Shell: Finding your way around

Windows powershell is new to SharePoint 2010 developers/administrators. In terms of technology and adoption, however, it is the other way around - Powershell has been around for long. Exchange Server, SQL Server have their own management shell on top of PS. 


SharePoint, as is the practice, understandably, takes a while to adopt and use the latest; the Sharepoint snapin and cmdlets comes with the 2010 release. 


It should ideally be bye-bye time to stsadm command now. If not it is a good excuse to create your own custom cmdlet


For new users, it will take a while to get an idea of the power of Powershell; here are a set of tips for finding your way around and getting comfortable with using it


A couple of useful commands that comes in handy everytime for me are get-command and get-help.


Note: if you donot find SP after the hyphen then the cmdlet is not a SharePoint cmdlet and most probably it is available as cmdlet in Windows Poweshell

Let us take the scenario where you have created a farm solution (not sandbox, with 2010 we have to be clearer :)) and is planning to add that to your environment. Do not use stsadm -o addsolution however tempting it turns out to be - look for the corresponding powershell cmdlet


Tip #1: Use Get-Command with wildcards:
You know for sure that cmdlet name will solution, so search for it in SharePoint management shell with
Get-Command *solution*






Tip #2: Use Get-Command with specific command
Now that you have go the cmdlet look closer at to what is its syntax
Get-Command Add-SPSolution 








Tip #3: Use Get-Help with specific command



Get Help is another command you can use, which will say in words and through description (surprisingly good documentation) what the command is all about
Get-Help Add-SPSolution







Tip #4: Use Get-Help with examples switch



In case you need to see some examples on how the command has to be used go for examples switch. 
Get-Help Add-SPSolution -examples



Finally, go ahead and add the solution

You would like the output it gives, right :) Now try to find out how to deploy the solution through cmdlet. Don't be surprised by the output that cmdlet gives (:()



Note: good time to familiarize yourself with the term switch. In powershell there are 3 terminologies used for specifying the inputs to a cmdlet
Parameter : parameter is the name of the cmdlet property for which a value is provided (for e.g. in the Add-SPSolution cmdlet call LiteralPath is a parameter)
Argument : The value that is passed to the parameter (for e.g. in the Add-SPSolution cmdlet call the physical path of the wsp file is the argument)
Switch : the parameter that does not need an argument (for e.g. in the Get-Help cmdlet examples is a switch, imagine turning on a switch and a behavior gets added to the cmdlet)