LinkedIn

Tuesday, December 10, 2013

SharePoint Timer Job – SPJobLockType

There are 3 SPJobLockType  available:

1.       SPJobLockType.None -- if you set it none, the instance will run in all the available servers in the Farm (e.g. Application Server Timer Job)
2.       SPJobLockType.ContentDatabase – this will cause 3 instances to be running in each of the Web-Frontends.
3.       SPJobLockType.Job – this will cause only one instance of the job to run on any of the front-end servers. (Note: it is possible to see multiple instances listed in the Job Status .. but if you look at the time it was last run.. only one would have run lately)

If you have to develop a job, you have to first decide on the type of lock you need for your job.

E.g. If your job does something with the files in the Web-Frontend server you might want to use a ContentDatabase lock.. or if you have something that manipulates the data in a list.. you will have to use Job lock.
Note: If you use other types of locks to manipulate the data in a list.. the multiple job instances will run simultaneously and cause Data Update conflict errors.
Note: If for any reason you re-deploy your job.. either put the dll directly in GAC or deploysolution.. make sure you restart the 'Windows Sharepoint Services Timer' service. (OWSTIMER.EXE)Note: The account used by the Timer service should have access to the Content Database.

Here are some sample code(s) of a custom timer job definition:
[Guid("{62FF3B87-654E-41B8-B997-A1EA6720B127}")]
class MyTimerJob1 : SPJobDefinition
{
    public MyTimerJob1()
        : base()
    { }

    public MyTimerJob1(string name, SPService service, SPServer server,
        SPJobLockType lockType) : base(name, service, server, lockType)
    { }

    public MyTimerJob1(string name, SPWebApplication webApplication, SPServer server,
        SPJobLockType lockType) : base(name, webApplication, server, lockType)
    { }

    public override void Execute(Guid targetInstanceId)
    {
        //Execute Timer Job Tasks
    }
}
Remember that the different server roles that we can find on a Sharepoint farm are:

  • Database Server: the server that hosts the Microsoft SQL Server database for the farm. Since Sharepoint Foundation is not typically installed in this server, no jobs will run here.
  • Web Front End Server: server where the Microsoft SharePoint Foundation Web Application service is running on.
  • Application Server: Any other Sharepoint server.
Here are a couple of examples on where the jobs will run depending on the parameters passed to the constructor:

//Job associated with a web app, no server in particular and none lock:
//  will run on all fron end servers.
var jobRunningOnAllFrontEndServers = new MyTimerJob1("mytimerjob", 
    SPWebApplication.Lookup(webAppURI), null, SPJobLockType.None);

//Job associated with a web app, one front end server and job lock:
//  will run only in the frontEndServer1 server.
var jobRunningOnAParticularFronEndServer = new MyTimerJob1("mytimerjob", 
    SPWebApplication.Lookup(webAppURI), fronEndServer1, SPJobLockType.Job);

//Job associated with a webApp, and an app server and lock type job: 
//  it won't run on any server since the server specified is NOT running 
//  the Web Application Service
var jobRunningOnNoServer = new MyTimerJob1("mytimerjob", 
    SPWebApplication.Lookup(webAppURI), appServer1, SPJobLockType.Job);

//Job associated with the timer service, a particular app server and none lock:
//  will run on the appServer1 server only.
var jobRunningOnAppServer = new MyTimerJob1("mytimerjob", 
    SPFarm.Local.TimerService, appServer1, SPJobLockType.None);

Tuesday, December 3, 2013

Business Connectivity Services security overview in SharePoint Server 2010

When a user accesses external data from a Web browser, three systems are involved: the logged on user’s client computer, the Web server farm, and the external system.

  1. From Web browsers, users typically interact with external data in external lists or by using Web Parts. 
  2. The BDC Server Runtime on front-end servers uses data from the Business Data Connectivity service to connect to and execute operations on external systems.
  3.  The Secure Store Service securely stores credential sets for external systems and associates those credential sets to individual or group identities.
  4. The Security Token Service is a Web service that responds to authentication requests by issuing security tokens made up of identity claims that are based on user account information.


