Archiwum kategorii: Sharepoint

SharePoint 2013 Search CSOM default row limit

Could be an interesting hint for those using CSOM search API: why are some of the results not returned?

Is it trim duplicates setting? No.
Is it some wildcard settings of the result source? No.

If you do not set the row limit of the query, you will get by default only 50 items. However, you can increase it like that:

[javascript]
var query = new Microsoft.SharePoint.Client.Search.Query.KeywordQuery(searchContext);
query.set_queryText(‚*’);
query.set_trimDuplicates(false);
query.set_rowLimit(500);
[/javascript]

Last line does the trick. Please note that – by default – 500 is the maximum value.

If you need to increase it, you can do it e.g. via Powershell for the entire search service application:

[powershell]
PS> $mySearchServiceApp = Get-SPEnterpriseSearchServiceApplication
PS> $mySearchServiceApp.MaxRowLimit = 2000
PS> $mySearchServiceApp.Update()
PS> iisreset
[/powershell]

Hope it helps,
Lukasz

SharePoint 2013 Content Editor – zero width space characters

Sometimes, the content editor web part of SharePoint 2013 adds unwanted characters to the text within it. You check once, twice, remove any unnecessary line breaks, spaces etc., but after saving or in the HTML source of the page you find these weird characters: ​ – the zero width spaces (& #8203;)

They can mess up your CSS layout, and frankly, I have not found a solution to force SharePoint not to insert them.

One possible workaround would be to remove them with a library like jQuery, e.g.

[javascript]

$(‚.ms-rtestate-field’).each(function(index,element)  {
var theeditor = $(element);
$(theeditor).html($(theeditor).html().replace(/u200B/g,”));
});
[/javascript]

The selector applies to the content editor webpart of SP2013.

Hope this helps.
Łukasz

SharePoint 2013: Get item order ID in the search results display template

In SharePoint 2013, when creating a custom display template for an item, sometimes you need to know, which item in the whole search results list it is. In other words, you need the information of which item in the whole sequence that is, and perform your own logic according to the parameter.

I’ve looked for the property quite a while, but finally found it. It is called piSearchResultId.

Practically you can call it like that in your display template:

ctx.CurrentItem.piSearchResultId

It’s value is similar to the following:

0_1 for first item in the list
1_1 for the second item
2_1 for the third item
…and so forth.

With such values you can extract the first number, and there you go!

Hope this helps,
Lukasz

Failed to query the OAuth S2S metadata endpoint

Upon registration of workflow service in SharePoint 2013, running the following command in SP Management Shell:
[powershell]Register-SPWorkflowService -SPSite http://testsite/sites/workflow1 -WorkflowHostUri https://testsite:12290[/powershell]
the following error is displayed:

Register-SPWorkflowService : Failed to query the OAuth S2S metadata endpoint at URI http://testsite/sites/workflow1/_layouts/15/metadata/json/1 .

Error details: ‚The metadata endpoint responded with an error. HTTP status code: Forbidden.

It seems that the permissions are missing (403). However, if you open the indicated JSON URL with IE logged in as admin, you get the expected result.

In order to resolve this issue:
1. go to Central Administration
2. Manage Service Applications
3. Select the Workflow Service Application
4. In the ribbon bar, click on „Administators”, add tha Farm Admin and grant him full control.

Re-run the shell command, it should now run smoothly without error.

Hope this helps,
Łukasz

Login prompt when opening Office documents from a public SharePoint site

Hi there,

we have a following scenario:

  • a MOSS 2007 web application,
  • publicly accessible,
  • its URL added in Internet Explorer to the intranet sites,
  • checked in and published office documents within this site.

The problem occurring is that when one wants to open a MS Office document from the site using Internet Explorer, the Office application (Word, Excel..) is asking for username and password, although the document is publicly visible and not password-protected. Even if one clicks „Cancel” on the login prompt, the file is opened seamlessly.

After some research, I came across two possible solutions that can be applied in order to get rid of the unnecessary login prompt: either remove the URL from IE’s intranet sites list (which might not be desired because of other benefits of intranet sites), or make  following changes in the applications settings in IIS (7):

Go to the web site’s features, open the request filtering feature, and in the „HTTP Verbs” tab, add a deny rule for the verbs „OPTIONS” and „PROPFIND„. In my case, the use of checking in/out documents, opening them in read-only mode etc., was not necessary in this application, thus the verbs could be inhibited without the loss of other needed functionalities.

More information can be found in this KB article.

Hope this helps,
Lukasz

Insufficient rights when deploying a SP2010 project from Visual Studio

Hi there,

this time just a quick tip for some of you getting an error when deploying a SharePoint 2010 project from Visual Studio:

Error occurred in deployment step ‚Recycle IIS Application Pool’: Cannot connect to the SharePoint site. If you moved this project to a new computer or if the URL of the SharePoint site has changed since you created the project, update the Site URL property of the project.

In my case, the Site URL property of the project was empty but still the need was to deploy the project globally into the environment.

Furthermore, this message can be somewhat misleading, as it may occur when the user account with which you are deploying the  project with, has insufficient rights to do so (e.g. is not the member of the farm’s administrators group).

Hope this helps,
Lukasz

MOSS Search web service – impersonation problems when calling from an external application

Hi there,

A while ago I was implementing a search functionality within an ASP.NET application. The plan was to use the SharePoint Search for crawling and indexing the contents, and afterwards, from my application, connect to the MOSS web service and perform the needed query upon it.

I had some web sites and BDC applications prepared within a scope; everything crawled and indexed – so far so good.

In the ASP.NET application, the service reference to the exposed asmx has been added (e.g. http://sharepoint/_vti_bin/search.asmx ).
Then I tried to invoke the service sending a query packet xml object:
[csharp]QueryServiceSoapClient client = new QueryServiceSoapClient();

client.Query ("<QueryPacket>….");[/csharp]
At this stage, the following exception occurred:

Error:
Retrieving the COM class factory for component with {CLSID BDEADEE2-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 80070542

It doesn’t say much, does it? After some reading, it came out that the app could not authenticate itself against the MOSS webservice in a correct manner – the credentials for the webservice weren’t passed as one would expect.
Of course, an explicit assignment of username and password was not the way I wanted to go. I needed the application pool account (which had all needed permissions on the webervice) to be used and impersonated on every call to the asmx.

Changing the client’s impersonation level to ‚Delegation’ solved the issue:
[csharp]client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation;[/csharp]
Exception gone, search results present.
Hope this helps,
Łukasz

SharePoint: „Loading this assembly would produce a different grant set from other instances” after a security patch from MS

Hello,

after installing the critical patches for .NET framework, as described in the MS Security Bulletin MS11-100, some of our MOSS 2007 applications were hitting the following exception:

FileLoadException : Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401

It seems that the security fix applied in the patch KB2657424 (maybe also KB2656351, although it’s a different version of .NET framework) has caused this temporary problem. The solution is to recycle the affected applications’ IIS pool – the exceptions don’t occur anymore and applications work correctly again.
The solution with restarting application pools appears to be quite strange, since the whole machine had to be restarted upon installation of those security updates. But still, it worked.

Hope this helps,
Łukasz

SharePoint: backup failed – the current operation timed-out after 3600 seconds

Hi,

A short though maybe a helpful one:

Symptoms:
1. MOSS 2007 central administration states: backup failed. One or more databases weren’t properly backed up.
2. Backup logs contain following message:

Error: Object Shared Search Index failed in event OnPrepareBackup. For more information, see the error log located in the backup directory.
WebException: The current operation timed-out after 3600 seconds

3. Similar message (timeout) regarding the SSP’s database.
4. SSP administration page indicates one or more apparent  endless crawls running, on content sources which are rather small.

Resolution:
1. Restart the Office SharePoint Search service.
2. Clear search index – reset crawled content in SSP’s search administration.
3. Start full crawls on your content sources.

Best,
Łukasz

Posted from WordPress for Android

SharePoint: deleting a SSP leaves a running SQL agent job

Hello,

On one of MS SQL Server database backend machines, I was getting a lot of windows event log entries stating that there was a problem for our SQL Server account with accessing one of the databases:

Login failed for user ‚DOMAINsqluser’. Reason: Failed to open the explicitly specified database. [CLIENT: x.x.x.x]

Investigating the corresponding SQL Server instance logs, further details of the issue followed:

[298] SQLServer Error: 18456, Login failed for user ‚DOMAINsqluser’. [SQLSTATE 28000]

[298] SQLServer Error: 4060, Cannot open database "SSP_XYZ" requested by the login. The login failed. [SQLSTATE 42000]

First idea was of course checking the permissions of the user within that database, but then there came the weird thing – a database with such name did not exist. Another approach was that maybe some old web application has been forgotten and still uses explicitly the DB name (e.g. in web.config). Not the cause either.

Finally, since the database name contained ‘SSP’, it had most probably something to do with a Shared Services Provider database. The current one we have has a different name, so the name occurring in the error logs referred to a non-existing SSP. We were able to find out that such SSP has been created and deleted a while ago. The corresponding database has been also removed from the SQL-Server, but one oddment remained there: a SQL Agent job for deleting expired sessions. The agent tried to connect to that DB every minute, and encountered the error mentioned above.

You can find the jobs either directly in the table ‘msdb.dbo.sysjobs’, or within the object explorer, under the “SQL Server Agent” node:

sql server agent jobs

Deleting or disabling the job responsible for connecting to the non-existing SSP’s database solves the problem.

Hope this helps,
Łukasz