Monday, May 24, 2010

EXCEPTION FROM HRESULT: 0X81070000

This link is moved here.

Speaking at Baltimore SharePoint Group on Jun 17 2010

Title: Speaking at Baltimore SharePoint Group on Jun 17 2010

Topic: Client Object Model in SharePoint 2010

Details: Baltimore SharePoint Users Group - Web Site here

Location:1450 South rolling road Baltimore, MD 21227; How to reach here?

Thursday, April 15, 2010

Speaking at SharePoint Saturday DC on May 15th 2010



Title: Speaking at SharePoint Saturday DC on May 15th 2010

Topic: SharePoint 2010 Sandboxed Solutions


Location: NVCC Community Cultural Center Annandale, VA

Saturday, April 3, 2010

How to use Rating Control in SharePoint 2010

Title: How to use Rating Control in SharePoint 2010

Details: Some thing and finally some thing every one really wanted. Either you download code from codeplex or use any 3rd party controls - its takes about week or more for you to create a Rating Control that is customized to your needs. Now, we have this out of the box in SharePoint 2010 and here is how you use it.

How-To: Lets begin with setting up Rating Control for a Custom List first.
Step # 1 Enable / Start the 'User Profile Service' from the CA > System Settings > Servers > Manage services on server ( by default it is Started ).
Step # 2 Under CA > Monitoring > Timer Jobs > Review Job Definitions > look for 'User Profile Service Application - Social Data Maintenance Job' and

'User Profile Service Application - Social Rating Synchronization Job'.
These jobs are scheduled by default to run every 1 hr. 


Step # 3 For our convenience and testing, schedule both these jobs to run every 1 min as shown below.
Also do the same for
'User Profile Service Application - Social Rating Synchronization Job'


Step # 4 Ok you are now all set. Go to the List level ( your desired List / Doc Lib ) and get to the List Settings
Step # 5 Select the Rating Settings on the General Settings option and choose the option 'Yes' for 'Allow items in this list to be rated?'
Step # 6 Once you choose this option, 2 new columns will be added to your list as shown below
Rating (0-5) will give you the 5 star rating asynchronous control that you can rate any item for.
Number of Ratings will display how many unique users rated the item.

Remmember that if same user rates twice, it will override his / her previous rating
( and will not aggregate ).

Rating control will average ratings of unique users rating on item basis.
Step # 7 User ratings are collected asynchronously as shown below.
Step # 8 Once you submit rating, you will be also shown the success message.
Step # 9 Wait for a minute since the timer jobs is set to run for every 1 min as configured earlier. View the list webpart and notice that the ratings will be changed.
Step # 10 Perfect! Lets now see how to use this Rating Control on a Page. First we need the Page level register tag.
<%@ Register Tagprefix="SharePointPortalControls" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

Step  # 11 Once you register the Control Tag, use the below control code and add it to the PlaceHolderMain section.
Make sure that the FieldRef Name matches the column name. You are all set now.

<SharePointPortalControls:AverageRatingFieldControl id="PageRatingControl" FieldName="Rating (0-5)" runat="server" />

Friday, April 2, 2010

Using Custom Actions in SharePoint 2010

Title: Using Custom Actions in SharePoint 2010

Details: Using Custom Actions in SharePoint 2010 is not different as you create them in either WSS3.0 / MOSS 2007. In this post I will run through the sample of creating your own Custom Group and then a Custom Action link under it. Now before we proceed, I created a very nice pic of mine and sized it to 48x48 and copied it to the 14 hive / Template / Images folder ( named as SiteSettings_SriniSistla_48x48.jpg in this case ). Alright, now lets proceed for few steps.
Step # 1 Create a folder ( MyCustomActions in my example ) with a proper name of your choice
Step # 2 Add a new file to the folder and name it as Feature.xml
Step # 3 Add the content as shown in below code and customize it to your needs. Well, notice that this feature is Scoped to Site and you can create a feature for any scope based on where you want to have the Custom Action.
<?xml version="1.0" encoding="utf-8"?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
 ActivateOnDefault="FALSE" 
 AlwaysForceInstall="FALSE" 
 AutoActivateInCentralAdmin="FALSE" 
 Description="Will Create a Section and Link to my Blog" 
 Hidden="FALSE" Id="90C924A7-32F7-4C19-BD4C-AF49EF0563A9" 
 Scope="Site" Title="My Custom Actions">
 <ElementManifests>
 <ElementManifest Location="MyCustomActions.xml" />
 </ElementManifests>
</Feature>
Step # 4 Create another file in the same folder ( myCustomActions.xml in my example ) and name it as Elements.xml or of your own choice
Step # 5 Add the content as shown in below code and customize it to your needs.
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomActionGroup Description="Srini Sistla Exclusive Custom Group" Id="SriniSistla" Url="/_layouts/images/SiteSettings_SriniSistla_48x48.jpg" 
Location="Microsoft.SharePoint.SiteSettings" Sequence="111" Title="Srini Sistla Blog Details">
  </CustomActionGroup>
  <CustomAction GroupId="SriniSistla" Id="UserInterfaceCustomActions.SiteSettings"  Location="Microsoft.SharePoint.SiteSettings" Sequence="106" Title="Blog  Link">
     <UrlAction Url="http://codename-srini.blogspot.com" />
  </CustomAction>
</Elements>
Step # 6 Now, notice that I have a CustomActionGroup created first ( with Id = SriniSistla ) that I will use it in my CustomAction Section. You can create of your own choice in this case.
Step # 7 Once you have everything in place, copy this folder to 14 hive > Template > Features.
Step # 8 I am happy for now in still using STSADM commands and I will go ahead and use the Install Feature Command here.
stsadm -o installfeature -filename MyCustomFeature\Feature.xml
Step # 9 You can as well activate the feature using Stsadm itself, however you can as well go and activate your feature from the Site collection features link under Site Actions > Site Settings > Site Collection Administration as shown below.








Step # 10 Once you activate the feature, you will find the Custom Actions group and the Custom Actions Link on your site actions > site settings page as shown below.
















So far so good. Notice the GroupId="SriniSistla" in my example. If you want to add to an already existing out of the box groups use below GroupId's.

First, to Add your Custom Actions under Site Actions > Site Settings Page set the Location="Microsoft.SharePoint.SiteSettings" and
GroupID="Customization" to add under 'Look and Feel Section'
GroupID="Galleries" to add under Galleries'
GroupID="SiteAdministration" to add under 'Site Administration'
GroupID="SiteCollectionAdmin" to add under 'Site Collection Administration'
GroupID="UsersAndPermissions" to add under 'Users and Permissions'

for entire Custom Actions list, refer to the msdn site here.
have fun.

Monday, March 29, 2010

InLine List Item Editing in SharePoint 2010

Title: InLine List Item Editing in SharePoint 2010

Details: I have worked on many third party tools including telerik / devexpress and I always wanted the inline editing functionality on atleast the out of the box list items. And finally my wish fulfilled

List items ( on modify view settings ) can now be edited inline as show below.
Before getting to it, you need to first enable the inline editing option as show below on the modify view settings page.

Create a Tool to Get the Full Name of an Assembly

Title: Create a Tool to Get the Full Name of an Assembly

Details: Here is a wonderful way to create a tool to get the full name of an assembly provided by Microsoft ( original link ). Create a command line project and name it as GetAssemblyName using the below code. Below are few screenshots how it looks like ( output ) after you create it.

#1 Adding the tool to the External Tools on your Visual Studio 2010
tools
#2 Linking the Tool
link
#3 Using the tool and output
output

Code:

using System;
using System.Reflection;
using System.IO;