The following table describes the authentication modes of the Microsoft Business Connectivity Services:

Authentication mode
Description
PassThrough
Passes the credentials of the logged-on user to the external system. This requires that the user’s credentials are known to the external system.
If the Web application is not configured to authenticate with Windows credentials, the NT Authority/Anonymous Logon account is passed to the external system rather than the user's credentials.
RevertToSelf
When the user is accessing external data from a Web browser, this mode ignores the user’s credentials and sends the application pool identity account under which the BCS runtime is running on the Web server to the external system. When the user is accessing external data from an Office client application, this mode is equivalent to PassThrough mode, because Microsoft Business Connectivity Services running on the client will be running under the user’s credentials.
This mode is called BDC Identity in the Microsoft Business Connectivity Services administration pages and in SharePoint Designer 2010.
WindowsCredentials
For external Web services or databases, this mode uses a Secure Store Service to map the user’s credentials to a set of Windows credentials on the external system.
Credentials
For an external Web service, this mode uses a Secure Store Service to map the user’s credentials to a set of credentials that are supplied by a source other than Windows and that are used to access external data. The Web service should use basic or digest authentication when this mode is used.
ImportantImportant:
To help preserve security in this mode, we recommend that the connection between the Microsoft Business Connectivity Services and the external system should be secured by using Secure Sockets Layer (SSL) or Internet Protocol Security (IPSec).
RDBCredentials
For an external database, this mode uses a Secure Store Service to map the user’s credentials to a set of credentials that are supplied by a source other than Windows. To help preserve security in this mode, we recommend that the connection between the Microsoft Business Connectivity Services and the external system should be secured by using Secure Sockets Layer (SSL) or IPSec.
DigestCredentials
For a WCF Web service, this mode uses a Secure Store Service to map the user’s credentials to a set of credentials using Digest authentication.
Performace Counters in Sharepoint

Objects and Counters
Problem
Resolution Options
Processor
Processor - % Processor Time
Over 75-85%
This shows processor usage over time. If this is consistently too high, you may find performance is adversely affected. Remember to count "Total" in multiprocessor systems. You can measure the utilization on each processor also, to ensure balanced performance between cores.
Upgrade processor
Increase number of processors
Add additional server(s)
Disk
Avg. Disk Queue Length
Gradually increasing, system not in a steady state and queue is backing up
This shows the average number of both read and write requests that were queued for the selected disk during the sample interval. A bigger disk queue length may not be a problem as long as disk reads/writes are not suffering and the system is working in a steady state without expanding queuing.
Increase number or speed of disks
Change array configuration to stripe
Move some data to an alternative server
% Idle Time
Less than 90%
Increase number of disks
Move data to an alternative disk or server
% Free Space
Less than 30%
Increase number of disks
Move data to an alternative disk or server
Memory
Available Mbytes
Less than 2GB on a Web server.
This shows how much physical memory is available for allocation. Insufficient memory leads to excessive use of the page file and an increase in the number of page faults per second.
Add memory.
noteNote:
SQL Server available memory will be low, by design, and does not always indicate a problem.
Cache Faults/sec
Greater than 1
This counter shows the rate at which faults occur when a page is sought in the file system cache and is not found.
Add memory
Increase cache speed or size if possible
Move data to an alternative disk or server
Pages/sec
Greater than 10
This counter shows the rate at which pages are read from or written to disk to resolve hard page faults. If this increases, it indicates system-wide performance problems.
Add memory
Paging File
% Used and % Used Peak
The server paging file, sometimes called the swap file, holds "virtual" memory addresses on disk. Page faults occur when a process has to stop and wait while required "virtual" resources are retrieved from disk into memory. These will be more frequent if the physical memory is inadequate.
Add memory
NIC
Total Bytes/sec
Over 40-50% of network capacity. This is the rate at which data is sent and received via the network interface card.
Investigate further by monitoring Bytes received/sec and Bytes Sent/sec.
Reassess network interface card speed
Check number, size, and usage of memory buffers
Process
Working Set
Greater than 80% of total memory.
This counter indicates the current size (in bytes) of the working set for a given process. This memory is reserved for the process, even if it is not being used.
Add memory
% Processor Time
Over 75-85%.
Increase number of processors
Redistribute workload to additional servers
ASP.NET
Application Pool Recycles
Several per day, causing intermittent slowness.
Make sure that you have not implemented settings that automatically recycle the application pool unnecessarily throughout the day.
Requests Queued
Hundreds or thousands of requests queued.
Implement additional Web servers
The default maximum for this counter is 5,000, and you can change this setting in the Machine.config file
Request Wait Time
As the number of wait events increases, users will experience degraded page rendering performance.
Implement additional Web servers
Requests Rejected
Greater than 0
Implement additional Web servers

