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