Monday, August 17, 2009

Something about SP2010

Hi Friends,

Atleast I am very excited to see SP2010 and can't stop myself from searching about what's new is coming. I got some information and would like to share. So have fun reading this:

14 hive instead of 12 hive

SharePoint Desiger will be a huge thing in SP2010 and some of its operations are included in SharePoint UI. Also Designer workflow deployment, which is a huge pain right now, is included in. Like you can create designer workflow in SD then you can export it to visual studio and that will create your wsp.

Any huge change in database will be batched up and will be executed in batches to avoid performance issue (e.g. deleting huge list.)

Normal WSP creation is included in visual studio.

U2U runs with web service option, the object model option model does not work

Offline modification of content/documents and synchronization is possible

Tenant administration - new level of administration - Highest level of administrator who has all the control - then second level of admin who will have access to particular things.

STSADM is not completely gone but PowerShell will do everything that STSADM does and lot more.

Microsoft Office ribbon used in UI to give better user experience

In MOSS there can be only one Index server per farm. This is a huge issue as if Index server goes down , there is no back up. This is not the case with WFE/SQL/Query server. In SP2010, it is possible to have multiple index server in farm so that the only backup server limitation in MOSS will go away.

Thanks for visiting.

"Contains" option in SharePoint Advanced Search page



If you have seen SharePoint advanced Search Page before and after applying the Microsoft Office Servers Infrastucture Update (which applies updates to Microsoft Office SharePoint Server 2007 (MOSS), Microsoft Search Server, and Search Server Express) you may be puzzled by the disappearance of a options on the Advanced Search page. And one of the most important option which is gone is "Contains" and "does not contains" under property restrictions.

Actually in this update they removed the default options to search by Contains or Does not contain.

Here's what the Advanced Search page used to look like:


To restore the Contains and Does not contain options to the Advanced Search Web Part, use the following steps:

On the Advanced Search page:
click Site Actions
click Edit Page.
From the Advanced Search Web Part, click Edit, and then click Modify Shared Web Part.
Click Properties to expand the selection.
In the Properties text box, click the ellipses to open the Builder dialog box.
In the Builder dialog box, under the root node, find <Option Name="AllowOpContains" Value="False"/>
Thanks for visiting.

Friday, August 14, 2009

Hiding "Edit Page" option in "Site Actions" menu

This is about SITE ACTIONS menu.
I needed to hide the "Edit Page" option under the "Site Actions" menu for all users without Full Control permissions. The following steps removed the edit page option for user's without the managesubwebs right.

Open the master page for the site.
Find the following lines of code:
<SharePoint:MenuItemTemplate runat="server" id="MenuItem_EditPage" Text="<%$Resources:wss,siteactions_editpage%>" Description="<%$Resources:wss,siteactions_editpagedescription%>" ImageUrl="/_layouts/images/ActionsEditPage.gif" MenuGroupId="100" Sequence="200" ClientOnClickNavigateUrl="BLOCKED SCRIPTMSOLayout_ChangeLayoutMode(false);" />

Add to the following lines to the code:
PermissionsString="ManageSubwebs" PermissionMode="Any"

The code should now look like:
<SharePoint:MenuItemTemplate runat="server" id="MenuItem_EditPage" Text="<%$Resources:wss,siteactions_editpage%>" Description="<%$Resources:wss,siteactions_editpagedescription%>" ImageUrl="/_layouts/images/ActionsEditPage.gif" MenuGroupId="100" Sequence="200" ClientOnClickNavigateUrl="BLOCKED SCRIPTMSOLayout_ChangeLayoutMode(false);" PermissionsString="ManageSubwebs" PermissionMode="Any" />

Save the master page and you are done. Thanks for visiting.

Tuesday, August 4, 2009

Changing sharePoint default search scope - without modifying OOB file

Previously I posted about changing search scope in Search drop down. But that solution requires modifying OOB xml file (C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\OSearchEnhancedFeature\ SearchArea.xml), which is not recommended.

So I decided to investigate an laternate Microsoft recomended way and I got one.

What I did was copied whole feature folder "OSearchEnhancedFeature" and named the new folder "OSearchEnhancedFeatureCustom".
Then I added this line to SearchArea.xml in the new folder "OSearchEnhancedFeatureCustom".
<property name="DropDownMode">ShowDD_DefaultContextual</property>

Also don't forget to remove all CustomActions from file "searchadminlinks.xml" otherwise you will have duplicate links for Search options on Site Settings page.

This feature will get installed at Web Application level and you can activate it only for the web applications you need to.

Thanks.

Thursday, July 2, 2009

Changing SharePoint default search scope

If you have Advanced Search enabled in your SharePoint site, then on your site’s home page Search drop down box, you will see 3 options :
This Site : Your Site Name (This will search only on the current site collection)
All Sites (This will search in everywhere in farm)
People (This is for searching people from AD)

In the drop down the default selected scope is “All Sites”. That means whenever user wants to search something on your site, he has to change value in drop down every time. So it is very obvious to change the default to “This Site : Your Site Name”, because most of the times user wants to search only in your site.

To change this default value, we need to make only one change in following file:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\OSearchEnhancedFeature\ SearchArea.xml

We have to add one PropertyName line at the end of the file (right after line <property name="ShowAdvancedSearch">true</property>)

<property name="DropDownMode">ShowDD_DefaultContextual</property>