References:
http://technet.microsoft.com/en-us/library/ff758658.aspx


Thursday, November 21, 2013

SharePoint Products and Technologies Pre-Upgrade

If the following error is detected by the preupgradecheck process:
Failed : Pending upgrade operation detected in this farm
Running SharePoint Products and Technologies Configuration Wizard may not work. You may have to use the following script:

psconfig -cmd upgrade -inplace b2b -wait

This should solve the problem.

Clearing Transactional Log File

The transaction log for database 'DatabaseName' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases:
Use the following db scripts to clear the log:
use DBName
dbcc shrinkfile(2,2048)

Wednesday, November 20, 2013

Sharepoint 2010 Move-SPSite Issues

Recently in one of the sharepoint migration projects I had a requirement to move all the contents of a sitecollection to a seprate content database. I was using Move-SPSite powesrshell comment and when I executed this command I got error message: Operation is not valid due to the current state of the object. In the eventviewer the error logged was : Database 'WSS_Content_80_Demo' on SQL Server instance 'XXXX' is not empty and does not match current database schema.
After spending sometime searching for the he problem I found that the Content DBs were out of sync. Then I executed the following command:
PSConfig.exe -cmd upgrade -inplace b2b -force -cmd applicationcontent -install -cmd installfeatures

Thursday, June 27, 2013

Sharepoint : Open PDF documents in browser

You can  set "Browser File Handling" property to "Permissive" for a web application in the "General settings" page in SharePoint 2010 Central Administration.


Monday, June 17, 2013

Dynamically creating quick launch header & link in Sharepoint

The following code can be used to create a header in Sharepoint quick launch programmatically. It also adds a new link to the quick launch

 string link = System.Configuration.ConfigurationSettings.AppSettings["link"];

string HeaderlinkTitle = System.Configuration.ConfigurationSettings.AppSettings["HeaderLinkTitle"];
string SublinkTitle = System.Configuration.ConfigurationSettings.AppSettings["SubLinkTitle"];
string SitecollectionURL = System.Configuration.ConfigurationSettings.AppSettings["SitecollectionURL"];

using (SPSite site = new SPSite(SitecollectionURL))

