Using SharePoint 2010’s OOB search result to search in a particular library

There was a requirement to have a search text box and a button in landing page and show OOB search result from a single document library.

After doing some analysis on OOB search the following is the code which we came up with.

The technique is use the query string with query items “k=query”, “cs=This List” & “u=list’s absolute url”. Underlined items are the items which change dynamically.

http://server/sites/site/_layouts/OSSSearchResults.aspx?k=MyQuery&cs=This List&u=http://server/sites/site/MyLibrary

<div>
    <script type="text/javascript">
        function Search() {
            var libraryName = 'Library'; //Library Name            
            var url = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl; //http://server/sites/<sitecollection> orhttp://server/sites/<sitecollection>/site
            var searchUrl = url + '/_layouts/OSSSearchResults.aspx';

            var queryText = document.getElementById('querybox').value;
            var queryUrl = searchUrl + '?k=' + queryText + '&cs=This List&u=' + url + '/' + libraryName; //http://server/sites/<sitecollection>/_layouts/OSSSearchResults.aspx?k=<Query from input box>&cs=This List&u=http://server/sites/<site>/<Library Name>

            window.navigate(queryUrl);
            //alert(queryUrl);
        }            
    </script>
    <input id="querybox" name="querybox" />
    <input onclick="Search()" name="SearchInLibrary" value="Search In Adapter Document Library" type="button" />
</div>

SharePoint 2013 Preview – Hardware Requirements

Recently I was planning to checkout SharePoint 2013 and do a test drive. So to get a virtual machine from our internal cloud hosting I was doing analysis on the hardware requirements for SharePoint 2013 preview and the following came as a shock !

24GB RAM for 2013 preview development server as compared to 4GB for 2010 version.

That’s 6 times of 2010 RAM requirements. I am hoping that the requirements will come down once the SharePoint 2013 goes to RTM.

Hardware requirements—web servers, application servers, and single server installations

Installation ScenarioDeployment type and scaleRAMProcessorHard disk space
Single server with a built-in database or single server that uses SQL ServerDevelopment or evaluation installation of SharePoint Foundation 2013 Preview8 GB64-bit, 4 cores80 GB for system drive
Single server with a built-in database or single server that uses SQL ServerDevelopment or evaluation installation of SharePoint Server 2013 Preview24 GB64-bit, 4 cores80 GB for system drive
Web server or application server in a three-tier farmPilot, user acceptance test, or production deployment of SharePoint Server 2013 Preview12 GB64-bit, 4 cores80 GB for system drive

Hardware requirements—database servers

ComponentMinimum requirement
Processor
  • 64-bit, 4 cores for small deployments
  • 64-bit, 8 cores for medium deployments
RAM
  • 8 GB for small deployments
  • 16 GB for medium deployments

For large deployments, see the “Estimate memory requirements” section in Storage and SQL Server capacity planning and configuration (SharePoint Server 2010).

These values are larger than those recommended as the minimum values for SQL Server because of the distribution of data that is required for a SharePoint 2013 Preview environment. For more information about SQL Server system requirements, see Hardware and Software Requirements for Installing SQL Server 2008 R2.

Hard disk80 GB for system drive

Hard disk space depends on how much content that you have in your deployment. For information about how to estimate the amount of content and other databases for your deployment, see Storage and SQL Server capacity planning and configuration (SharePoint Server 2010).

 

Source: http://technet.microsoft.com/en-us/library/cc262485(v=office.15).aspx#hwforwebserver

The HTTP request is unauthorized with client authentication scheme ‘Ntlm’. The authentication header received from the server was ‘NTLM’

For one of the SharePoint implementation I was suppose to call the SharePoint 2010 ASMX service within a Custom WCF services hosted in a different server than the SharePoint 2010 host.

So as usual I added the service reference (PS: The add web reference is not available in WCF solution). Then I was getting the following error whenever the ASMX method was hit in the WCF.

"The HTTP request is unauthorized with client authentication scheme ‘Ntlm’. The authentication header received from the server was ‘NTLM’"

After breaking my head for few minutes, decided to hit the Google and got the solution in the source mentioned at the end.

So finally the code which worked is listed below.

 
  EndpointAddress endpoint = new EndpointAddress(new Uri("http://SharePointserver/_vti_bin/InvoiceServices.svc"));

  BasicHttpBinding httpBinding = new BasicHttpBinding();

  httpBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;

  httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;

  InvoiceServicesClient myClient = new InvoiceServicesClient(httpBinding, endpoint);

  myClient.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

  //Invoke the service method here…

Source: http://stackoverflow.com/questions/2608887/sharepoint-web-services-the-http-request-is-unauthorized-with-client-authenti

Note, in the above it might look like half of the link is missing and actually it works.

How I use my mobile

Mobile devices context have now changed a lot. Being from simple communication device to full blow Personal Information Manager.

Here in the organization I work for, usage of personal mobiles for official communications are not allowed. Primary reason being data security.

So I use my mobile for staying in touch with my friends, keep track of news and events, manage my personal and official task list etc.

I am going to start of a series of post reviewing the apps I use in mobile and how I use them.

Starting off … My Mobile Desktop

Home Screen