namespace GetAssemblyName
{
class Program
{
static void PrintUsage()
{
Console.WriteLine("Usage: GetAssemblyName.exe \n");
Console.WriteLine(@"Example: GetAssemblyName.exe C:\MyAssembly.dll");
Console.Read();
}

static void Main(string[] args)
{
if (args.Length < 1 || args[0] == "?")
{
PrintUsage();
return;
}

string filename = args[0];

try
{
AssemblyName an = AssemblyName.GetAssemblyName(filename);
Console.WriteLine("Fully specified assembly name:\n");
Console.WriteLine(an.ToString());
}
catch (FileNotFoundException)
{
Console.WriteLine("Cannot locate the assembly. Check the path and try again.");
}

Console.Read();
}
}
}



To add a Get Assembly Full Name item to the Tools menu





  • In Visual Studio, select External Tools from the Tools menu.


  • In the External Tools dialog, click Add and enter Get Assembly Full Name for the Title.


  • Fill the Command textbox by browsing to GetAssemblyName.exe.


  • In the Arguments textbox, type the following (which is case sensitive): $(TargetPath)


  • Enable the Use Output window checkbox. Click OK.


  • The new command is added to the Tools menu.



Technorati Tags: ,

Sunday, March 7, 2010

LINQ to SharePoint

Title: LINQ to SharePoint

Details: Its not new to us that LINQ to SharePoint is newly introduced in SharePoint 2010 with a new Provider 'Microsoft.SharePoint.Linq'. It translates LINQ Queries into CAML queries. Which means... bye bye CAML ( you can still use it if you love it ). Few pointers on LINQ to SharePoint...
  • No CAML required
  • Can be called against both server and client object model
  • Tools available ( SPMetal ) to create business layer ( entity classes ) - How to use SPMetal?
  • Intellisense helps query construction
  • Query across multiple lists with relationships
  • Allow inefficient queries
  • Merge results from multiple lists and multiple data sources
  • Join results from multiple data sources
Code: Sample code on how to use LINQ to SharePoint is as shown below. ( Code run against my custom list called FirstNames which has column name FirstName ). You need to create the entity class ( EntitiesDataContext in the below example ) first using SPMetal that would give a data context for our use.

DataContext data = new DataContext(SPContext.GetContext(this.Context).Web.Url);

using (EntitiesDataContext moEntitiesDataContext = new EntitiesDataContext(SPContext.GetContext(this.Context).Web.Url))
{
    var fn = from fNames in moEntitiesDataContext.FirstNames
            select new { fNames.FirstName };                    
}

Saturday, March 6, 2010

Solution Dependencies in SharePoint 2010

Title: Solution Dependencies in SharePoint 2010

Details: We have seen 'Feature Dependencies' until MOSS 2007. Similarly have you ever felt the need of 'Solution Dependencies'? I am sure you might have felt and then here is how your need is fulfilled in SharePoint 2010. Now we can have solution dependencies and it comes with few rules that we need to understand that are mentioned as below.
  1. Checks if dependant solution is available
  2. Does not deploy dependant solutions
  3. Checks for dependancy during the time of deployment
  4. Solution dependancy works for both kinds of solutions ( Farm / Sandboxed )
  5. Solution dependancy does not work on the combination of Farm / Sandboxed Solutions
  6. In situation when dependancy solution is not activated/deployed then activating/deploying dependant solution will fail.
  7. Opposite the above point # 6 will succeed.
  8. In case of dependancy solution is deactivated/retracted, dependant solution will still be activated/deployed.
Below is sample code on how to use it ( under package.template.xml file )...

Code:
<?xml version="1.0" encoding="utf-8"?>
<Solution xmlns="http://schemas.microsoft.com/sharepoint/"
          SolutionId="CURRENT_SOLUTION_GUID"
         <  
  <ActivationDependencies>
    <ActivationDependency SolutionId="DEPENDANT_SOLUTION_GUID"/>
  </ActivationDependencies>
</Solution>

SharePoint 2010 and Office 2010 Lauch dates announced as May 12th 2010

Title: SharePoint 2010 and Office 2010 Lauch dates announced

Details: Mark your calendars as Microsoft announced the launch dates for SharePoint 2010 and Office 2010 as May 12th 2010; official link with details on the SharePoint msdn blog site here.

http://blogs.msdn.com/sharepoint/archive/2010/03/05/sharepoint-2010-office-2010-launch.aspx



Tuesday, March 2, 2010

Error: System.IO.FileNotFoundException was unhandled by user code

Title: Error(s) while running SharePoint 2010 projects using Visual Studio 2010

Details: Have you encountered the below errors while you are running SharePoint 2010 projects using Visual Studio 2010?

System.IO.FileNotFoundException was unhandled by user code
Message="The Web application at http://sp2010/ could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application."

or

Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed.

Resolution: Verify what framework you are running against. By default Visual Studion 2010 runs with .NET Framework 4.0 and SharePoint 2010 is built against to run on .NET Framework 3.5.
Change you project settings to run against 3.5 and you should be good

Speaking at CapArea SharePoint Group on May 11 2010

Title: Speaking at CapArea SharePoint Group on May 11 2010

Topic: SharePoint 2010 Sandboxed Solutions

Details: CapArea SharePoint Site

Location: AT&T Building, 1900 Gallows Road, Vienna, VA 22182; How to reach here?

Monday, March 1, 2010

Speaking at SharePoint Users Group of DC on Mar 04 2010

Title: Speaking at SharePoint Users Group of DC on Mar 04 2010

Topic: SharePoint 2010 Sandboxed Solutions

Details: Register here

Location: How to reach here?

Speaking at Global SharePoint User Group on Mar 02 2010 ( Online )

Title: Speaking at Global SharePoint User Group on Mar 02 2010 ( Online )

Topic: SharePoint 2010 Sandboxed Solutions

Register: Register here

Link: Other details here

SharePoint 2010 Versioned Controls

Title: SharePoint 2010 Versioned Controls

Details: These are the new control tags introduced in SharePoint 2010 that allow us to render code based on specific version ( V3 or V4 ) for the aspx, ascx and master pages. You can use the below tags and code to achieve it. Use the UIVersion attribute to set the version ( 3 for WSS 3.0 and MOSS; 4 for SPF and SPS 2010 )

Code: During Render ( slower )
<SharePoint:VersionedPlaceHolder runat="server" UIVersion="4">
  <div>Your content</div>
</SharePoint:VersionedPlaceHolder>

Code: During Load Time ( faster )
<SharePoint:VersionedContent runat="server" UIVersion="4">
  <ContentTemplate>
    <div>Your content</div>
  </ContentTemplate>
</SharePoint:VersionedContent >

Migrating from MOSS 2007 to SharePoint 2010

This link is moved here.

Migrating from MOSS 2007 to SharePoint 2010 - Part II

This link is moved here.

Migrating from MOSS 2007 to SharePoint 2010 - Part III

This link is moved here.

Migrating from MOSS 2007 to SharePoint 2010 - Part I

This link is moved here.

Tuesday, February 16, 2010

Speaking at SharePoint Saturday Boston on Feb 27th 2010

Title: Speaking at SharePoint Saturday Boston on Feb 27th 2010

Topic: SharePoint 2010 Sandboxed Solutions

Register: Register here

Link: Other details here

Wednesday, February 10, 2010

Delete user from Site Collection

Title: How to delete a user from a site collection

Details: Some one asked me to post a sample of code to acheive the above subject. So, here is the code. However let me explain few things so that you can proceed and alter few things.

#1 you can run though the SPUserCollection that you can get from web.SiteUsers collection and find more than 1 person. In general case if it is only 1 user, then use the below code.

#2 do trip between web.Users Vs web.SiteUsers. SiteUsers is the SiteCollection users and web.user is the user object.

Code:

static void RemoveUserFromSiteCollectionByUserName(string siteUrl, string userName)
{
    using (SPSite siteCollection = new SPSite(siteUrl))
    {
        using (SPWeb web = siteCollection.OpenWeb())
        {
            SPUser user = web.SiteUsers[userName];

            try
            {
                if (!user.IsDomainGroup && !user.IsSiteAdmin)
                {
                    web.SiteUsers.Remove(user.LoginName);
                    web.Update();
                }
            }
            catch (Exception ex)
            { 
                // user not found
            }
        }
    }
}

Tuesday, February 9, 2010

Visual Studio 2010 RC Released

Title: Visual Studio 2010 RC and .NET 4.0 RC Released

Details: here is the link.

Saturday, February 6, 2010

A Great Tip for Great SharePoint 2010 Presentations using SPWakeUp

Title: A Great Tip for Great SharePoint 2010 Presentations using SPWakeUp

Details: A very nice article provided by Paul Swider.

Friday, February 5, 2010

Large List Throttling in SharePoint 2010

Title: List Throttling in SharePoint 2010

Details: One of the new features / enhancements in SharePoint 2010 is the support for large lists ( upto 50million ) and also supports to set limits on top of these large lists. Consider the list has 'X' number of rows ( think of a big number ) and say user is querying 'Y' records of it and 'Y' is very near to 'X'. In that case, you can restrict the rows returned in order to prevent large queries. Though you can set it using the UI as show below, you can override it using the code also.
Code: To enable or disable throttling, use the property as show below.

list.EnableThrottling = false;

To access from UI, go to CA > Application Management > Manage Web Applications > "Select Web Application" > General Settings > Resource Throttling.



One important factor to consider here is while migrating from MOSS 2007 to SPS 2010, beware that throttling settings might effect your existing functionality since such new feature doesnt exist in MOSS.

Thursday, February 4, 2010

How to Turn-On SharePoint 2010 Developer Dashboard

Title: How to turn-on Developer Dashboard in SharePoint 2010

Details: Developer dashboard is a new feature in SharePoint 2010 that provides information on the performance and tracing that can be used to monitor the page during render. By default its turned off. You can turn it on using either stsadm / powershell / code. You can use the below code to trigger the developer dashboard.

Code:

SPFarm farm = SPFarm.Local;
SPWebService context = farm.Servers.GetValue();
context.DeveloperDashboardSettings.DisplayLevel = SPDeveloperDashboardLevel.OnDemand;
context.DeveloperDashboardSettings.Update(); 






As marked in the pic above, Developer Dashboard can be toggled to On/Off based on the SPDeveloperDashboardLevel. There are 3 states of the Levels, On/Off/OnDemand. A Turned-On dashboard would like as shown below.



Alternatively, you can turn it on using stsadm commands as shown below:
Set to 'On Demand' - displays an icon on top right hand corner for toggle

stsadm -o setproperty -pn developer-dashboard -pv ondemand

Set to 'On' - Always displayed
stsadm -o setproperty -pn developer-dashboard -pv on

Set to 'Off' - Turned off
stsadm -o setproperty -pn developer-dashboard -pv off

Monday, January 25, 2010

Why use SharePoint 2010 Sandboxed Solutions?

Title: Why use SharePoint 2010 Sandboxed Solutions?

Details: Below are few thoughts on why to use Sandboxed Solutions
  • Isolation
    • Deployed to the database ( no files within the SBS will touch file system ).
    • Runs under special process, SPUCWorkerProcess.exe
    • Assign Resource Points
    • Doesn’t effect other Site Collections
  • No waiting for farm admins to deploy your solutions
  • Farm admins don’t need to worry about bad solutions any more
  • Runs on partial trust
  • Can be monitored
  • Can be validated

Tuesday, January 19, 2010

Query multiple lists across sites in a web site collection

Title: Query multiple lists across sites in a web site collection

Details: SPSiteDataQuery Class - This is one of the very intresting and wonderful classes available in SharePoint to retreive information from list across sites in the same web site collections. How many of you have tried the roll up ( not including the CQWP ) by coding? Look at the below code and see the simplicity of it. Simply build the SPSiteDataQuery ( query ) to the GetSiteData Method and get DataTable in return. One important thing to notice is that, it is not supported in SharePoint 2010 Sandboxed Solutions.

Code:

void UsingSPSiteDataQuery(SPWeb web)
{
   SPSiteDataQuery query = new SPSiteDataQuery();
            
   query.Lists = "";
   query.ViewFields = "";
   query.Webs = "";

   web.GetSiteData(query);
}

Monday, January 18, 2010

SharePoint 2010 Sandboxed Solutions Solution Validator ( SPSolutionValidator )

Title: Sandboxed Solutions Solution Validator ( SPSolutionValidator )

Details: Now that you already know how to create a Sandboxed Solution, in a typical scenario Farm Admins need some one or some mechanism to evaluate or validate the solutions developed using Sandboxed solutions by the developers. Here is the example of how and what you need to inherit and extend the ootb available classes to write your own.

Code: First, here are the namespaces required

using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Administration;

using System.Runtime.InteropServices;
using System.Collections.ObjectModel;

using Microsoft.SharePoint.UserCode; // Under > C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\UserCode\assemblies\

You then need a class that inherits from SPSolutionValidator and overrides couple of its methods as show below. Remmember that this code is going to fire for every other solution thats is added to the solution gallery on a Site Collection.
namespace AltsisSolutionValidator
{
    [Guid("481823F5-75A7-4EF8-8A4B-11C4D52D1014")]
    public class SolutionValidator : SPSolutionValidator
    {
        private const string strValidatorName = "Altsis Validator Name";
        
        public SolutionValidator()
        { 
        
        }

        public SolutionValidator(SPUserCodeService userCodeService)  : base(strValidatorName, userCodeService)
        {
            this.Signature = 1977;
        }

        public override void ValidateAssembly(SPSolutionValidationProperties properties, SPSolutionFile assembly)
        {
            base.ValidateAssembly(properties, assembly);
            properties.Valid = true;
        }

        public override void ValidateSolution(SPSolutionValidationProperties properties)
        {
            base.ValidateSolution(properties);
            ReadOnlyCollection files = properties.Files;

            // Write your validations etc here- extend it as much as you can         
            
            properties.ValidationErrorMessage = " Solution Suceess / Failed ";
         }
    }
}

Alright, now you need a feature to deploy this to Farm Level.
namespace AltsisSolutionValidator.Features.AltsisSolutionValidatorFeature
{
    /// 
    /// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade.
    /// 
    /// 
    /// The GUID attached to this class may be used during packaging and should not be modified.
    /// 

    [Guid("2a4d3a6b-ab9c-4008-9408-26dd4cd1f6d8")]
    public class AltsisSolutionValidatorFeatureEventReceiver : SPFeatureReceiver
    {
        // Uncomment the method below to handle the event raised after a feature has been activated.

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPUserCodeService.Local.SolutionValidators.Add(new SolutionValidator(SPUserCodeService.Local));
        }


        // Uncomment the method below to handle the event raised before a feature is deactivated.

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPUserCodeService.Local.SolutionValidators.Remove(new Guid("481823F5-75A7-4EF8-8A4B-11C4D52D1014"));
        }


        // Uncomment the method below to handle the event raised after a feature has been installed.

        public override void FeatureInstalled(SPFeatureReceiverProperties properties)
        {
        }


        // Uncomment the method below to handle the event raised before a feature is uninstalled.

        public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
        {
        }

        // Uncomment the method below to handle the event raised when a feature is upgrading.

        public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary parameters)
        {
        }
    }
}

Here is my codeplex project template that you can download
http://spsolutionvalidator.codeplex.com/

Thats it. Fire away and see the results for yourselves.

Sunday, January 17, 2010

Error occurred in deployment step 'Retract Solution': Cannot start service SPUserCodeV4 on computer