That’s it. We are done.
The only thing that most of us wouldn’t like is to modify oob xml file. But I think we can add/remove this line using feature in this file. So that we can overcome all known issues.

Thursday, June 25, 2009

PowerShell script to Remove user from SharePoint Group

Here is a small script I created today in PowerShell to delete a particular user from all sites of a particular web application's particular group.
It reads 3 inputs from user.
(1) Web Application URL (2) Group Name (e.g Viewers) (3) User Login Name (domain\userid)



#####################################################################################
# This script reads Web Application URL, Group Name and User Name to delete user from Group from all Sites of Web Application
# Limitations : Only one user id from only one Group of only one Web Application can be deleted
#####################################################################################

function global:RemoveUser()
{

#------------------------------------------------------------------------------------
# GAC
[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c") Out-Null
[System.Reflection.Assembly]::Load("Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c") Out-Null
[System.Reflection.Assembly]::Load("Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c") Out-Null
[System.Reflection.Assembly]::Load("System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") Out-Null
#------------------------------------------------------------------------------------
# Read Web-Application URL
$WebApplicationUrl = "";
while ($WebApplicationUrl -eq "" -or $WebApplicationUrl -eq " " -or $WebApplicationUrl -eq $null)
{
$WebApplicationUrl = Read-Host "Enter Web Application Url to Delete User form "
if($WebApplicationUrl -eq "Q" -or $WebApplicationUrl -eq "q")
{
return;
}
#Check Required Vars
if($WebApplicationUrl -eq "" -or $WebApplicationUrl -eq $null )
{
Write-Host -ForegroundColor "Red" "`n Web Application Url to Delete User form is required. `n"
}
}
#------------------------------------------------------------------------------------
# Read Group Name
$SiteGroupName = "";
while ($SiteGroupName -eq "" -or $SiteGroupName -eq " " -or $SiteGroupName -eq $null)
{
$SiteGroupName = Read-Host "Enter Group Name to delete user from "
if($SiteGroupName -eq "Q" -or $SiteGroupName -eq "q")
{
return;
}
#Check Required Vars
if($SiteGroupName -eq "" -or $SiteGroupName -eq $null )
{
Write-Host -ForegroundColor "Red" "`n Group Name to delete user from is required. `n"
}
}
#------------------------------------------------------------------------------------
# Read User Name
$UserName = "";
while ($UserName -eq "" -or $UserName -eq " " -or $UserName -eq $null)
{
$UserName = Read-Host "Enter User Login Name to delete (e.g. Domain\UserId, System\User1) "
if($UserName -eq "Q" -or $UserName -eq "q")
{
return;
}
#Check Required Vars
if($UserName -eq "" -or $UserName -eq $null )
{
Write-Host -ForegroundColor "Red" "`n User Id is required. `n"
}
}
#------------------------------------------------------------------------------------
# Chcek and delete user if exists in Group
$Thesite = new-object Microsoft.SharePoint.SPSite($WebApplicationUrl)
$oApp = $Thesite.WebApplication
foreach ($Sites in $oApp.Sites)
{
$mySubweb = $Sites.Rootweb
Write-Host "Site URL = " $mySubweb.Url
#Write-Host "mySubweb.Title = " $mySubweb.Title

foreach ($SiteGroups in $mySubweb.SiteGroups)
{
#Write-Host "Site Group is :" + $SiteGroups.Name
if($SiteGroups.Name.ToUpper() -eq $SiteGroupName.ToUpper())
{
$oSiteGroup = $mySubweb.SiteGroups[$SiteGroupName];

#Write-Host "Site Group is :" $oSiteGroup.Name
$oUsers = $oSiteGroup.Users

foreach ($oUser in $oUsers)
{
#Write-Host "oUser.LoginName = " $oUser.LoginName
if($oUser.LoginName.ToUpper() -eq $UserName.ToUpper())
{
Write-Host "----------------------------------------------------------------------------------------"
Write-Host -ForegroundColor "black" -BackgroundColor "white" "User Found"
Write-Host "Site URL = " $mySubweb.Url
Write-Host "Site Group is :" $oSiteGroup.Name
Write-Host "oUser.Name = " $oUser.Name
$oSiteGroup.RemoveUser($oUser)
Write-Host -ForegroundColor "black" -BackgroundColor "white" "User " $oUser " deleted successfully from Group " $oSiteGroup.Name " in Site " $mySubweb.Url
Write-Host "----------------------------------------------------------------------------------------"
}
}
}
}
}
}

Thanks for visiting.

Monday, April 27, 2009

SharePoint Custom Actions

SharePoint Custom Actions:

So far, I came across requirement of customizing out of box sharepoint pages (like create.aspx, spcf.aspx, qstnew.aspx) to fullfill client need to add functionality or custom code in those pages. As you know, although we can modify these pages but must not because any patch installation or anything else will owerwrite them back to default and we will loose our code. So we have to make copy of those pages and add custom link on page from where its getting called.

Example : If you require to override the WebPart Page/Survey Creation Page spcf.aspx/new.aspx) then you have to add link under particular Group in Create.aspx page. This you can achieve without writing any code in create.aspx by creating Feature using CustomActions.

SharePoint provides so many default CustomActions which we can use as per our creativity.

Code example : To add custom link in Site Actions Ment which takes user to custCreate.aspx page





http://msdn.microsoft.com/en-us/library/bb802730.aspx : Various default custom actions.
http://msdn.microsoft.com/en-us/library/ms473643.aspx : How to do it.