Happy 2nd Anniversary, EndUserSharePoint.com!

Well, the point of this post is to say “Happy 2nd Anniversary EndUserSharePoint.com”. I really would like to congratulate Mark Miller ( founder ), Natasha Felshman, all the authors, commentors and contributors for the outstanding job they have been doing during the two past years. Needless to say, I am really proud to be a very small part of this wonderful community.

Just within a couple of years, the site has become a community of SharePoint authors who contribute their time and energy into providing some of the best content in the world for SharePoint Information Workers.

Guys there are very open-minded and they really care about the growth of the SharePoint community and this link proves it, Mark Miller was the first one to spread the word about my Arabic SharePoint screencasts. Didn’t I tell you ? I’m really proud to be a small part of such an amazing community:)

The statistics below reflect the huge success and impact of EndUserSharePoint on the SharePoint community, please join me in congratulating Mark Miller by leaving a comment here.

67

I would also like to extend a special thank you to all those who wished to meet me at SharePoint Conference 2009 by listing my name with all the SharePoint gurus and heroes, I’m really depressed that I won’t be able to make it but I’ll will be following the conference through the live media stream.

Usage Analysis is not capturing information for Web Application

Just thought of sharing this MSDN forum-thread with my blog followers since I have received this question more than once. Usage Analysis is really a common source of confusion among SharePoint administrators.

Q :

I have 3 Web Applications, webapp1, webapp2 and I recently added webapp3. each web application hosts about 5 site collections.
I have enabled usage analysis processing  on the farm level but it’s only capturing information for web app1 and web app2. And it’s not capturing any information for any site collection for web app3.

A :

Usage reporting from within MOSS runs on a daily schedule that is user configurable from the central administration, you must wait at least one day for any meaningful reporting to be available for new web application. By the way you should activate the reporting feature on all the site collections in the web application.

Q :

I have already activated the reporting feature on all the site collections and about 48 hours elapsed to collect the usage statistics.

A :

Run the following commands from the command prompt, wait for 24 hours and it should work.

stsadm -o setproperty -pn job-usage-analysis -pv no

stsadm -o setproperty -pn job-usage-analysis -pv yes


This sequence disables, then re-enables the job-usage-analysis job within SharePoint. It’s important to execute this sequence after adding new web applications.
Let me know after 24 hours.

Q :

Now the new web application usage info is captured.

A :

Note that when you add a new Web application to MOSS, usage analysis is not automatically reconfigured. In order to make usage analysis processing available for the new Web application, you must disable, then re-enable via central administration or through STSADM as I showed you.

“The specified network name is no longer available” Exception when using SharePoint Search API!

I ran into a very weird issue that caused me a real headache when using SharePoint Search API !
Below is the code I was using :

FullTextSqlQuery fts = new FullTextSqlQuery(site);
fts.QueryText = "SELECT AccountName FROM portal..scope()…";
fts.ResultTypes = ResultType.RelevantResults;
fts.RowLimit = 100;
ResultTableCollection rtc = fts.Execute();

 

When the last line executes, an exception is thrown with the following message :

The specified network name is no longer available. (Exception from HRESULT:
0x80070040), Exception Stack Trace :    at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(
Int32 errorCode, IntPtr errorInfo)     at Microsoft.Office.Server.Search.Query.FullTextSqlQuery.Execute()

I have also received the following error in the SharePoint Trace Logs:

10/05/2009 20:03:10.18 OWSTIMER.EXE (0x0850)                              0x08D0 Search Server Common                MS Search Administration                  0              High       Log Query:  More Information: The specified network name is no longer available.

Additionally, I have seen this error in the Windows Application log of the SharePoint web front end server:

Office Server Search EventID: 10038 Level: Error Query machine ‘<ServerName>’ has been taken out of rotation due to this error: The specified network name is no longer available. 0x80070040. It will be retried in 15 seconds.

Resolution:

This problem may occur because of an error in Windows Server 2008. If you use the TransactNamedPipefunction to request more than 8,000 bytes of data, Windows Server 2008 does not transfer the data correctly. To solve this issue, install the hotfix from KB 946487 on all Windows Server 2008 machines in the SharePoint farm, this will do the trick!