{

SPWeb web = site.OpenWeb();
foreach (SPWeb subweb in site.AllWebs)
{

SPNavigationNodeCollection quickLaunchNodes = subweb.Navigation.QuickLaunch;
bool LinkisThere = false;
for (int i = 0; i <= quickLaunchNodes.Count-1; i++)

{
if (quickLaunchNodes[i].Title == HeaderlinkTitle)
{
LinkisThere = true;
int InitialChildrenCount = quickLaunchNodes[i].Children.Count;
bool ChildrenLinkisThere = false;
for (int j = 0; j < InitialChildrenCount; j++)
{
if (quickLaunchNodes[i].Children[j].Title == SublinkTitle)

{

ChildrenLinkisThere = true;

quickLaunchNodes[i].Children[j].Delete();

SPNavigationNode subMenuItem = new SPNavigationNode(SublinkTitle, link, true);

quickLaunchNodes[i].Children.AddAsFirst(subMenuItem);

break;

}

}

if (InitialChildrenCount == 0

ChildrenLinkisThere == false)

{

SPNavigationNode subMenuItem = new SPNavigationNode(SublinkTitle, link, true);

quickLaunchNodes[i].Children.AddAsFirst(subMenuItem);

}

break;

}

}

if (LinkisThere == false)

{

SPNavigationNode menuItem = new SPNavigationNode(HeaderlinkTitle, link, true);

quickLaunchNodes.AddAsLast(menuItem);

SPNavigationNode subMenuItem = new SPNavigationNode(SublinkTitle, link, true);

quickLaunchNodes[quickLaunchNodes.Count-1].Children.AddAsFirst(subMenuItem);

}

}

Console.WriteLine("Successfull");
Console.Read();

************************************************************************

APP.Config










Error message: “An error has occurred on the server” while working with a Wiki Library

When i navigate to the "Site Pages" library (Go to Site Actions => Site Settings => View All Site Content) in the team site, I was getting this error in the Recently Modified section.This is because there was no indexed columns in the library ( Go to Site Pgaes=> Library Settings => Indexed Columns). In my case the culprit was Wike Page Library.In the List settings, click on "Create a new index". Select "Modified" from the Primary Column drop down. Click on Create to create an indexed column. Now go back to the page where you were seeing the error, now the error should be gone.

For futher details refer the below link:
http://kirkbarrett.wordpress.com/2011/07/04/ambiguous-error-message-an-error-has-occurred-on-the-server-working-with-a-wiki-definition/












Wednesday, May 15, 2013

Media Player in Sharepoint WSS3.0/  MOSS 2007 / Sharepoint 2010 by passing video url as querystring parameter

By placing the below code in the CEWP a Windows Media Player object will be placed on the page to play audio / video. You can pass the url of the media file as querystring parameter.

//Get request parameters through JavaScript

function getParameter ( queryString, parameterName ) {
   // Add "=" to the parameter name (i.e. parameterName=value)
   var parameterName = parameterName + "=";
   if ( queryString.length > 0 ) {
      // Find the beginning of the string
      begin = queryString.indexOf ( parameterName );
      // If the parameter name is not found, skip it, otherwise return the value
      if ( begin != -1 ) {
         // Add the length (integer) to the beginning
         begin += parameterName.length;
         // Multiple parameters are separated by the "&" sign
         end = queryString.indexOf ( "&" , begin );
      if ( end == -1 ) {
         end = queryString.length
      }
      // Return the string
      return unescape ( queryString.substring ( begin, end ) );
   }
   // Return "null" if no parameter has been found
   return "null";
   }
}

//Replace * by empty string
<* object classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="600" height="400" id="mediaplayer1" title="Media Player" >
   <* param name="FileName" value=getParameter(window.top.location.search.substring(1),"mediaurl") >
   <* param name="AutoStart" value="True" >
   <* param name="ShowControls" value="True" >
 <* param name="ShowStatusBar" value="False" >
   <* param name="ShowDisplay" value="False" >
   <* param name="AutoRewind" value="True" >
    <* param name="DisplayBackColor" value="True" / >
    <* param name="BufferingTime" value="6" >
    <* param name="allowfullscreen" value="true">
    <* param name="allowscriptaccess" value="always">
    <* embed src=getParameter(window.top.location.search.substring(1),"mediaurl") width="600" height="400" autostart="True" type="application/x-mplayer2"
 pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/" filename=getParameter(window.top.location.search.substring(1),"mediaurl") showcontrols="True" showstatusbar="False" showdisplay="False" autorewind="True" displaybackcolor="True" bufferingtime="6" >
  <* /embed >
    <* /object >

Wednesday, May 8, 2013

Marketing: Suspect, Prospect, Lead & Oppotunity

Suspect – Everyone in your target market

Prospect – Anyone who can be targetted for your marketing efforts and pre sales activities.

Lead – The right person with the ability to buy. A prospect who has shown a certain level of interest in your products or services

Opportunity – The right person who is ready to buy. A lead who is ready to give you a chance to present your services, to discuss up potential project, or submit a formal quote for your products and services.