Thursday, September 27, 2012

Find All InfoPath Form Libraries in SharePoint

During a Corporate Re-branding project, implemented new logo, color themes all over the SharePoint sites and now, the new Logo must be changed in All the InfoPath Form Libraries!

It was really challenging to manually find InfoPath form libraries in a Large environment with 1500+ site collections. Automation? PowerShell!

Luckily, this time found a partial PowerShell script written by EMC SharePoint consultants and modified the script to get all the InfoPath Form libraries of the web application.

Here goes the PowerShell script to find all InfoPath Form Libraries of the All Site collections.

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null

#For SharePoint 2007
function global:Get-SPSite($url){
    return new-Object Microsoft.SharePoint.SPSite($url)
}

#Get the web application
Write-Host "Enter the Web Application URL:"
$WebAppURL= Read-Host
$SiteColletion = Get-SPSite($WebAppURL)
$WebApp = $SiteColletion.WebApplication

#Write the CSV header
"Site Collection `t Site `t List Name `t List Url `t Docs Count `t Last Modified `t WF Count `t Live WF `t Live WF Names `t Form Template" > c:\InfoPathLibs.csv

#Loop through all site collections of the web app
    foreach ($site in $WebApp.Sites)
    {
       # get the collection of webs
       foreach($web in $site.AllWebs)
        {
            write-host "Scaning Site" $web.title "@" $web.URL
               foreach($list in $web.lists)
               {
                   if( $list.BaseType -eq "DocumentLibrary" -and $list.BaseTemplate -eq "XMLForm")
       {
                  $listModDate = $list.LastItemModifiedDate.ToShortDateString()
                $listTemplate = $list.ServerRelativeDocumentTemplateUrl
                  $listWorkflowCount = $list.WorkflowAssociations.Count
                $listLiveWorkflowCount = 0
                $listLiveWorkflows = ""
       
                foreach ($wf in $list.WorkflowAssociations)
        {
                    if ($wf.Enabled)
         {
                        $listLiveWorkflowCount++
                        if ($listLiveWorkflows.Length -gt 0)
         {
                            $listLiveWorkflows = "$listLiveWorkflows, $($wf.Name)"
                        }
                        else 
         {
                            $listLiveWorkflows = $wf.Name
                        }
                     }
                 }
       #Write data to CSV File
                   $site.RootWeb.Title +"`t" + $web.Title +"`t" + $list.title +"`t" + $Web.Url + "/" + $List.RootFolder.Url  +"`t" + $list.ItemCount +"`t" + $listModDate +"`t" + $listWorkflowCount +"`t" + $listLiveWorkflowCount +"`t" + $listLiveWorkflows +"`t" + $listTemplate >> c:\InfoPathLibs.csv
             }
               }
        }
    }

#Dispose of the site object
$siteColletion.Dispose()
Write-host  "Report Generated at c:\InfoPathLibs.csv" -foregroundcolor green 

Report Screenshot:
Here  is the output of the report which has all the InfoPath Form libraries of the provided web application.
Report shows All InfoPath Form Libraries in the web application



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Monday, September 24, 2012

Integrating SMS Alert Configuration in SharePoint 2010

Introduction:
SMS Alerting is a new feature introduced in SharePoint 2010. Business requirements like, user should get a SMS whenever new announcement published or stock level decreased can be fulfilled with SMS integration. In some cases, SMS is preferred than Email message as SMS is fast and Email may get filtered by SPAM filters.

Perform the following procedure step by step to configure SMS integration with SharePoint to establish SMS notification system.

Enable SMS Alerts in SharePoint 2010 - Steps Overview:
  1. Obtain the SMS Gateway by registering to any of the SMS gateway providers or Setup your own SMS Gateway.
  2. Import the root certificate of the service provider’s Root certificate and create a trusted root authority.
  3. Configure Mobile account settings in SharePoint 2010 central Administration.
  4. Create Alerts/Use third-party applications (like Nintex Workflows) to use the SMS alerts!

Step 1: Obtain the SMS Provider Gateway

SharePoint SMS providers
There are many SMS gateway services available out there in Internet. It is also possible to setup our own SMS gateway (but more cost involved!).
In this implementation guide, we are going to use: redoxygen.net


Step 2: Import the root certificate of the SMS service provider and add it to trusted root certificate authority

SSL connection must be used between the SharePoint server and the SMS service provider. So, we need to have the SMS service provider website’s certificate provider in trusted certificate provider authority store before proceeding to next step.

Obtain a root certificate and create a trusted root certificate authority. Import the root certificate of the service provider's HTTPS Web address, and then create a trusted root authority.