Title: SharePoint 2010 Error occurred in deployment step 'Retract Solution': Cannot start service SPUserCodeV4 on computer

Details: Building Sandboxed Solutions on SharePoint 2010 using Visual Studio 2010 Beta and encountered the error? Then make sure that the service Microsoft SharePoint Foundation User Code Service ( CA > System Settings > Services on Server ) is Started.


Friday, January 15, 2010

System Center Operations Manager Management Released

Title: System Center Operations Manager Management Packs for SharePoint Server 2010 Beta and SharePoint Foundation 2010 beta

Details: ( from MSDN SharePoint blog post as is ) Management Packs allow users to monitor SharePoint 2010 with System Center Operations Manager. SharePoint Foundation Management Pack and SharePoint Server 2010 Management Pack enables monitoring of SharePoint Foundation 2010, SharePoint Server 2010, Search Server 2010 (These is separate management pack for FAST search), Project Server 2010 and Office Web Apps. Once management pack is imported to System Center console, based on console configuration it automatically discovers what SharePoint bits or servers are installed in the environment that is being monitored and start monitoring those components.

These 2010 management packs will be released to System Center Operations manager catalog and will also be released to web along with SharePoint 2010 RTM.

more details at http://tinyurl.com/y88dmp9

Books for Microsoft System Center Operations and Configuration Manager 2007 R2

Wednesday, January 6, 2010

Speaking at SharePoint Saturday NYC on Jan 30th 2010

Title: Speaking at SharePoint Saturday NYC on Jan 30th 2010

Topic: SharePoint 2010 Sandboxed Solutions

Register: Register here

Link: Other details here

Tuesday, January 5, 2010

ASP.NET to SharePoint Migration

Title: ASP.NET to SharePoint Migration

Details: Added a start up template project to codeplex.

Link: http://aspnet2sp.codeplex.com/

Microsoft Resource File To COFF Object Conversion Utility has stopped working

Title: Error: Visual C# Command Line Compiler has stopped working or Microsoft Resource File To COFF Object Conversion Utility has stopped working

Details: Have you experienced either one of the above errors when you are installing MOSS 2007 on Windows Vista or Windows 7 ??

Solution: Here is the solution for the above error.

Visual C# Command Line Compiler has stopped working

Title: Error: Visual C# Command Line Compiler has stopped working or Microsoft Resource File To COFF Object Conversion Utility has stopped working

Details: Have you experienced either one of the above errors when you are installing MOSS 2007 on Windows Vista or Windows 7 ??

Solution: Here is the solution for the above error.

Monday, December 28, 2009

STSADM AddSolution failed to extract the cab file in the solution

Title: Error: Stsadm AddSolution failed to extract the cab file in the solution

Details: When tried to addsolution using stsadm command, some times the above error is experienced. Now, what to look for?

Steps:
Step#1: Extract your .wsp file
Step#2: Check the contents and make sure there are no duplicates ( files or resources )
Step#3: See if you have any files with special characters including brackets ' copy (2) filename ' so on and so forth.
Step#4: Clean up unwanted files and rebuild your .wsp.
Step#5: Addsolution this time and verify.

You should be good now.

The query results cannot be enumerated more than once

Title: Error: The query results cannot be enumerated more than once

Details: Ever tried using Linq DataContext model ( using the dbml file ) and try iterating from the return type ISingleResult ? If so, you might have got the error for sure. So, the simple way to do it is to obtain the results to a generic list as shown below.

Code: Consider that GetUserDetails returns a ISingleResult generic list type of GetUserDetailsResult

List<GetUserDetailsResult> results = GetUserDetails().ToList();
foreach (GetUserDetailsResult result in results)
{
// Write your code here...
}

Friday, December 25, 2009

SharePoint 2010 Sandboxed Solutions

Title: SharePoint 2010 Sandboxed Solutions

Introduction: How many times ( as a developer ) have you felt you wanted to have control on testing, staging or productions servers to deploy your solution? and how many times you might have bothered your engineering team for deployment? Similarly, how many times the engineering team might have cursed you for going to them many times to redeploy your solutions? Sounds familiar situation? Well with the introduction of Sandboxed Solutions, its a great relief to both the teams. Lets see in short in the post and I will write separately on each topic in other posts.

Sandboxed Solutions: With elevated previlages ( site collection administrators ), now you can deploy your solutions (.wsp) at the site collection level and fully control them. So, all you need is to request your engineering groups to add you to the Site collection administrators group on the target site collection. With SB Solutions, one can guarentee trust (partial) as well as protection to the farm. Since the SBS's work on a site collection, if any thing goes wrong only that site collection is compromised and would isolate the other Site collections, Web Application as well as Farm. SBS works on a different thread (SPUCWorkerProcess) and doesnt run on the same app pool. This isolation guarentees further more safety.

Build - Deploy: With VS 2010 one can opt for creating a SB Solution Project (default). However when the same solution is deployed at Farm Level, it runs with full trust where as at the site collection level it runs under partial trust. The output of the VS project would be a .wsp which you can upload to the Solutions store under the site collection. You can as well directly use the deploy option of VS however it may not be a suitable for staging and production deployments. You would simple Activate it ( equivalent to deploying the .wsp ) to run your underneath resources. When you donot need it, simply De-Activate the same.

Limitations: You cannot acheive everything using SBS's. As mentioned earlier since its partially trusted donot assume you can attempt to write everything using SBS. Here is list of ( some of ) what you can create

  • Web Parts ( not visual webparts )

  • Site Pages ( not application pages with code behind )

  • List Definitions

  • Event and Feature receivers

  • Infopath form services

  • Custom Actions

  • Content Type and Site Columns

  • JS, AJAX, SilverLight, jQuery ...



Monitoring and Validating: Farm Admins can monitor using the site quota's under CA and specify locks. Alternatively, using SPSolutionValidator Farm admins can monitor and validate the solutions that allow only code signed with a particular certificate to run.

Monday, December 21, 2009

Installing SharePoint 2010 Beta

Title: Installing SharePoint 2010 Beta

Preface: I failed trying to install SharePoint 2010 Beta more than 8 times and finally I was able to do it today. Here is what I did so far and finally what worked out. Installing it on a Windows 7 or Vista OS targetting developer user is no brainer. Simply follow this link and I was able to do it first time. However, my motto is to install it on a Virtual Machine ( VMWare ). So, I started with VMWare 7.0 with 4 core, 4GB RAM, 60GB HDD etc to begin with. I tried to install on both Windows Server 2008 Ent x64 and Windows Server 2008 R2 x64 versions. And when ever I tried to install with pre requisite setup etc, never been successful. Below are few errors I faced ( not all included ).

Errors:
#1 Application Server Role: Web Server (IIS) Role: configuration error
#2 pending restart of the computer.

References: Though I was unsuccesful installing it, these are great resources to follow and give ultimate information.
Sahil Malik's Blog
Jie Li's Blog
Code Project
Patrick's Blog

Finally: I went back to basics... ( my VM settings are same as mentioned above, no changes )
Step #1 Installed Windows 2008 Server 'Standard' Edition and ran the windows updates ( including SP2 ).
Step #2 Installed KB971831
Step #3 Ran the pre-req tool ( ran successful )
Step #4 Installed SPS 2010 > Chose Server Farm and chose StandAlone ( this would install SQL express 2008 )
Step #5 Installed Office Professional 2010
Step #6 Installed SharePoint Designer 2010
Step #7 Installed Visual Studio 2010 Beta
Step #8 Installed SQL Server Management Studio 2008
Step #9 Ran the Windows Update once again
Step #10 Take a snapshot

Voila!!!!

Thursday, December 17, 2009

Reading App.Config Key Values from Feature Folder

