Monday, June 3, 2013

How to identify and clean up orphan sites in sharepoint

Orphan sites are of two types, Content DB and Config DB orphan sites.
Content DB orphan sites have entries of a site collection in content DB but no entries are found in Config Database siteMap table.
Config DB orphan sites have entries of site collection in sitemap table, but no entries for the site exists in content DB. This type of orphan’s are more problematic and can even cause your search crawls to fails.
 ·        Identification of orphan sites by running SQL query
Run preupgrade check on your farm which will generate report with a list of orphan sites. Generally this reports only on content DB orphan sites and not on Config DB orphan sites.
Alternatively you can use the following query to identify all orphan sites in a farm
Use TEMPDB
Drop table orphanlist

CREATE TABLE [dbo].[orphanlist](
[farm] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[databasename] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[SiteID] [uniqueidentifier] NULL,
[sitepath] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[type] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
)

drop table orphan_hopper  
declare  
@dbname as varchar(250), 
@cmdstr as varchar(2000), 
@dbid as varchar(250),
@configdb as varchar(250)  

select @configdb = 'YOUR_config_db_HERE'

select @cmdstr = 
'select distinct b.name as ''databasename'', b.id as ''dbid'' into orphan_hopper 
from 
 [' + @configdb + '].dbo.sitemap as a inner join   
 [' + @configdb + '].dbo.objects as b on a.databaseid=b.id inner join   
 [' + @configdb + '].dbo.objects as c on c.id=a.applicationid inner join   
 [' + @configdb + '].dbo.objects as d on b.parentid=d.id inner join   
 [' + @configdb + '].dbo.objects as e on d.parentid=e.id  '  
exec (@cmdstr)    

DECLARE DBCursor CURSOR For 
  Select databasename, dbid 
  From orphan_hopper 

OPEN DBCursor 
FETCH NEXT FROM DBCursor into @DBName, @dbid 