Here, https://www.redoxygen.net uses the certificates from Go Daddy.com, So go to:  https://certs.godaddy.com/anonymous/repository.seam , download the certificate gd-class2-root.cer under Go Daddy Class 2 Certification Authority Root Certificate (DER Format) and place it under: c:\Certificates\ gd-class2-root.cer (or whichever path applicable)
Download GoDaddy's Root Certificate

Now, the next step is to: Add the certificate to trusted root certificate authority store. This can be achieved by PowerShell. Here is how:

$cert = Get-PfxCertificate "C:\certificates\gd-class2-root.cer" 
New-SPTrustedRootAuthority -Name "GoDaddy Inc" -Certificate $cert

if you miss the above steps, You will get an error message "There is a problem connecting to the text message (SMS) service" while configuring Mobile account settings.
sharepoint text message (sms) service settings SMS Gateway Settings in Mobile Account Configuration For SMS Service in SharePoint 2010 Central Administration

Step 3: Configure Mobile account settings in SharePoint central Administration


 1.    Go to: Central Administration >> System Settings >> Configure Mobile Account
Mobile Account Configuration For SMS Service in SharePoint 2010 Central Administration

 2.    Enter the account details you obtained from https://www.redoxygen.net
          a.    Enter the URL as: https://www.redoxygen.net/oms/service.asmx
          b.    Enter your user name and password.
          c.    Click on "Test Service" to validate the settings. You should see "The account is valid”
SMS Gateway settings in Mobile Account Configuration For SMS Service in SharePoint 2010 Central Administration

3.    Click on “Ok” button to save your settings.

The above steps can be automated using PowerShell cmd-let:
Set-SPMobileMessagingAccount -Identity sms -WebApplication <WebApplicationUrl> [-ServiceUrl <ServiceUrl>] [-UserId <UserId>] [-Password <Password>]

Step 4: Create Alerts / Use third-party applications to use the SMS alerts!

Now, everything is done, SharePoint SMS setup is ready! Create your alerts in any list by specifying the mobile number under delivery method as Text Message (SMS) to receive SMS Alerts.
Create New Alert and select delivery Method as: Text Message (SMS) To Receive SMS Alerts in SharePoint
That’s all, you are done! SharePoint will send SMS message as per your alert settings.

Technet Reference: Configure a mobile account

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Sunday, September 23, 2012

SharePoint Developer Dashboard - FAQs

This article is to answer some of the Frequently asked questions on SharePoint developer dashboard.

What is Developer Dashboard in SharePoint?
The developer dashboard is a new feature introduced in SharePoint 2010 to monitor and debug the performance on page by page basis. Remember the old days, when it was too difficult in MOSS 2007 on troubleshooting page delays? Developer dashboard is the answer to them!

What Information it gives to debug and troubleshoot?
Lot!
All operations and its start-end time, Controls and their load time, total execution time, current user, SPRequests, URL, Current page checkout level, current operations being performed,  Call Stacks, Web Server, Critical Events, Database Queries and their execution time, Service Calls, execution time, Events fired during the page rendering, Order of the page lifecycle and time during each stage, etc.

How to Activate SharePoint developer dashboard?
The dashboard is turned off by default. It can be enabled via:
  • Stsadm
  • PowerShell
  • Object model
There are three modes in developer dashboard:
  1. On - Turns On Developer Dashboard all time at the end of the page content.
  2. Off - switch off developer dashboard
  3. OnDemand - You will be able to show or hide the developer dashboard by clicking the image button next to your login name on the page. site collection administrator can toggle it ON or OFF.
Stsadm
stsadm -o setproperty -pn developer-dashboard -pv [mode]
E.g.
stsadm -o setproperty -pn developer-dashboard -pv ondemand

PowerShell:
$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$dashboard = $contentService.DeveloperDashboardSettings
$dashboard.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::Off
$dashboard.Update()

Object Model:
SPWebService contentService = SPWebService.ContentService;
contentService.DeveloperDashboardSettings.DisplayLevel = SPDeveloperDashboardLevel.On;
contentService.DeveloperDashboardSettings.Update();

How to I Launch Developer Dashboard?
once its turned ON every page will have the developer dashboard in its bottom. If its set to "OnDemand", developer dashboard can be launched by clicking the image button next to your login name on the page.
Trigger SharePoint Developer Dashboard OnDemand
 
How to Hide or Disable SharePoint Developer Dashboard?
Any of the above methods like stsadm can be used.
E.g.
stsadm –o setproperty –pn developer-dashboard –pv off