Title: Reading App.Config Key Values from Feature Folders
Details: We had a scenario where we need to have App.config under the Feature Folder. Keeping aside the need, the requirement was to read these values from a class thats inheriting SPItemEventReceiver which means I cannot use the Feature.xml properties. One way to accomplish this is as shown below. This is just a raw code, and you can tweak the code for best practices etc.
Code:

private string GetAppSettingValue(string key)
{
string ret = string.Empty;
string appconfigFilePath = Path.Combine(SPUtility.GetGenericSetupPath("TEMPLATE"), @"FEATURES\FEATURENAME\App.config");

ConfigXmlDocument document = new ConfigXmlDocument();
document.Load(appconfigFilePath);
XmlNodeList xmlNodeList = document.GetElementsByTagName("add");

for(int i=0; i < xmlNodeList.Count; i++)
{
if(xmlNodeList[i].Attributes["key"].Value.ToLowerInvariant() == key.ToLowerInvariant())
{
ret = xmlNodeList[i].Attributes["value"].Value;
}
}

return ret;
}

BreakRoleInheritance Method

Title: SPList.BreakRoleInheritance Method
Details: BreakRoleInheritance would break the inheritance ( can be used on a list / document library ) to alter permissions on the parent or itemlevel.
Usage:

public void BreakRoleInheritance (
bool CopyRoleAssignments
)

Accepts either true / false as parameter that would decide whether or not to copy the existing groups / users and permissions.

One interesting concept to note. Instead of using the below code that would remove all the groups and permissions from an item or list level after breaking the inheritance.


listItem.RoleAssignments.RemoveAll();


we can simple use as below


listItem.BreakRoleInheritance(false);

Removing Group / User Permissions on list item

Title: Removing Group / User Permissions on the List Item
Details: Some point of time you will encounter a scenario that you would want to remove permission of a group or user for a specific list item. So, here is what can be done.

Step # 1: Create a Feature and on Activation, Add Event Receivers to the List / Document Library

web.Lists[docLibraryName].EventReceivers.Add(SPEventReceiverType.ItemAdded, AssemblyName, ClassName);


Step # 2: On the Item Event Receiver, you can check for some validations ( or rules )etc and break the inheritance and remove the group.

private static void RemoveGroupPermissionsToTheItem(string groupName, SPWeb web, SPListItem listItem)
{
if (!listItem.HasUniqueRoleAssignments)
{
listItem.BreakRoleInheritance(true);

SPGroup group = web.SiteGroups[groupName];
listItem.RoleAssignments.RemoveById(group.ID);
}
}


Step # 3: On Feature Deactivation, make sure you delete the event handler on the list / documentlibrary


private void DeleteItemAddedEventReceiver(SPDocumentLibrary documentLibrary)
{
SPEventReceiverDefinitionCollection eventReceiverDefinitionCollection = documentLibrary.EventReceivers;

foreach (SPEventReceiverDefinition eventReceiverDefinition in eventReceiverDefinitionCollection)
{
if (eventReceiverDefinition.Assembly == AssemblyName && eventReceiverDefinition.Type == SPEventReceiverType.ItemAdded)
{
eventReceiverDefinition.Delete();
break;
}
}
}

Thursday, November 26, 2009

Installing SharePoint Server 2010 on Windows 7

Title: Installing SharePoint Server 2010 on Windows 7 / Setting Up the Development Environment for SharePoint

Details: Here is a very nice article that would help you set up your development environment on Windows 7.

http://msdn.microsoft.com/en-us/library/ee554869(office.14).aspx

Thursday, November 19, 2009

Speaking at SharePoint Saturday DC

Here is the code and presentation.

Title: Speaking at SharePoint Saturday DC

Date: Dec 5th 2009

Location: Microsoft Technology Center, 12012 Sunset Hills Rd. Reston, VA 20190

Topic: 'Migrating ASP.NET Web Applications to SharePoint Platform' - an ongoing business need

Details: With SharePoint and its advantages - many projects in organizations are ready to migrate from ASP.NET to SharePoint platform. This has become one of the strongest business case and there are instances when developers have questions on ‘How-To’? This session would give an outline of methods, procedures, best practices on real time experience approach.

Speaking at SharePoint Saturday Richmond

Here is the code and presentation

Title: Speaking at SharePoint Saturday Richmond

Date: Nov 21st 2009

Location: Massey Technology Center on the J. Sargeant Reynolds Parham Campus, Richmond, VA

Topic: Understanding and Programming Features in SharePoint

Details: This session provides an introduction to SharePoint Features. During the session, I will describe what features are, how powerful they are, and provide some practical approaches to using them. The session also covers concepts of Feature Stapling. The target audience for session includes Beginner and Mid level developers.

Thursday, November 5, 2009

Error while deploying using VSEWSS 1.3

Title: Error while deploying using VSEWSS 1.3

Scenario: On my Windows Vista x64 and IIS 7.0, I installed VseWss 1.3 version and tried to use simple out of the box site definition template. When I build the project every thing is fine. However, when I try to deploy the project it gives me the below error.

-------------------------------------------------------------------------

Error 1 The content type text/html; charset=utf-8 of the response message
does not match the content type of the binding (text/xml; charset=utf-8). If
using a custom encoder, be sure that the IsContentTypeSupported method is
implemented properly. The first 1024 bytes of the response were: ' html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>IIS 7.0 Detailed Error - 500.0 - Internal Server Error</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana,Arial,Helvetica,sans-serif;background:#CBE1EF;}

code{margin:0;color:#006600;font-size:1.1em;font-weight:bold;}
.config_source code{font-size:.8em;color:#000000;}
pre{margin:0;font-size:1.4em;word-wrap:break-word;}
ul,ol{margin:10px 0 10px 40px;}
ul.first,ol.first{margin-top:5px;}
fieldset{padding:0 15px 10px 15px;}
.summary-container fieldset{padding-bottom:5px;margin-top:4px;}
legend.no-expand-all{padding:2px 15px 4px 10px;margin:0 0 0 -12px;}
legend{color:#333333;padding:4px 15px 4px 10px;margin:4px 0 8px
-12px;_margin-top:0px;
border-top:1px solid #EDEDED;border-left:1px solid #EDEDED;border-right:1px
solid #969696;
border-bottom:1px solid
#969696;background:#E7ECF0;font-weight:bold;f'. 0 0


-------------------------------------------------------------------------

Resolution: After a little bit of googling around I found that the error is related to VseWSS 1.3 version, WCF and IIS 7.0.

So, here is what we need to do:
For Windows Vista:
#1. Under Control Panel > Programs > Programs and Features > Click Turn Windows Features On or Off.
#2. Under Microsoft .NET Framework 3.0, choose Windows Communication Foundation HTTP Activation.
#3. Install the selected features.

Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))

Title:Error: Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)) or unable to add selected web part(s). Operation aborted.

Scenario: "Every thing was fine until today morning" - that's the kind of surprising face you might have all of a sudden and from no where one of the above errors might appear on the site when ever you try to modify some thing.

Resolution: Any modification is a write operation to the database. Since you might not be able to get more details as you see the above errors, its worth checking some options.

#1. Check the SQL Log File, the Database size and Database Space available.
#2. Check the Log Files. It might be that the log file is full and writes are blocked.
#3. Other most common issue is that there is less space on the drive.

Tuesday, October 20, 2009

Sending Email or SMS using SPAlert ( SPAlertDeliveryChannels )

Title:Sending Email or SMS using SPAlert
Sends notification to a user about the list, list item, document, or document library to which the alert applies via E-mail or SMS.


SPAlert has the property SPAlertDeliveryChannels - an enumaration type that has enum values Email and Sms


Reference : MSDN

SharePoint 2010 Development Tools : SPMetal