Hope this helps 🙂

Exporting ListViewWebParts!

ListViewWebPart cannot be exported by design, that’s true! ListViewWebPart elements are tied to the underlying list and views by GUID, and the GUID is unique for each view and each list in each site.

But what if you need to export it to add it to an AllUsersWebPart element in an onet.xml file ?

The following code snippet will export any web part (even if it is a ListViewWebPart ) from the page specified.

SPLimitedWebPartManager mgr = web.GetLimitedWebPartManager(

“default.aspx”

, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

foreach(WebPart webpart in mgr.WebParts )
{
          string Filename = @"c:\webparts\"+ webpart.ID + ".dwp";

System.Xml.XmlTextWriter writer =
new System.Xml.XmlTextWriter(Filename,Encoding.Default);

          webpart.ExportMode = System.Web.UI.WebControls.
                                    WebParts.WebPartExportMode.All;
          mgr.ExportWebPart(webpart, writer);
          writer.Close();
}

	

Adding links to View Selectors through SharePoint Features

Using Features makes it easy to add actions to menus of the user interface in SharePoint. To define a custom action for a particular menu, you must identify the menu by setting the location to the appropriate SharePoint namespace, and by using the ID that SharePoint uses to identify the specific location. The following example shows how to add a link to to the a view selector through a Feature.

<CustomAction
    Id="custom.ActionMenu"
    Location="Microsoft.SharePoint.StandardMenu"
    GroupId="ViewSelectorMenu"
    Title="XSLT View"
    RegistrationType="List"
    RegistrationId="101"

  >
<UrlAction Url="xsltdataviewurl.aspx"/>
</CustomAction>

Your Very Own Permissions Dashboard by Laura Rogers

Using a web service and a little magic, it’s possible to create your own data view web part “dashboard” to quickly get to permissions and other screens for all of the lists and libraries on your SharePoint site.  Here’s an example of what the goal is:

 

This is really a Very cool read for SharePoint! Lot of folks asking how to do this and Laura Rogers has done a fantastic job showing you how. Here is a link to the full article !

Programming against IIS Application pools in SharePoint

Earlier versions of SharePoint did make some use of the .NET Framework, but SharePoint 2007 has been rebuilt from ground up on top of it, meaning SharePoint applications are in fact tremendously powerful ASP.NET applications.

What are Application Pools?
A classic example that I always utilize to discuss application pools is a web hosting company that hosts many websites on a common server, and therefore all the websites hosted on this server share the system resources. If one of the hosted websites had a memory leak, this potentially takes memory away from the other hosted sites, causing errors and inconveniences.
Prior to IIS 6.0, at least, that was the case. Too many server resources were shared between websites, and it was too easy for an error to creep in and damage the entire server process.

Fortunately, IIS 6.0 introduced a new concept called application pools. Application pools form boundaries around applications, separating them from each other even though they are being hosted on the same server.

Each application pool is given its own set of server resources (including memory). That way, the hosting company can now host each website in its own application pool to accomplish security, reliability, and availability and to prevent the leaky or misbehaving site from affecting other sites.

Application Pools in SharePoint Object Model

The SharePoint OM comprises types whose instances correspond to IIS entities such as application pools, web sites,…. These types permit you to program against these entities within your code

SharePoint represents each IIS application pool with an instance of a type named SPApplicationPool, which allows you to program against IIS application pools from your managed code. Here are some of the public methods of the SPApplicationPool class that you can use in your managed code:

  • Provision. This method creates the application pool.
  • Unprovision. This method removes the application pool.
  • Update. This method updates and commits the changes made to the application pool.
  • UpdateCredentials. This method updates and commits the credentials under which the
    application pool is running.
   1:  SPWebServiceCollection wsc = new SPWebServiceCollection(SPFarm.Local);
   2:  foreach (SPWebService ws in wsc)
   3:  {
   4:       SPApplicationPoolCollection appPoolCollection= ws.ApplicationPools;
   5:       foreach (SPApplicationPool appPool in appPoolCollection)
   6:       {
   7:           // Your code
   8:       }
   9:  }