If its is set to on demand, site collection admins can turn it on or off.  When they do, it only turns it on or off for that particular site collection.  Also, only the person who turned it on sees the output.  Other users will not see the output.


How do I monitor my own function with developer dashboard?
Use: spmonitoredscope as
using (new SPMonitoredScope(“Your-Function-Name”))
{
  //Place your code inside
}

"Your-Function-Name" will appear in the developer dashboard!. BTW, SPMonitoredScope isn't accessible in the Sandbox solutions.

Does it available in SharePoint 2010 foundation?

Yes, developer dashboard is available in SharePoint 2010 Foundation as well.

Example of the Developer Dashboard:
SharePoint Developer Dashboard - FAQs

Enable Developer dashboard in SharePoint 2013

All of the above methods work for SharePoint 2013 also! SharePoint 2013 developer dashboard brings new features such as: ULS logs Tab, Opening in new window, MDS Tab, SPRequests tab to debug Object dispose bugs, View all requests, etc. Ondemand option is deprecated in SharePoint 2013.
 developer dashboard sharepoint 2013 enable

SharePoint 2013 developer dashboard relies on Usage and Health Data Collection Service Application. So, Create it first!
New-SPUsageApplication -Name "Health and Usage Application" -DatabaseName "SP2013_Health_and_Usage_Srv"

If you don't do it prior enabling: you will get developer dashboard in SharePoint 2013 empty!
 developer dashboard sharepoint 2013 empty

Feature based solution to Manage SharePoint developer dashboard in central administration
Wictor Wilén has created a Feature based solution to Turn ON/OFF Developer dashboard from Central Administration site.

What Permission we need to run SharePoint developer dashboard?
By default, You need "AddAndCustomizePages". But you can set the "RequiredPermissions" property to base permissions to override.

MSDN Link on Using the Developer Dashboard 

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Wednesday, September 19, 2012

Find All Documents Created or Modified by a Particular User in Specific Date Time

Requirement is to find all documents which are uploaded to the SharePoint environment during the past one Month. PowerShell can do the reporting well. Lets see the code:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

# Set the date Filter
$dateFilter = (Get-Date).AddMonths(-1) #Past Month
"File, Created Time, File Size" | out-file NewDocuments.csv

# Get all Webs
$webs = Get-SPWebApplication "http://sharepoint.crescent.com" | Get-SPSite -Limit All | Get-SPWeb -Limit All