Title: SPMetal
SPMetal is a command line tool that generates entity classes that are in turn used in Linq to SharePoint - Microsoft.SharePoint.Linq ( new in SP 2010 ). It is like an interface to connect to the Foundation 2010 Content Databases that enables operations such as add, delete and change items.


SPMetal can be found under the location C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\
Usage:

SPMetal /web:http://ContosoServer/Marketing /code:MarketingSite.cs

Reference : MSDN

Client API Class Library in SharePoint 2010

Title: SharePoint 2010 Client API
It's not been 1 day before SharePoint SDK Documentation is released on MSDN and already its so compelling to using 2010. Here is some thing very intresting and I am waiting to write code on.


SharePoint Foundation 2010 has a all new class library 'The Client API'. Voila!!! what does that mean... now you can write even better managed client object model for Silverlight and .net in SharePoint 2010. Isnt it cool???


So, here are the available namespaces and class library references:

Microsoft.SharePoint.Client - Core namespace that provides types and members for working with SharePoint Foundation Web sites, list data, and security within a site collection.

Microsoft.SharePoint.Client.Application - Provides types and members that are used for authentication.

Microsoft.SharePoint.Client.Utilities - Provides utility types and members for managing users as principals.

Microsoft.SharePoint.Client.WebParts - Provides types and members for managing Web Parts within Web Part pages.

Microsoft.SharePoint.Client.Workflow - Provides types and members for managing workflow templates and workflow associations.

Reference : MSDN

Monday, October 19, 2009

SharePoint 2010 What's Deprecated?

Title: What's Deprecated?
As many as 190 Types and Methods are deprecated in the new version ( beta ).
you can find the details here.

What's New in SharePoint Server 2010?

Title: SharePoint Server 2010
Some of the new features in SharePoint Server 2010 are listed below:

Business Connectivity Services (BCS)
Enterprise Content Management (ECM)
SharePoint Enterprise Search
PerformancePoint Services
Excel Services
User Profiles and Social Data
Word Automation Services Overview

more information here

What's new in SharePoint Foundation 2010?

Title: Foundation 2010
Foundation 2010 ( next version of WSS 3.0 ) has the following new features

Alerts Enhancements
Business Connectivity Services
Client Object Model
Events Improvements
Microsoft Synch Framework
Mobile Device Development Enhancements
Query Enhancements
Ribbon
Sandboxed Solutions
Service Application Framework
Silverlight Integration and the Fluid Application Model
UI Improvements
Windows PowerShell for SharePoint
Workflow Improvements

more details here

SharePoint 2010 Resources

The much awaited SharePoint 2010 resources can now be obtained from here.

http://blogs.msdn.com/sharepoint/archive/2009/10/19/sharepoint-2010-resources.aspx

Tuesday, October 6, 2009

SPWeb.AvailableContentTypes Vs SPWeb.ContentTypes

Title: SPWeb.AvailableContentTypes Vs SPWeb.ContentTypes


Scenario: Try to get the content types from using both the properties. You might notice that there is no difference. Well then why do we have 2 different properties. Here is the code to get the content types ( notice the comments ) ...

static void GetListTypeID()
{
using (SPSite oSite = new SPSite(@"http://localhost/"))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
//SPContentTypeCollection ctypecoll = oWeb.ContentTypes; // USING CONTENT TYPES
SPContentTypeCollection ctypecoll = oWeb.AvailableContentTypes; // USING AVAILABLE CONTENT TYPES
foreach (SPContentType type in ctypecoll)
{
Console.WriteLine("ID: " + type.Id + " ; Name: " + type.Name);
}
}
}
}




Run the above using either of ContentTypes and AvailableContentTypes. You will see that the result is same.

From MSDN the difference is

The ContentTypes property returns only the content types that exist on the current Web site, not all content types in the current scope. Use the AvailableContentTypes property to return all content types in the current scope, including those of any parent Web sites.

Though it helped me to understand I couldnt get the real essence of it. So, the intresting concept is that AvailableContentTypes is READONLY. You cannot add a new ContentType by using AvailableContentTypes collection.

** CORRECTIONS **
My bad... Some mis-interpretation with my wordings above. The above code as is executed at Site Collection level gives the same results. As mentioned above from MSDN AvailableContentTypes gives information including subsite content types. However, my point is to bring out which one should be used to create new content types ( ContentType ) and which one is read-only ( AvailableContentTypes ). Hope you got the point right.

Monday, October 5, 2009

Programmatically Get Content Types

Title: You might want to get all the content types on a given site

Code:

static void GetListTypeID()
{
using (SPSite oSite = new SPSite(@"http://localhost/"))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
SPContentTypeCollection ctypecoll = oWeb.ContentTypes;
foreach (SPContentType type in ctypecoll)
{
Console.WriteLine("ID: " + type.Id + " ; Name: " + type.Name);
}
}
}
}

Friday, September 25, 2009

One or more features must be turned on before this feature cab be activated

Title: One or more features must be turned on before this feature cab be activated

Scenario: Trying to activate 'Office SharePoint Server Publishing' feature on the Site Features of the site.

Solution: Activate the 'Office SharePoint Server Publishing Infrastructure' feature at the site collection level first before trying the scenario.

Create Site Collection in a specific Content Database

Title: Create Site Collection in a specific Content Database

Scenario: My previous post on the same topic are some ways to create site collections in the specific content database. Programmatically we can also do it as mentioned in this blog post done by my friend Sandeep. So I kind of put them all in all and created a simple console application to create site collection in a specific content database.

Download the file and try for yourself.

Usage: use the command as show below.


Wednesday, September 23, 2009

Getting context using RunWithElevatedPrivileges

Title: Getting context using RunWithElevatedPrivileges


Scenario: Have you ever tried creating the SPSite and SPWeb context inside the RunWithElevatedPrivileges context? If you have done so, then you must have noticed that the context user is still the logged in user and is not elevated to the app_pool identity.
To get the right context, use the code as shown below.


Code:

SPSite siteColl = SPContext.Current.Site;
SPWeb webSite = siteColl.OpenWeb();

SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(siteColl.ID))
{
using (SPWeb web = site.OpenWeb(site.ID))
{
// DO SOME THING IMP HERE
}
}
});

How to create Site Collection in a specific Content Database?

Title: How to create Site Collection in a specific Content Database?

Scenario:
We often have this requirement of creating sites collections in a specific content database instead of going into one of the available content databases. So, here are few available ways that can be considered. Every thing has its own disadvantages. So, pick the one which suits you the best.

Solution:
Option # 1 : While creating the new content database from CA you can set the options in Database Capacity Settings to limit the number of sites along with Warning. However it allows always 1 extra space for one more C-DB. So, you need proper planning well before for it. Ofcourse you can always go and increase it. So it might not be good working idea every time.





Option # 2 : As posted in my previous post use STSADM createsiteinnewdb option. Problem with this model is that you cannot create more than 1 site into the same CDB.


Option # 3 : Moving Site Collections between Content Databases


Per say if the site collection is created in an unwanted CDB, then you can move the site collection to the required CDB using the below statements. However, the issue with this model is you may not have the freedom to do it on production servers. So make sure you script it out properly and provide it to the Administrators.


STSADM.EXE -o enumsites -url http://mysiteiwantetomove > sites.xml



Open the sites.xml file and edit the file so that you would have only those site listing that you want to move.

STSADM.EXE -o mergecontentdbs -url http://mysiteiwantetomove -sourcedatabase
[databasename] -destinationdatabase [databasename] -operation 3 -filename sites.xml



Option # 4 : Take CDB's to offline mode


Go to CA > AM > CDB's and edit.
You can take all other CDB's to offline mode except the one you want to create site collections under. That way, your new site collection will be created in the CDB available in ready mode. Once you create the site collection, make sure you bring back the other CDB's to ready mode.