I keep tab at 2 things here.

  1. My team’s time across 3 time zones. This is the default dual clock widget which comes with SGSII.
  2. My messenger status. I use IM+ Pro for messenger and stay connected in Microsoft Live, GTalk, Yahoo & Skype.
  3. Dual Battery Widget helps me keep tab on battery level. Till this date this is one of the best looking battery widgets.
  4. Traffic Counter help to monitor the data usage.

Weather & Entertainment Screen

  1. Keeping updated on weather sometime helps to plan on commuting. I use Accuweather widget which comes with SGSII.
  2. Audio FX widget. Helps to change the audio quality with apps like DI FM. But this one doesn’t work with FM Radio App which comes with SGSII.
  3. PowerAMP 4×2 widget.

Birthday Calendar

Agenda Widget coupled with Gmail Calendar which is synced with FaceBook’s Birthday Events iCal URL.

To Do

I keep track of my to do list with the help of Producteev free account service. Till now one of the best online task management service which has apps for all the platforms.

Switches

Finally the switches screen where I utilize Tasker app’s widget to control various tasks.

 

Mostly I try to keep my widgets as low as possible and try to use dark wallpapers to conserve CPU usage, screen brightness and in turn save battery. On a whole the combination of screens help me keep tabs on information.

The most useful are the Producteev and IM+ Widgets.

Producteev helps to have glance at non completed items and those due today & IM+ Pro helps me keep the count of non responded messages and online status.

In addition to above you can see 2 non-standard SGSII icons on status bar related to following apps.

  1. MyPhoneExplorer status.
  2. Smart App Protector.

More about all these apps in upcoming posts !

Links to applications mentioned in the post

Agenda Widget for Android
https://play.google.com/store/apps/details?id=com.roflharrison.agenda

Audio Fx Widget
https://play.google.com/store/apps/details?id=com.namakerorin.audiofxwidget

Dual Battery Widget
https://play.google.com/store/apps/details?id=org.flexlabs.widgets.dualbattery

Facebook for Android
https://play.google.com/store/apps/details?id=com.facebook.katana

IM+
https://play.google.com/store/apps/details?id=de.shapeservices.impluslite#?t=W251bGwsMSwxLDIxMiwiZGUuc2hhcGVzZXJ2aWNlcy5pbXBsdXNsaXRlIl0.

MyPhoneExplorer Client
https://play.google.com/store/apps/details?id=com.fjsoft.myphoneexplorer.client

Poweramp Standard Widget Pack
https://play.google.com/store/apps/details?id=com.maxmpz.audioplayer.widgetpack1

Producteev
https://play.google.com/store/apps/details?id=com.producteev.android.alpha22

Smart App Protector(app lock)
https://play.google.com/store/apps/details?id=com.sp.protector.free

Traffic Counter Extended
https://play.google.com/store/apps/details?id=com.carl.trafficcounter

Twitter
https://play.google.com/store/apps/details?id=com.twitter.android

SharePoint Error – Code blocks are not allowed in this file

When I was adding an in-line code into master page I was getting the following error.

An error occurred during the processing of /sites/<collection>/SitePages/Welcome.master. Code blocks are not allowed in this file.

The fix is add the following code to the web.config of the web application which hosts the site collection.



Displaying Current User In SharePoint Master Page

One of the requirements while I was working in SharePoint 2010 was displaying the user name in the master page.

So the following are the 2 pieces of code.

Add the following code to the body tag inside master page. Make sure the below code is outside of any tag which has the runat=”server” property set.

<script type=”text/javascript”>var loginName = “<%= Microsoft.SharePoint.SPContext.Current.Web.CurrentUser.Name %>”;</script>

Now put the following code where ever required.

<span>Welcome, <script type=”text/javascript”>document.write(loginName);</script></span>

 

If you face the following error…check out the link https://blog.binarybits.net/?p=207

An unexpected error has occurred 

If you face the following error…check out the link https://blog.binarybits.net/?p=215

Code blocks are not allowed in this file

If you face the following error… check out the link https://blog.binarybits.net/?p=211

The Controls collection cannot be modified because the control contains code blocks (i.e. <% … %>).

 

The Controls collection cannot be modified because the control contains code blocks (i.e. ).

While I was writing an in-line code with javascript inside the master page I was constantly facing the following exception.

The Controls collection cannot be modified because the control contains code blocks (i.e. <% … %>).

Welcome, <script type=”text/javascript”>var loginName = “<%= SPContext.Current.Web.CurrentUser.Name %>”;document.write(loginName);</script>

Found out that the javascript with c# code needs to be out of the tag which has runat=”server”. After checking the code I re-wrote the code into 2 pieces

<script type=”text/javascript”>var loginName = “<%= Microsoft.SharePoint.SPContext.Current.Web.CurrentUser.Name %>”;</script>

The above code I moved out of the “<form runat=”server”…” code and the below code inside the required location.

<span>Welcome, <script type=”text/javascript”>document.write(loginName);</script></span>

Now the page is rendered properly.

 

SharePoint Error – An unexpected error has occurred

While I was modifying SharePoint’s master page to put an inline code, I was constantly redirected to SharePoint Error Page “An unexpected error has occurred”.

After spending nearly an hour to get a clue from EventLog and other sources, I found out that by adding the following config codes to web.config of the web application where the site collection resides, we can see the ASP.NET error page with detailed information.

<SafeMode MaxControls=”200″ CallStack=”true”>
<customErrors mode=”Off”/>