WHILE @@FETCH_STATUS =0 
BEGIN 
 INSERT INTO orphanlist([Type], farm, databasename,[sitepath], SiteID) 
 EXEC 
  (' 
select ''Potential ConfigDB orphan:'' + '''+@dbname+'''   as [Type], '''+@configdb+''' as [farm], '''+@dbname+''' as [databasename],path as [sitepath], id as [SiteID] from ['+@configdb+'].dbo.sitemap where id not in (select id from ['+@dbname+'].dbo.sites) and databaseid = '''+@dbid+''' 
union 
select ''Potential ConfigDB orphan:'' + '''+@dbname+'''   as [Type], '''+@configdb+''' as [farm], '''+@dbname+''' as [databasename],path as [sitepath], id as [SiteID] from ['+@configdb+'].dbo.sitemap where id not in (select siteid from ['+@dbname+'].dbo.webs where parentwebid is null) and databaseid = '''+@dbid+''' 
union 
select ''Potential ContentDB orphans:'' + '''+@dbname+''' as [Type], '''+@configdb+''' as [farm], '''+@dbname+''' as [databasename],fullurl as [sitepath], siteid as [SiteID] from ['+@dbname+'].dbo.webs where parentwebid is null and siteid not in (select id from ['+@configdb+'].dbo.sitemap where databaseid = '''+@dbid+''') 
union 
select ''Potential ContentDB orphan:'' + '''+@dbname+'''  as [Type], '''+@configdb+''' as [farm], '''+@dbname+''' as [databasename],fullurl as [sitepath], siteid as [SiteID] from ['+@dbname+'].dbo.webs where parentwebid is null and siteid not in (select id from ['+@dbname+'].dbo.sites) 
') 
 FETCH NEXT FROM DBCursor into @DBName, @dbid 
END 
CLOSE DBCursor 
DEALLOCATE DBCursor 

select * from orphanlist 
Drop table orphanlist

·        Identification of orphan site type
SQL query output should be pulled into excel and then based on "type" information column determine if the orphan site is a Config DB and Content DB type.
·        Steps to clean up content DB orphan sites
Run stsadm deletesite to clean up Content DB orphan site.
Note – Take back up of the content DB’s before deleting the orphan sites.
stsadm -o deletesite -databaseserver "instanceName" -databasename  "[ContentDBName]" -siteid "[Site ID]"
·        Steps to clean up Config DB orphan site
a.       Identify the content DB for the orphan site
b.      Make sure that search crawls are not running. Also make sure that user profile import and audience compilation is not running.
c.       Detach the content database from sharepoint central admin
d.      Reattach the content database using “stsadm addcontentDB”
·        Rerun the preupgradeCheck to confirm that orphan sites have been cleaned up.

Wednesday, July 11, 2012

SharePoint 2010 Infopath Print Button

Once you have your Infopath form put together and published to a List, go to the List page.

1. Click on the “List” tab under List Tools
2. Click on the drop down arrow on the “Modify Form Webparts” button
3. Select “(Item) Display Form”
4. This will take you to an edit page screen with your Infopath form set as a webpart
5. Add a “Content Editor Webpart” to the page
6. Edit your new webpart’s source and paste in the following:


input type="button" value=" Print" onclick="window.print();return false;"

Note:


This adds a print button to the page that uses the default print call within a browser.  Since we edited the “Display” form, the button will not appear if a user is editing the form or creating a new item.
tags are not required

Monday, July 2, 2012

Finding List GUID ID

There will be several times when you need the Guid or ID of list or view - for example while passing these in for adding, updating or deleting list item in SharePoint through List service or when setting the Task list to be used with SharePoint Designer Workflows. Here is a simple way to accomplish the same.



For List:


1.Navigate SharePoint site


2.From “Settings” menu select “List Settings”


3.Copy the entire URL and paste in any text editor


It would look something like this:
http://mossserver/_layouts/listedit.aspx?List=%7B2761B4AF%2D6452%2D448F%2DADF6%2D6FBA18DAAB81%7D
1.Delete everying before and including “List=”.


2.Change “%7B” to “{”


3.Change all “%2D” to “-“


4.Chnage “%7D” to “}”


You are now left with the following:
{2761B4AF-6452-448F-ADF6-6FBA18DAAB81}
_



For View:
For View's GUID you can perform the same steps
_


Note:
In case of View its little tedious, because when you will copy the link in text editor it will also consist of GUID of list and url of Source.


For example it would be something like this


http://mossserver/_layouts/listedit.aspx?List=%7B2761B4AF%2D6452%2D448F%2DADF6%2D6FBA18DAAB81%7D&View=%7B58B8F4B8%2DA2F6%2D4E3C%2D9F1F%2D4657F664B4D2%7D&Source=%252F%255Flayouts%252Flistedit%252Easpx%253FList%253D%25257B76E983B9%25252D5FCC%25252D4D3E%25252D8DE9%25252D671932BB3308%25257D


So you have to be careful while removing unnecessary part from the copied link




Sunday, June 24, 2012

Attempted to perform an unauthorized operation


Issue Details:
 System.Web.Services.Protocols.SoapException: Server was unable to process request. —> Attempted to perform an unauthorized operation.



Solution:

Check if the current user has appropriate permissions on SharePoint site.


The Web Application should be configured configured with Integrated Windows Authentication and anonymous access should be disabled/unchecked.


Go to IIS —> Website —> Properties —> Directory Security         —> Uncheck Enable Anonymous Access


 

Tuesday, June 12, 2012

How to make MOSS 2007 search results open in new window

I wanted to be able to open links in new windows since I noticed a lot of users often times were searching for say PDF’s and then they would accidentally close the browser instead of hitting the back button. Big annoyance for them.

So I was snooping around the Search Core Results Web Part’s XSL Editor to see if I could edit the XSL to open links in new windows instead. It’s actually pretty easy, here are the steps:

1. Go to http://portal/searchcenter/pages/results.aspx

2. Modify Shared Web Part for the Search Core Results WebPart

3. Click on the XSL Editor Button

4. I’d suggest copying the contents of the pop up into notepad/wordpad to do your editing.

5. Search for the following lines:


6. At the ends of each of the
tags, you’ll want to add on target=”_blank”

For example to make the link attached to the document icon open in a new window, the full tag would be like this:




Using the same XSL Editor you can also manipulate how your search results are displayed and even include custom content types if you wanted to!

SSP Access Denied Issue

Problem definition:Even though you are the farm administrator, site collection admin for the ssp, you get access denied error, when you click on the 'User profiles and properties'.Sharepoint Central Admin -> SharedServices1 -> User Profiles and My Sites -> User profiles and properties'


Fix:
Go to Personalization services permissions link located under the User Profiles and My Sites section on the shared services1 page.Sharepoint Central Admin -> SharedServices1 -> User Profiles and My Sites -> Personalization services permissions
Add users/group. Add yourself with the manage user profiles permissions.If you are the admin then add the user who complained about the access.

Failed to instantiate file "TopAnswer.webpart" from module "WebPartPopulation": Source path "dwp\TopAnswer.webpart" not found.

Issue Details:


Failed to instantiate file "TopAnswer.webpart" from module "WebPartPopulation": Source path "dwp\TopAnswer.webpart" not found.
Troubleshoot issues with Windows SharePoint Services.


Solution Details:


1. Clear the SharePoint Fonfiguration Log Files


2. Upgrade MOSS SP2.