Saturday, September 19, 2009

Get all the sub sites under the current site

Scenario:
You want to get all the sub sites under a given site collection including sub sites under sub sites.
Scenario:
Use site.AllWebs to get the entire collection as shown below.
Code:

void GetAllSitesUnderSiteCollection(string siteUrl)
{
using (SPSite site = new SPSite(siteUrl))
{
foreach (SPWeb web in site.AllWebs)
{
Console.WriteLine(web.Title + " ~ " + web.Url);
}
}
}

Create Site in New Database using stsadm (createsiteinnewdb)

Title: Create Site in new database using createsiteinnewdb
Code:

stsadm -o createsiteinnewdb -url http://yourownurl/ -owneremail owner@emailid.com -sitetemplate sts#1 -title "My Site Title" -databasename Create_Under_This_DB -ownerlogin NTLogin\Admin

Programmatically Delete Site Collection

Title: Programmatically Delete Site Collection
Code:

void DeleteSiteCollection(string requestUrl, string siteUrl)
{
SPSite site = new SPSite(requestUrl);
SPWeb web = null;
try
{
SPWebApplication webapp = site.WebApplication;
web = site.OpenWeb();
SPSiteCollection spSites = webapp.Sites;
webapp.Sites.Delete(siteUrl);
}
finally
{

}
}

Programmatically Create Site Collection

Title:Programmatically Create Site Collection
Code:

void CreateSiteCollection(string requestUrl, string siteUrl, string title, string description, uint lcid, string webTemplate, string ownerLogin, string ownerName, string ownerEmail)
{
SPSite site = new SPSite(requestUrl);
SPWeb web = null;
try
{
SPWebApplication webapp = site.WebApplication;
web = site.OpenWeb();
SPSiteCollection spSites = webapp.Sites;
webapp.Sites.Add(siteUrl, title, description, lcid, webTemplate, ownerLogin, ownerName, ownerEmail);
}
finally
{

}
}

Thursday, August 6, 2009

Hide or Show Quick Launch Bar

Title: Hide or Show the Quick Launch Bar

Scenario: Our custom master page (xyz.master) overrides the default.master page. The requirement was not to show the left navigation / quick launch menu on the left hand side. However, some site collections that inherit our xyz.master might need the feature of having quick launch visible.

Preface: There are many ways to do it. You can write code that behave intelligently to handle this and so on and so forth. But the situation could be - it is already hosted and may not have room for a binary drop or feature stapling. Well what I did?

At first place, the quick launch menu can be hidden using the below CSS code

Code:

<style>
.ms-navframe { display:none; }
</style>

So to enable it back, all we need to do is to set the display property to 'block' instead.

I added a content editor webpart and add the below code to the page.

<style>
.ms-navframe { display:block; }
</style>

Since a CEWP can handle code that of script and styles, it can override the master page css and displays the quick launch.

Wednesday, July 22, 2009

SharePoint Site Backup and Restore using STSADM

Scenario: Backup sitecollection and restore it on a different server or same server.

Preface: Lets build some simple script (batch) files here. First declare the constants. Notice the BACKUPFILENAME variable. That would build the file name as YYYY_MM_DD_BACKUP.BAK

Code:

@SET STSADM="c:\program files\common files\microsoft shared\web server extensions\12\bin\stsadm"
@SET MAINSITEURL="http://servername"
@SET BACKUPFILENAME="C:\SiteBackUp\%date:~10,4%_%date:~4,2%_%date:~7,2%_backup.bak"

Backup Commands: Before you take the backup, ensure the Site has 'none' lock. However, when you are ready to run the backup... make sure you make the site lock to 'readonly' so that no further changes can occur.

@echo off
Echo ------------------------------------------------------------------

Echo Getting Site Lock
stsadm -o getsitelock -url %MAINSITEURL%

Pause

Echo Setting Site Lock to ReadOnly
stsadm -o setsitelock -url %MAINSITEURL% -lock readonly

Echo Backing up the top level site
stsadm -o backup -url %MAINSITEURL% -filename %BACKUPFILENAME% -overwrite

Echo Setting Site Lock to None
stsadm -o setsitelock -url %MAINSITEURL% -lock none

Echo ------------------------------------------------------------------
Pause please press any key to continue...

Restore Commands: Use the below script to restore the backed up site onto the new site collection on a new machine.


Echo Getting Site Lock
stsadm -o getsitelock -url %MAINSITEURL%

Pause
@echo off
Echo ------------------------------------------------------------------

Echo Setting Site Lock to none
stsadm -o setsitelock -url %MAINSITEURL% -lock none

Echo Restoring the top level site
stsadm -o restore -url %MAINSITEURL% -filename %BACKUPFILENAME%

Echo Setting Site Lock to None
stsadm -o setsitelock -url %MAINSITEURL% -lock none

Echo ------------------------------------------------------------------
Pause please press any key to continue...



Output: In case the target site does not exist Restore commands would create a new site collection (if it were a different server). If restoring on the same server, you have to use '-override' parameter or have to create a new content database for that Site Collection and then restore.

Ensuring SharePoint Success

Dux Raymond will be hosting a mentoring workshop "Ensuring SharePoint Success: How to Effectively Deliver the Promise of SharePoint" on August 19-21, 2009. In this unique, one time event, he'll be joining by leading SharePoint thought leaders (Paul Culmsee, Andrew Woody and Ruven Gotz) in Organizational Change, Project Management, Requirements Development and Agile Methodology from around the world mentoring you to make sure you can deliver SharePoint success. Not only will they teach key concepts and theories, they'll provide real-world templates, checklists, project artifacts and provide group + 1 on 1 mentoring sessions with the participants!


Check out further details here.

RightsSensitiveVisibilityHelper UserHasRights

Scenario: Find whether the current user has permissions for a specified SPList object

Output:
true if the current user has permissions for the object; otherwise, false.

Code:

public static bool UserHasRights (
PermissionContext permissionContext,
SPBasePermissions permissions,
PermissionMode permissionMode,
SPList contextList
)

Where,
permissionContext: value that indicates the context object to which a permission mask is applied.

permissions: An SPBasePermissions value that specifies the built-in permissions available in

permissionMode: A PermissionMode value that specifies whether the user must have all of the rights specified in the permission mask to view a link, or only one of the rights specified in the permission mask.

contextList: The SPList object to evaluate.

Tuesday, July 14, 2009

Adding and Removing a button to the Ribbon ( SharePoint 2010 )

*** Please view the disclaimer before you proceed ***

Scenario: Adding and Removing a button on the Ribbon. You can define the location on the Ribbon where you want the button to appear. Follow the below method to add a new button / remove the button to the Library tab in the Actions group for a document library.

How-To:

    1. Create a folder under 14 hive\Template\Features (SharePoint 2010 will have 14 hive similar to that of 12 in WSS / MOSS 2007) RibbonButton
    2. As seen in the previous post create the feature.xml
    3. Create a blank xml file, manifest.xml and add the below content (Adding Button) to it and Save it.
    4. Deploy the customization using Windows PowerShell as shown in my previous blog.
    5. Test it by navigating to the document library in your site / sub site and clicking on the library tab > Actions group > New Button button.
    6. To remove the button replace the content in the manifest.xml with the Removing Button content mentioned below.

Adding Button:



<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="Ribbon.Library.Actions.AddAButton"
Location="ViewToolbar"
RegistrationId="101"
RegistrationType="List"
Title="Add a Ribbon Button">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition
Location="Ribbon.Library.Actions.Controls._children">
<Button Id="Ribbon.Library.Actions.NewRibbonButton" Command="NewRibbonButtonCommand"
Image16by16="/_layouts/images/FILMSTRP.GIF"
Image32by32="/_layouts/images/PPEOPLE.GIF"
LabelText="New Button"
TemplateAlias="o2" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="NewRibbonButtonCommand"
CommandScript="javascript:alert('This is a new button!');" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>