#Iterate through webs
ForEach ($web in $webs) 
{
   #Iterate through All Lists
    ForEach ($list in $web.Lists) 
 {
  #Check for Document Libraries  
        If ($list.BaseType -eq "DocumentLibrary") 
  {
     #Iterate through All documents
                   ForEach ($item in $list.Items)
   {
                  If ($item.URL.StartsWith("_")) {Break} #Skip _catalogs, etc
                  If ($item.URL.EndsWith(".aspx")) {Break} #Skip Form pages
                    If ($item.File.TimeCreated -ge $dateFilter) 
    {
                      $result = """$($web.URL)/$($item.URL)"", $($item.File.TimeCreated), $( [Math]::Round($item.File.Length/1024,2))"
                      $result | Out-File NewDocuments.csv -Append
                 }
                }
        }
    }
}


Same way, we can find all documents uploaded to SharePoint sites based on Date criteria by just checking $item.File.TimeLastModified property. Say For instance,
  • You may be interested to see all old documents created an year back 
  • All documents which are not changed during the past one year.

Find All Documents Created or Modified by a Particular User:
In an another situation, the request is to find all documents either created by  modified by a particular user in SharePoint 2007.
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

#Region MOSS2007-CmdLets
Function global:Get-SPWebApplication($WebAppURL)
{ 
 if($WebAppURL -eq $null)  #Get All Web Applications
    {
  #Sharepoint 2007 powershell spfarm
  $Farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
  $websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]}
  $WebApps = @()
  foreach ($websvc in $websvcs) {
      foreach ($WebApp in $websvc.WebApplications) {
          $WebApps += $WebApp
      }
  }
  return $WebApps
 }
  else #Get Web Application for given URL
 {
    return [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($WebAppURL)
  }
 }
 
Function global:Get-SPSite()
{
  Param( [Parameter(Mandatory=$true)] [string]$SiteCollURL )
 
   if($SiteCollURL -ne '')
    {
    return new-Object Microsoft.SharePoint.SPSite($SiteCollURL)
   }
}

Function global:Get-SPWeb()
{
 Param( [Parameter(Mandatory=$true)] [string]$SiteURL )
  $site = Get-SPSite($SiteURL)
        if($site -ne $null)
            {
               $web=$site.OpenWeb();
            }
    return $web
}
#EndRegion


# Set the date Filter
"File Name `t Created By `t Modified By `t Created `t Last Modified `t File Size `t URL" | out-file AllDocsByUser.csv
 
# Get the Web Application 
$WebApp = Get-SPWebApplication "http://sharepoint.company.com"

#Iterate through site collections
ForEach ($site in $WebApp.Sites)
    {
     #Iterate through webs
     ForEach ($web in $site.AllWebs)
        {
            #Iterate through All Lists
            ForEach ($list in $web.Lists)
            {
            #Check for Document Libraries 
            If ($list.BaseType -eq "DocumentLibrary")
               {
                #Iterate through All documents
                ForEach ($item in $list.Items)
                    {
                        If ($item.URL.StartsWith("_")) {Break} #Skip _catalogs, etc
                        If ($item.URL.EndsWith(".aspx")) {Break} #Skip Form pages
                      
                        If ( ($item.File.Author -like "*domain\user*") -or ($item.File.ModifiedBy -like "*domain\user*"))
                           {
                             $result = "$($item.File.Name) `t $($item.File.Author) `t $($item.File.ModifiedBy) `t $($item.File.TimeCreated) `t $($item.File.TimeLastModified) `t  $( [Math]::Round($item.File.Length/1024,2)) `t $($web.URL)/$($item.URL)"
                              $result | Out-File AllDocsByUser.csv -Append
                           }
                     }
                }
           }
      }
  }


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Sunday, September 16, 2012

Hide SharePoint 2007 List Toolbar buttons and Menu Items

Got a requirement to Hide SharePoint toolbar buttons (E.g. "New", "Upload"), Menu Items (E.g. "Upload Multiple Files", "Alert Me") from all document libraries of a SharePoint 2007 site collection.
  • If its is for just a single document library, this can be achieved by wring Javascript-CSS, place it in Content Editor web part to hide the "New" button.
  • If its for the entire Farm, this can be achieved by Override the ToolbarActionsMenu template: http://blogs.msdn.com/b/dipper/archive/2006/10/05/how-to-remove-or-hiding-items-in-list-toolbar-in-sharepoint-server-2007.aspx
  • HideCustomAction? Nope, ListViewWebPart menu items are rendered as a web control from the Microsoft.SharePoint.dll, So they can't be hidden through the "HideCustomAction" feature.
Hide "New" button from SharePoint 2007 List Toolbar

Solution:
jQuery or JavaScript with Delegate Control. How? The overall idea is, plug the jQuery to hide "New" button into "AdditionalPageHead" delegate control of the Master page.

Just Create a WSP Builder project and add a feature with out receiver. Add a User control (say, HideNewMenu.ascx) 
jQuery code to Hide List toolbar Buttons

Hide New Button from SharePoint List Toolbar
Code for HideNewMenu.ascx
<%@ Control Language="C#" %> 

<script type="text/javascript" src="/_layouts/jQuery/jquery-1.4.1.min.js"></script>
<script>
    $(document).ready(function()
      {
   if(ctx)
      {
                if(ctx.listBaseType == 1)
             {
                      $('.ms-menutoolbar td:lt(4)').hide();
                    }
             }
     });
</script> 

Same way, You can hide any Tool bar buttons. E.g. Hide "Upload" button in Toolbar. Just get into the view source of the page to fetch the target.

<script type="text/javascript" src="/_layouts/jQuery/jquery-1.4.1.min.js"></script>
<script>
    $(document).ready(function()
      {
$('.ms-menutoolbar td:eq(3)').hide();
$('.ms-menutoolbar td:eq(4)').hide();
    });
</script>

Nothing special in Feature.xml, but in Elements.xml update the code so that it applies the delegation on "AdditonalPageHead".

Elements.xml code:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Control
    ControlSrc="~/_controltemplates/HideNewMenu.ascx"
    Sequence="90"
    Id="AdditionalPageHead">
  </Control>
</Elements>


Build and deploy the wsp, Go to Site collection features and activate the feature (I've named it as "Hide New button in Document Library Toolbar") and See it in action in any document library of the site collection.
"New" List toolbar button Hidden

Similarly, If you want to hide individual menu items, you can use the JavaScript from Ayman: http://www.codeproject.com/Articles/32622/SharePoint-Customization-Tricks-Part-1.

If you don't have jQuery and want to achieve the same with JavaScript:
<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("hideNewMenuToolbar()");

function hideNewMenuToolbar()
{
  try
  {
 if(ctx)
 {
 if( ctx.listBaseType == 1 ) //Making sure its a doc lib
 {
 var aTags=document.getElementsByTagName('a');

           for(i=0; i < aTags.length; i++)
            {
               if(aTags[i].id.indexOf("NewMenu")!=-1)  
                 {
                   aTags[i].parentNode.parentNode.style.display='none';
                 }
            }
        }
        }
   }
 catch(e){}
}

</script>

Hide Toolbar Menu Items using jQuery:
Say for E.g. Lets hide the "New Document" Menu item under "New" menu of the document library toolbar:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" type="text/javascript"></script>

<script>
    $(document).ready(function()
      {
   if(ctx)
      {
                if(ctx.listBaseType == 1)
             {
                     $("ie\\:menuitem[text='New Document']").attr('hidden', true);
                   }
             }
     });
</script>

How to Hide Toolbar Menus using JavaScript:
To hide an individual Menu items: say, Hide "New Document" from New button's context Menu in document libraries: You can use MultipleUpload in place of New0 to hide "Multiple File Upload".

<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("hideToolbarItem()");

 function hideToolbarItem()
{
  var doc = document.getElementsByTagName('ie:menuitem'); 

  for (var i = 0; i < doc.length; i++)
  {
    itm = doc[i];    
     if (itm.id.match('New0')!=null) 
        { 
           itm.hidden=true; 
        }
  } 
}
</script>


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Saturday, September 15, 2012

SharePoint Migration Tools Comparison

Disclaimer: By writing this article I'm not promoting or demoting any SharePoint migration product. This analysis was done during early 2012. Product features may get improved meanwhile. Products are compared in the perspective of the features required for my business scenarios.

I've conducted these tests by migrating from our live SPS-2003 and SharePoint 2007 into SharePoint 2010 with all of the tools. We have compared the features/issues/license cost

SharePoint Migration Products Compared?
I've evaluated below products and methods.
  1. Metalogix - Migration Manager for SharePoint http://www.metalogix.com/Products/Migration-Manager-for-SharePoint/SharePoint-Upgrade.aspx
  2. Quest - DELL - Migration Manager for SharePoint  http://software.dell.com/products/migration-suite-for-sharepoint/
  3. MetaVis - Migrator http://www.metavistech.com/product/sharepoint-migration
  4. Avepoint - DocAve Migrator http://www.avepoint.com/sharepoint-to-sharepoint-migration-docave/
  5. Idera - SharePoint migration suite  http://www.idera.com/Products/SharePoint/SharePoint-migration-suite/
  6. Axceler - Davinci Migrator http://www.axceler.com/SharePointMigration/DavinciMigratorforSharePoint2010.aspx
  7. Database Attachment Method!

What Extra values does these Tools adds?
Why we need a separate product for migration? What can't be done in out of the box migration or upgrade methods such as Database attachment/In-place upgrade? Well, it speeds up the migration process and provides these additional functionality

  • Migrate directly from SPS 2003 to SharePoint 2010
  • Template Re-Mapping
  • Sub-site to Site collection Promotion and vice versa
  • List Merging/Splitting
  • Incremental Migration
  • Content From DB
  • Link Verification and Correction
  • Migrate Specific Element like users
  • User Re-mapping/Clean-up
  • Compare Sites/Lists
What Features are compared?
I've tested these major features during this evaluation:

  • SharePoint 2003/2007 Team sites
  • Wiki Libraries
  • Web part pages
  • Custom web parts
  • Users, Permissions and security
  • Site Templates/List Templates
  • InfoPath Forms
  • Content Types
  • SPD/Nintex workflows
  • Data view web parts

List of items which needs manual intervention
  • Site template/List Templates
  • Site definition/List definitions
  • Custom web parts/Third party solutions
  • Features/Solutions/Event handlers/ User controls
  • Content types/InfoPath Form Libraries
  • Master pages/Themes and style sheets
  • SharePoint Central Administration settings
  • Code or pages in _layouts
  • Un-ghosted pages (Custom List views built with SPD)
  • Workflows(Including SPD workflows, Nintex) 
  • Web.config changes
Comparison Table:
Feature
MetalogixMetavisQuestAvepointIderaAxcelerDB Attach Method
Metadata, Versions MigrationYesYesYesYesYesYes, PartiallyYes
Users and GroupsYesYesYesYesYesYes, PartiallyYes
SecurityYesYes. But replaces with “System” in some placesYes. But replaces with “System” in some placesYesYes. But replaces with “System” in some placesYesYes
Infopath Forms MigrationYes - Only files, Not templateYes - Only files, Not templateYes - Only files, Not templateNoYes - Only files, Not templateYes - Only files, Not templateYes
Custom web parts migrationYes – Custom solution must be deployed in target first!YesYesNoYesNoYes – Custom solution must be deployed in target first!
Custom list viewsYesYesYesNoYesYes, PartiallyYes
SPD workflowsNoYes- But Doesn't work!Yes- But Doesn't work!NoYes- But Doesn't work!NoNo
Content TypesYesYesYesNoYesYes, PartiallyYes
Re-TemplatingYesYesYesNoYesNoNo
Re-Architecturing(Moving sub-site as site collection and vice versa)No (but has a workaround)YesYesNoYesNoNo (but has a workaround)
split and merge sites, lists; change list locations and site hierarchiesNo (but has a workaround)YesYesNoYesNoNo (but has a workaround)
Comparing SitesYes -LimitedYesNoNoYesNoNo
InterfaceWindows Application. Need to install on Source, Destination.Windows ApplicationWindows ApplicationWeb ApplicationWindows ApplicationWeb ApplicationN/A
Wiki-PagesYesYes -Not updated contentYes -Not updated contentNoNoNoYes
Web Part Pages/Basic pagesYesNoNoNoNoNoYes
Public Folders/FilesNoYesNoNoYesNoNo
Show/Find SharePoint Objects(Web part pages,webparts, Themes, etc)NoYesYesNoYesNoNo
Incremental Migration, Content From DB, Link Verification and Correction, Migrate Specific Element like usersYesNoNoNoNoNoNo
License Cost$9595 for 300 GB$12960 for 50 GB$8424 per Web Front EndNot considered$10,194 for 300 GBNot consideredNot applicable
Additional content - $36 per GB$7,600.00 for Additional 100 GB$17994 for Unlimited
$17,994 Unlimited


Conclusion? Compare the features you need, compare the cost, Decide the one fits for you.


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Wednesday, September 12, 2012

User Profile Synchronization Service Stuck at "Starting" - Solution

While configuring User Profile Synchronization in SharePoint 2010, User Profile Synchronization service got stuck at "Starting" state. User profile synchronization service was in starting state for long time! I've been banging my head for couple of Hours.
  • Made sure SharePoint web services in IIS is up and running 
  • Verified the environment has latest service pack - SP1 installed. 
  • Verified LoopbackCheck is disabled
  • Verified TCP chimney is disabled (TO check, in cmd: netsh int tcp show global .To Disable: netsh int tcp set global chimney=disabled )
  • While configuring SharePoint, I used SQL Alias. As UPS doesn't like SQL Server FQDN or IP addresses!  I made sure the Farm Account has "DB Creator" and "Security Admin" Roles.
  • Verified Forefront Identity Manager Synchronization Service and the Forefront Identity Manager Service are running in the identity of the account which as Farm Administrator access rights.
  • The account in which I logged on and trying to configure user profile service application has local administrator rights on the farm, But not Farm Administrator account, My Fault!  user profile synchronization service account should have Farm Administrator access.
User Profile Synchronization Service Stuck at "Starting" state

After a while, tried running the FIM client from: C:\Program Files\Microsoft Office Servers\14.0\Synchronization Service\UIShell\miisclient.exe , FIM gave an Error Message: Unable to connect to the synchronization Service. found the root cause of the issue!
FIM Client Error: Unable to connect to the synchronization Service

Solution was: The account I currently logged-in is a Local Administrator account, but not SharePoint Farm Admin! Logged off and logged in with Farm Admin account. Tried stopping the service which was in "Starting" state.

How to stop the User Profile Synchronization service which got stuck at "Starting" state?
In some cases,  user profile synchronization service may started and then stopped. But here, user profile synchronization service hangs! Lets seek help from our friend: PowerShell!  Get the User profile Synchronization service's GUID and pass it to Stop-SPServiceInstace cmdlet.

Get-SPServiceInstance > Services.txt 

This will get all the services along with their GUID to a text file, say "services.txt". Open the file and get the GUID of  User profile Synchronization service which will be in Provisioning state.

Once you get the GUID, execute: Stop-SPServiceInstance and provide the GUID
Stop User profile Synchronization service

Now, again tried starting the user profile sync service (Application Management >> Manage services on server >> start “User Profile Synchronization Service”), waited for 5 - 10 minutes,  Boom! it worked this time!

In an another case, when we tried re-creating the user profile service application, had the same issue. Fix for this issue was to Remove ForefrontIdentityManager certificates from these 3 locations.
  1. Personal
  2. Trusted Root Certification Authorities
  3. Trusted People
ForefrontIdentityManager certificates
This is because, when I deleted an existing user profile service, it didn't delete the certificates and when recreating it caused the issue!

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Tuesday, September 11, 2012

Find and Delete Orphaned Users in SharePoint

Orphaned User? Who are they?
Orphaned users are those who have been disabled/removed from Active Directory, but still have permissions to sites, lists and items. Internally, SharePoint keeps them in "UserInfo" table of the content database for meta-data such as created/modified by fields.

Its unavoidable in any organization where employees constantly on-boarding and off-boarding. Its really difficult to manage, when it comes to thousands of sub-sites, sites, libraries and lists with their own sets of permissions.

Why we care about Orphaned users?
It is a best practice to delete orphaned users to keep the farm clean & organized. Also this will solve the problem of deleted active directory users still appearing on the people picker which was discussed here  People Picker not showing users from Active Directory? . If you know the user base or criteria then you can use: Clean-up User Information List

Found only few users and want to delete them?
Go to: http://YOUR-SHAREPOINT-SITE-URL/_layouts/people.aspx?MembershipGroupId=0
This will give the master list of users in site collection, from here you can remove users who are no longer need by clicking "Remove Users from Site Collection"

If you know the orphaned user name (E.g. Employee left the Company), You can go to above URL Filter and delete the particular user. Alternatively, You can query the SQL Server table to find the orphaned users.  Here is how:

Step 1. Open SQL Server Management Studio from SharePoint's SQL box, and run this query for relevant content database.

SELECT * FROM [MOSS_Content_DatabaseName].[dbo].[UserInfo] WHERE tp_Login='DOMAIN\UserID'

Step 2. Take note of the tp_ID column value

Step 3. Go to http://<your sharepoint-site-collection/_layouts/userdisp.aspx?ID=tp_ID, where tp_ID is the number you found from the above select statement.

Step 4. This will take you to the user's profile where you can click on the Delete User from Site Collection button.

However, it is not possible to manually check for SharePoint 2010 orphaned users and clean them, as it would take lot of time. Things become easier with PowerShell, Lets use it here to find & delete Orphaned users in SharePoint.

How to Find and Delete Orphaned Users in SharePoint using PowerShell
Here is my script to Find and Delete Orphaned SharePoint Domain Users: Find and Delete Orphaned Users in SharePoint with PowerShell

Open Source Utilities to Find & Delete Orphaned Users:
CodePlex tool: http://landofsharepoint.codeplex.com/
Riolinx's Tool: http://www.riolinx.com/en/downloads/p/OrphanedUsersCleaner.zip

Tail: Remove all alerts assigned to Orphaned users: Find and Delete Orphaned Alerts in SharePoint


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Thursday, September 6, 2012

Attach Event Receiver to Specific List Programmatically in SharePoint 2010

Recently, developed a Event Receiver to set Item Level permissions based on the list field "Visible to Visitors". Event receiver binds with all document libraries using ListTemplateId element in Elements.xml.  Event Receiver to Set Item Level Permissions based on List Column Value

How to Associate Event Receiver with a List Programmatically in SharePoint 2010:
SharePoint 2010 offers ListURL to be specified in Elements.xml file to attach the Event Handler to the particular list. MOSS 2007 doesn't! So you have to write code to Register, May be Console application/Feature Receiver, etc.

Code to Register Event Receiver with a Particular List:

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;

namespace SetItemLevelPermission
{ 
    //Class to Register Event Receiver to particular List

    class BindEventHandlerToLists : SPFeatureReceiver
    {
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
              SPWeb  web  =  (SPWeb)properties.Feature.Parent;

              //Get the Lists in which the Event receiver to be attached. We can Get this from Config file instead of hard coding
              //Check whether the List exists!
              SPList list = web.Lists["Project Documents"];

              //Set the Assembly, Class names
              string AssemblyName = "SetItemLevelPermission, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3e166fe20cd991fe";
              string ClassName = "SetItemLevelPermission.SetPermissions";

              //Register the event handlers
              list.EventReceivers.Add(SPEventReceiverType.ItemAdded, AssemblyName, ClassName);
              list.EventReceivers.Add(SPEventReceiverType.ItemUpdating, AssemblyName, ClassName);
              
            list.Update();

        }

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPWeb web = (SPWeb)properties.Feature.Parent;
            SPList list = web.Lists["Project Documents"];

            // Remove the Binding of the Event Handler from Lists
            string AssemblyName = "SetItemLevelPermission, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3e166fe20cd991fe";

            //Delete the Event Receivers
            for(int i=list.EventReceivers.Count-1; i>=0; i--)
            {
                if (list.EventReceivers[i].Assembly == AssemblyName)
                {
                    list.EventReceivers[i].Delete();
                }
            }

        }

        public override void FeatureInstalled(SPFeatureReceiverProperties properties)
        {
            //throw new Exception("The method or operation is not implemented.");
        }

        public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
        {
            //throw new Exception("The method or operation is not implemented.");
        }
    }
 }


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Tuesday, September 4, 2012

Event Receiver to Set Item Level Permissions based on List Column Value

Requirement is to Set Item Level Permission on Document Library Items based on the field in the document library "Visible to Visitors". Field "Visible to Visitors" is a Check box. Technically, When this column set to True, We'll have to do nothing. When this column set to False, we'll have to break the inheritance and remove the visitors group from the Item's permissions.

Lets build a Event Receiver to set Item level permissions based on the field in the Library.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;

namespace SetItemLevelPermission
{
    class SetPermissions : SPItemEventReceiver
    {
        public override void ItemAdded(SPItemEventProperties properties)
        {
            // base.ItemAdded(properties);
            SPListItem item = properties.ListItem;

            //Check whether the List Item has the  "Visible to Visitors" column
            if (item.Fields.ContainsField("Visible to Visitors"))
            {
                //Check whether the Item's "Visible to Visitors" column value is False!
                if (item["Visible to Visitors"].ToString().ToLower() == "false")
                {
                    //Break the Inheritence and Remove the Visitor group
                    SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                        //Break the Inheritence
                        if (!item.HasUniqueRoleAssignments)
                        {
                            item.BreakRoleInheritance(true);
                            //Remove Visitors Group from the Item's permission
                            item.RoleAssignments.Remove(item.Web.AssociatedVisitorGroup);
                        }
                    });
                }
            }
        }

        public override void ItemAdding(SPItemEventProperties properties)
        {
            // base.ItemAdding(properties);

        }

        public override void ItemUpdated(SPItemEventProperties properties)
        {
            // base.ItemUpdated(properties);
        }

        public override void ItemUpdating(SPItemEventProperties properties)
        {
            // base.ItemUpdating(properties);

            //Check whether the List Item has the  "Visible to Visitors" column
            if (properties.ListItem.Fields.ContainsField("Visible to Visitors"))
            {
                //Check whether the "Visible to Visitors" column value is changed 
                //IMPORTANT: Use the internal name in AfterProperties, otherwise, It will not work!!!
                if (properties.ListItem["Visible to Visitors"].ToString().ToLower() != properties.AfterProperties["Visible_x0020_To_x0020_Visitors"].ToString().ToLower())
                {
                    SPListItem item = properties.ListItem;

                    //Check whether the Item's "Visible to Visitors" column value is True!
                    if (properties.AfterProperties["Visible_x0020_To_x0020_Visitors"].ToString().ToLower() == "true")
                        {
                            SPSecurity.RunWithElevatedPrivileges(delegate()
                            {
                                //Reset the Inheritense
                                if (item.HasUniqueRoleAssignments)
                                {
                                    item.ResetRoleInheritance();

                                }
                            });
                        }

                        else //  Visible to Viewers= "false"
                        {
                            //Break the Inheritence and Remove the Visitor group
                            SPSecurity.RunWithElevatedPrivileges(delegate()
                            {
                                //Break the Inheritence
                                if (!item.HasUniqueRoleAssignments)
                                {
                                    item.BreakRoleInheritance(true);

                                    //Remove Visitors Group from the Item's permission
                                    item.RoleAssignments.Remove(item.Web.AssociatedVisitorGroup);
                                }
                            });
                        }
                }
            }
        }
    }
}


Alright, our Event Receiver is ready! Lets Create a Feature to Bind the Event Receiver with All Document Libraries. How? Update the Elements.xml file with the Event Receiver details:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Receivers ListTemplateId="101">
    <Receiver>
      <Name>AddedEventHandler</Name>
      <Type>ItemAdded</Type>
      <SequenceNumber>10000</SequenceNumber>
      <Assembly>SetItemLevelPermission, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3e166fe20cd991fe</Assembly>
      <Class>SetItemLevelPermission.SetPermissions</Class>
      <Data></Data>
      <Filter></Filter>
    </Receiver>

    <Receiver>
      <Name>UpdatingEventHandler</Name>
      <Type>ItemUpdating</Type>
      <SequenceNumber>10000</SequenceNumber>
      <Assembly>SetItemLevelPermission, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3e166fe20cd991fe</Assembly>
      <Class>SetItemLevelPermission.SetPermissions</Class>
      <Data></Data>
      <Filter></Filter>
    </Receiver>

  </Receivers>
</Elements>

Build and Deploy the WSP and we're done!

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


You might also like:

Related Posts Plugin for WordPress, Blogger...