// Image16by16 and Image32by32 are part of SharePoint 2010

Removing Button:



<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<HideCustomAction Id="RemoveRibbonButton"
Location="CommandUI.Ribbon.Library.Actions.ConnectToClient">
</HideCustomAction>
</Elements>

Technorati Tags: ,

Customizing and Deploying Ribbon in SharePoint 2010

*** Please view the disclaimer before you proceed ***

Introduction: You might have seen in the sneak peek and beta screens of Office 2010 the new Ribbon pattern / interface / control. This post would give details about how to customize and deploy the same using Windows Power Shell.

How to: A sample feature could resemble the following:

<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="FeatureId"
Title="Name of the Feature"
Description="Description of the Feature."
Version="1.0.0.0"
Scope="Web"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="manifest.xml" />
</ElementManifests>
</Feature>

To deploy and enable it use the following commands:

Install-SPFeature FeatureId Enable-SPFeature FeatureId -Url http://server/site/subsite


Technorati Tags: ,

SharePoint Products and Technologies: 2010 (Tech Preview) Developer Documentation

Here is the link. It has got the Reference Document help file and how to customize the new ribbon control.

Help file contains details of lot of new web controls that you might want to see when compared with MOSS 2007.

Monday, July 13, 2009

SharePoint 2010 – Preliminary System Requirements - Getting Ready

Gear up for the SharePoint 2010 now. You might want to check the following and take advantage of the forth coming SharePoint 2010 Services.

Hardware:

    • Plan for 32bit to 64bit upgrade. SP 2010 has 64bit flavor only.
    • SP 2010 needs SQL 2K8 or SQL 2K5 running on 64 bit. Which means, you might want to considering upgrading your SQL box too.
    • SP 2010 will need Windows 2008 Server or above to run.
    • Make sure your development environment is also upgraded to 64bit.

Service Packs:

    • If you are planning to upgrade from MOSS 2007 or WSS 3.0, first deploy your existing environment with SP2 and then upgrade to SP 2010.
    • Run the Upgrade Checker Tool that’s included in SP2 which might bring upfront notice of possible issues during or upon upgrade.

Development:

    • Consider migrating to Visual Studio 2010 (pretty good migration and new tools available)
    • Watch for deprecated API’s
    • New deployment and packaging available with VS 2010 coming along.
    • Learn LINQ, entity models and Silverlight since these are supported in SP 2010.

Browser Compatibility:

    • IE > 6.0 is a mandate, which means you cannot use IE 6.0.
    • Fire Fox 3.x is supported.
Technorati Tags:

SharePoint 2010

Disclaimer:

Hi All,

Very soon I will start blogging about SharePoint 2010 a.k.a SharePoint Services “14”. Well since we are still talking about the beta version coming down during October this year, what ever is written in the blog might change substantially prior to the final commercial release. Also you cannot test them until you have either final product or beta or any prior tech preview releases (if any) that Microsoft makes. The risks associated with the implementation of my writings are purely users and solely its users decision and discretion in using so.

regards,
Srini Sistla

SharePoint 2010 Sneak Peek

Here is the link to the SharePoint 2010 Sneak Peek. Cant wait longer to get hands on :-)... Waiting to see if I can get the tech preview.

Friday, July 10, 2009

SilverLight 3.0 Released

Today SilverLight 3.0 and Microsoft Expression 3.0 released. Details are here.

What’s new in SilverLight 3.0 are here.

Technorati Tags:

Thursday, July 9, 2009

RSS / Atom Aggregator WebPart - Syndication using WCF

Preface: In my previous post, I wrote about the RSS Aggregator Webpart. That version of code used XMLDom model. However, in .NET 3.5 we have syndication classes available and you can see how reading RSS / Atom feeds have become so easy. This supports Atom 1.0 and RSS 2.0 versions.

Since the process is same, you can pass multiple feed url’s and make it aggregator too.

Assembly Reference: System.ServiceModel.Syndication

Solution:

public void GetSyndication(string url)
{
SyndicationFeed feed = SyndicationFeed.Load(XmlReader.Create(url));
if (null != feed)
{
foreach (SyndicationItem item in feed.Items)
{
//Link to the Post - item.Links[0].Uri.AbsoluteUri.ToString()
//Title of the Post - item.Title.Text
//Description - item.Summary.Text
}
}
}

Most of the time, you will end up querying either of Atom / RSS formats and you never know which one is the input. So, I kind of had a check point to validate the input formats. If one of the conversion fails, its obviously the other. Well here is the full code.


Your entry point would be GetSyndicationFeed Method if you dont know what's the incoming feed. However, if you know the feed type then you can directly call either the GetRSSFeedString method or GetAtomFeedString method directly.

public string GetSyndicationFeed(string url, string type)
{
if (string.IsNullOrEmpty(url)) return string.Empty;

string ret = string.Empty;
switch (type.ToLower())
{
case "rss":
ret= GetRSSFeedString(url);
break;
case "atom":
ret= GetAtomFeedString(url);
break;
case "": // Acts as a validator
try {
Rss20FeedFormatter rss = new Rss20FeedFormatter();
rss.ReadFrom(XmlReader.Create(url));
ret= GetRSSFeedString(url);
}
catch (XmlException exml){
ret= GetAtomFeedString(url);
}
break;
}
return ret;
}

public string GetRSSFeedString(string url)
{
StringBuilder sb = new StringBuilder();
Rss20FeedFormatter rss = new Rss20FeedFormatter();

try
{
rss.ReadFrom(XmlReader.Create(url));
}
catch (XmlException exml)
{
// Log it.
}

if (null == rss.Feed) return string.Empty;

foreach (SyndicationItem item in rss.Feed.Items)
{
// item.Links[0].Uri.AbsoluteUri.ToString() // - URL link to the post
// item.Summary.Text.ToString() // - Description or Summary of the post
// item.Title.Text // - Title of the post
}

return sb.ToString();
}

public string GetAtomFeedString(string url)
{
StringBuilder sb = new StringBuilder();
Atom10FeedFormatter atom = new Atom10FeedFormatter();

try
{
atom.ReadFrom(XmlReader.Create(url));
}
catch (XmlException exml)
{
// Log it.
}

if (null == atom.Feed) return string.Empty;

foreach (SyndicationItem item in atom.Feed.Items)
{
// item.Links[4].Uri.AbsoluteUri.ToString() // - URL link to the post
// ((System.ServiceModel.Syndication.TextSyndicationContent)(item.Content)).Text // - Description or Summary of the post
// item.Title.Text // - Title of the post
}

return sb.ToString();
}

Technorati Tags: ,,,,

Wednesday, July 8, 2009

Scheduling a SharePoint Backup

Scenario: Unfortunately as in the previous version, MOSS 2007 also doesn't have a tool for scheduling backups.

Solution: Command-Line backup tools – The stsadm.exe enables sharepoint admins to backup site collections using the command line and makes it easier to restore site collection (or a site).

Usage:
stsadm –o backup –url <url> –filename <filename> [-override]

for example:

stsadm –o backup –url http://myserver/sites/ –filename c:\mybackups\


Catastrophic backup: The stsadm utility now lets you do a full SP backup as you would with a CA Page.


To issue a full or differential backup use the format

stsadm –o backup –directory <unc path> –backupmethod <full | differential> [-item<created path from tree>] [-%<int between 1 and 100>] [-backupthreads<int between 1 and 10>] [-showtree] [-quite]


for example: (to back up entire SP Farm)

stsadm –o backup – directly \\backups\sharepoint –backupmethod full 


Technorati Tags: ,