Enumerate SharePoint Features

Enumerate Installed Features in the Farm

TreeView TreeView1 = new TreeView();

TreeView1.Nodes.Add(new TreeNode("Features"));
TreeNode oFSiteNode = null;
TreeNode oFNode = null;

SPSecurity.RunWithElevatedPrivileges(delegate()
{

//get the name of the current web in current user's context

                string spSiteURL = SPControl.GetContextSite(Context).Url.ToString();

                //Initialize the spweb object using the elevated privileges
                using (SPSite oSite = new SPSite(spSiteURL))
                {


TreeView1.Nodes.Clear();

#region Return Installed Features.

                    oFSiteNode = new TreeNode("All Farm Installed Features");

                    SPFarm oFarm = oSite.WebApplication.Farm;

                    SPFeatureDefinitionCollection oFeatDefColl = oFarm.FeatureDefinitions;
                    foreach (SPFeatureDefinition oFeatDef in oFeatDefColl)
                    {
                        if (oFeatDef != null)
                        {
                            oFNode = new TreeNode(oFeatDef.GetTitle(new System.Globalization.CultureInfo(1033)));
                            oFSiteNode.ChildNodes.Add(oFNode);
                        }
                    }

                    TreeView1.Nodes[1].ChildNodes.Add(oFSiteNode);

#endregion

TreeView1.CollapseAll();
oSite.Dispose();

}

}

Enumerate Site collection and Site Content Types

I will be creating a web part that enumerates root site and all it's subsites content types along with their columns.

We will be using a Tree View control for this.

using System;
using System.Collections.Generic;
using System.Text;

using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.WebControls;

/// <summary>
        /// Shows content types recursively
        /// </summary>
        /// <param name="oWeb">The parent node</param>
        /// <param name="oNode">The content Type node</param>
        protected void ShowCTypes(SPWeb oWeb, TreeNode oNode, SPContentTypeId contTypeID)
        {
            TreeNode oSubNode = null;
            SPContentTypeCollection oCTypeColl = oWeb.ContentTypes;

            foreach (SPContentType conttype in oCTypeColl)
            {
                //if current type is child of parameter oNode and is not the root ctype
                if (conttype.Parent.Id == contTypeID && conttype.Parent.Id != conttype.Id)
                {
                    oSubNode = new TreeNode(conttype.Name);
                    oSubNode.NavigateUrl = oWeb.ServerRelativeUrl + "/_layouts/ManageContentType.aspx?cType=" + conttype.Id;
                    oSubNode.Target = "_blank";

                    //add columns
                    ShowCtypeColumns(oSubNode, conttype);
                    //add subnodes
                    oNode.ChildNodes.Add(oSubNode);

                    //now oSubNode is the parent node
                    ShowCTypes(oWeb, oSubNode, conttype.Id);
                }
            }

        }

        /// <summary>
        /// Shows columns for a content type
        /// </summary>
        /// <param name="oNode">Current content type Treenode</param>
        /// <param name="contType">Content type whose columns are to be added</param>
        protected void ShowCtypeColumns(TreeNode oNode, SPContentType contType)
        {
            TreeNode oSubNode = null;

            //fetch fields of content type
            SPFieldCollection oFldColl = contType.Fields;

            if (oFldColl.Count != 0)
                oNode.ChildNodes.Add(new TreeNode("Columns"));

            foreach (SPField oField in oFldColl)
            {
                if (!oField.Title.Equals("ContentType") && !oField.Hidden)
                {
                    oSubNode = new TreeNode(oField.Title);
                    oSubNode.NavigateUrl = contType.ParentWeb.ServerRelativeUrl + "/_layouts/ManageContentTypeField.aspx?cType=" + contType.Id + "&Field=" + oField.InternalName + "&Fid=" + oField.Id;
                    oSubNode.Target = "_blank";
                    oNode.ChildNodes[0].ChildNodes.Add(oSubNode);
                }
            }

        }

/// <summary>
        /// Creates Treeview nodes for content types and features.
        /// </summary>
        protected void CreateControls()
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                TreeView1.Nodes.Clear();
                TreeView1.Nodes.Add(new TreeNode("Content Types"));

                //get the name of the current web in current user's context

                string spSiteURL = SPControl.GetContextSite(Context).Url.ToString();

                //Initialize the spweb object using the elevated privileges
                using (SPSite oSite = new SPSite(spSiteURL))
                {
                    SPWebCollection oWebColl = oSite.AllWebs;

                    #region Add content types

                    TreeNode oSiteNode = null;
                    foreach (SPWeb oWeb in oWebColl)
                    {
                        //create website nodes
                        oSiteNode = new TreeNode(oWeb.Title);
                        oSiteNode.NavigateUrl = oWeb.Url;

                        //get contenttypes collection for each subsite including root site
                        SPContentTypeCollection oCTypeColl = oWeb.ContentTypes;
                        TreeNode oNode = new TreeNode();

                        //if site doesn't have any Ctypes (only content types defined for that particular site are displayed)
                        if (oCTypeColl.Count != 0)
                        {
                            oNode.Text = oCTypeColl[0].Name;
                            oNode.NavigateUrl = oWeb.ServerRelativeUrl + "/_layouts/ManageContentType.aspx?cType=" + oCTypeColl[0].Id.ToString();
                            oNode.Target = "_blank"; //opens link in new window

                            //send current site and root contenttype node (not the actual content type)
                            ShowCTypes(oWeb, oNode, oCTypeColl[0].Id);

                            //add root contenttype node to website node
                            oSiteNode.ChildNodes.Add(oNode);

                        }
                        //add website node to root node of treeview.
                        TreeView1.Nodes[0].ChildNodes.Add(oSiteNode);
                        oWeb.Dispose();
                    }
                    #endregion

 

TreeView1.CollapseAll();
                    oSite.Dispose();
                }
            } //end of delegate
            ); //end of RunWithElevatedPrivileges

        }

        protected override void OnPreRender(EventArgs e)
        {
            CreateControls();
        }

        protected override void CreateChildControls()        {
            //add control to treeview
            this.Controls.Add(TreeView1);
        }

        protected override void RenderContents(HtmlTextWriter writer)
        {
            //render treeview control
            TreeView1.RenderControl(writer);
        }

    }
}

SharePoint ULS logs are empty: 0 KB logs in 12 Hive logs

A few months back I decided that it was time to get rid of unnecessary SharePoint logs since I wasn't into development and event logs were coming sufficient. Just in case you guys are wondering how to enable diagnostic logs, here are the steps: -

1) Open central administration > operations. Click on 'diagnostic logging' under 'Logging and Reporting'.

2) Select 'no' for 'Customer Experience Improvement Program' and 'ignore errors' for 'error reports'. If you wish to throttle (restrict) the events captured, select from category and events to be captured in event logs and trace logs (12 hive).

3) Provide the location for storing these logs. I usually keep 5-10 log files of 10-30 minutes each; otherwise my disk becomes full. As a practice keep logs in a different disk then the MOSS/WSS installation so that disk full issues do not affect the service.

NOTE: there are two types of logs in 12 Hive logs folder (<local-drive>\Program Files\Common Files\Microsoft Shared\web server extensions\12\Logs). The ones sitting outside the GUID folders are used for debugging and called ULS (unified logging service) logs. The ones within the GUID are usage analysis logs.

======================================================================

Anyway, back to my original issue; I happily disabled the logs, however few weeks back decided to re-enable them. And what, did everything as described above and the log files hence created were empty. Hmm, mind boggling; didn't look like a permission issue; still haven' figured out yet; the logs were being constructed but were of 0 KB each; files were empty: -

Things to check in his situtaion: -

  • enough disk space.
  • check if WSS timer service and WSS tracing service are running. Restart them once again.
  • try throttling the events (though this is most unlikely to work out as a solution since you would be restricting logs; exactly the opposite); however it worked for me; I enabled Verbose logging in trace log category of diagnostic logging page and logs started filling up. Whew!! Thank goodness, at least I have some data in logs now. This is a very strange behavior, what you guys should check is if you are throttling anything; remove that selection. For example throttling error events when no errors are there would give empty logs.

If anyone has figured out the solution, do let me know as my system is behaving exactly the opposite. :)

 

 

Today when I started my server (WIN 2k3), it threw a 'Service control manager' error: 'Failed to start at least one or more services'. I checked Event viewer and found the following error.

image

Upon manually trying to start IIS Admin from MMC , same error was thrown. I googled and as expected found an article - http://support.microsoft.com/kb/332103 from Microsoft saying "reinstall IIS". Err.. Definitely not. There has to be some other way. Soon I stumbled upon this angelic post - http://www.iisworkstation.com/2008/07/troubleshooting-could-not-start-iis.html. You can refer to the same post or in case are unable to open it, find below the instructions to troubleshoot this issue.

1) IIS ADMIN service needs two files - 'metabase.xml' and MBschema.xml to start; they reside in C:\WINDOWS\system32\inetsrv. The first thing to check is if files are available, in my case 'metabase.xml' was missing. I vaguely remembered that chkdsk that ran last night had mentioned some corrupt metabase.xml. Hmm.. so the poor file was removed... The first thing I did was to stop automatic startup of IIS ADMIN service from services.msc.

2) Fortunately, C:\WINDOWS\system32\inetsrv\History maintains the 10 latest backups (by default) of metabase.xml and MBScheme.xml files. As instructed, I copied the most recent entry (by modified date).

image

and pasted it to C:\WINDOWS\system32\inetsrv. Then I renamed it to 'metadata.xml'. Next I went to services.msc, changed the startup mode of IIS ADMIN from manual to automatic and started it. Immediately I got some script error. hmm. ...anyways, I clicked on yes and continued;the service started successfully.

3) Next thing to do was to increase the number of history files saved (learn from the past as I periodically backup SAM, SECURITY, SOFTWARE AND DEFAULT) . As instructed I ran the following command from start > run.

cscript.exe adsutil.vbs set /MaxHistoryFiles "15"

Ntime when the system restarts the effects will take place (else manually restart the IIS ADMIN service again).

4) Next thing was to go to 'INETMGR'. All the websites were in stopped state. I manually started them and checked in IE if my SharePoint sites were coming up fine. Finally YES YES YES.

Hope it helps anyone who faces this issue. Thanks to the original post!!

If you want to prevent a site from being crawled at all, you can set the 'Search Visibility' to false within the site settings. For an entire site collection you need to set this for each site as 'search visibility' is a site feature. (site features > search visibility).

image

 

The preferred way is to create a crawl rule in Central Admin of MOSS.

image

But what if you do want your site to be crawled however don't want it to appear in search results within certain site scopes? Let us assume 'ALL SITES'.

well, quite simple!

go to Central admin > Shared services > search services > view scopes.

Open the 'all sites' scope in edit mode. create a new exclude rule for hostname. save changes and bingo. :)

Downgrade Windows Vista to Windows XP on Inspiron 1525

[Out of context from current blog's subject, but thought should share with you; so.....Last night, my brother's system completely crashed and resolved to never work again for 2 minutes at a stretch. Unfortunately poor thing was hit by a deadly virus (unknown of course) a month back (courtesy his best friend who suddenly decided to download a video file packaged with a treat).

We tried everything from setting the Dell Inspiron 1525 to factory settings, blah blah but nothing worked. So ultimately, it was decided that Vista's time is up! Yes!!!! I never wanted to reinstall Vista. hehehe (finally will try slip-streaming). yay!

We collectively agreed on making a fresh install of Windows XP (goo goo goo...); I located one of my old CDs and prayed it would work and yes it did :)

But what is this; as soon as the setup started I got hi by below error: -

image

"Setup did not find any hard disk drives installed in your computer". I am sure it is one of those old sticky errors that people encounter while downgrading to Windows XP or Windows 2003 Server.

Reason: The system has SATA hard drive whose drivers are missing in Windows XP installation. So what now? I googled and found the way out and this is what I am about to share with you guys today.

We need to somehow integrate the missing SATA drivers with Windows setup files and use it.

Task 1: Find SATA drivers for Dell Inspiron 1525

Luckily unlike my HP laptop, I didn't have a field day locating SATA drivers for above model. Go to http://support.dell.com/support/downloads/driverslist.aspx?c=us&l=en&s=gen&ServiceTag=&SystemID=INS_PNT_PM_1525&os=WLH&osl=en&catid=&impid. Select "Windows XP" from OS dropdown.

image

and Bingo, all the drivers are located at one good old page. :). As for initial Windows XP installation, all we need is SATA drivers. I downloaded the highlighted one. at times

image

Download this EXE file (http://ftp.us.dell.com/SATA/R182441.exe). Once downloaded, right-click on it and select 'extract files' (need WIN RAR). Provide a location like "C:\XP Drivers for Inspiron 1525\R166200". At times 'download' button doesn't work. In such a case, replace highlighted text with the value of 'fileID' mentioned in the address bar.

http://support.dell.com/support/topics/global.aspx/support/downloads/en/downloads_splash?c=us&l=en&s=gen&%7Emode=popup&file=238839

Task 2: Install NLITE for creating a new windows XP setup slip streamed with SATA drivers

If you're using non Vista OS like XP, 2k3 to perform slip-streaming go to http://nliteos.pcrpg.org/nlite/nLite-1.4.9.1.installer.exe; for VISTA users http://nliteos.pcrpg.org/vlite/vLite-1.2.installer.exe.

Remember you would need .NET framework 2.0 SP1 as a prerequisite in case on XP, WIN 2K3 and VISTA and an additional AIK Kit (heavy files) for VISTA. I used my server for creating set-up. :). Download and Install NLite/VLite.

Task 3: Slip-Streaming (integrating SATA drivers with Win XP Pro Setup)

Start NLITE. click Next until you reach below screen, Click on Browse button and select the root folder containing WIN XP setup (in CD/ or HDD if again creating a new image with old setup files). once done, you'll again get a screen, where you need to provide the location to extract win XP setup files to. call it - c:\WinXPISO.

image

Click Next. The setup files will start loading, when the progress bar finishes, you will get below screen.

image

Click Next until you reach below screen. Use 'ctrl' key to multiple select different options. I selected 'service pack', 'drivers' and 'bootable ISO'. Make sure you select at least 'drivers' and 'bootable ISO'. clik Next.

image

If you selected 'service pack' you'' get below screen. Click on 'Browse' button and locate the EXE for Service Pack (2 or 3) in this case. You can get WIN XP SP2 from here-http://www.microsoft.com/downloads/details.aspx?familyid=049c9dbe-3b8e-4f30-8245-9e368d3cdb5a&displaylang=en and SP 3 from here - http://www.microsoft.com/downloads/details.aspx?FamilyID=5b33b5a8-5e76-401f-be08-1e1555d4f3d4&DisplayLang=en

image

If you haven't selected service pack option, you'll be presented with below screen. Click Insert. Select 'single driver'.

image image

Locate the drivers folder (where you extracted SATA driver files in Task 1).

image

select One of the INF files and click Open, both will be selected anyhow.

image

select 'textmode driver' option. I selected the following highlighted drivers for my set up. Click on OK.

image

Click Next. Click Yes upon 'start process?' prompt. Once the process finishes, you've an option to either Burn the new setup files or create an ISO. I chose to create an ISO. select 'create image' and click on 'make ISO' button to start making ISO

image image

Once the ISO is created you can burn the image to a DVD. I used Roxio Easy CD creator. Now that the CD is ready, insert it in the VISTA laptop. I used hairpin to pull the CD tray out and place the CD in it.

On Inspiron 1525, Use F12 to get boot option and select CD/DVD option and proceed. I took the fancy of formatiing and repartitioning the entire HDD since Inspiron 1525 didn't allow more than 1 partition besides System and recovery partition.

Task 4: Get the Missing Drivers for Inspiron 1525

a) Notebook System Software (only for DELL)

http://ftp.us.dell.com/utility/R181862.exe

b) System Software (only for DELL)

http://ftp.us.dell.com/utility/Dell_System-Software_A03_R214472.exe

c) Mobile Chipset Drivers

http://ftp.us.dell.com/chipset/R166187.exe

d) Ricoh Flash Controller Driver

http://ftp.us.dell.com/chipset/R166188.EXE

e) Video Adapter Driver

In order to correctly identify your chipset download chipset ID utility from http://downloadcenter.intel.com/Detail_Desc.aspx?agr=Y&ProductID=861&DwnldID=13799. Mine is Intel GM965 Express Chipset Family.

I recommend searching for latest video drivers/ SATA HDD drivers on Intel rather than Dell -http://downloadcenter.intel.com/default.aspx.

For above mentioned chipset select http://downloadcenter.intel.com/Detail_Desc.aspx?agr=Y&ProductID=2800&DwnldID=17353&strOSs=44&OSFullName=Windows*%20XP%20Professional〈=eng

f) Network Interface Card (Ethernet Controller)

Marvell 88E80XX 10/100 Ethernet Controller at http://ftp.us.dell.com/network/R180046.exe.

g) Dell Quickset (only for DELL)

http://ftp.us.dell.com/app/R174191.exe.

h) Audio Adapter

Sigmatel STAC 92XX C- Major HD Audio Driver at http://ftp.us.dell.com/audio/R180044.exe

i) Modem Driver

Conexant D330,HDA,MDC,v.92,modem at http://ftp.us.dell.com/comm/R167368.exe

j) Wireless Network Card

WLAN driver for Dell Wireless 1395 WLAN MiniCard at

http://support.dell.com/support/downloads/download.aspx?c=us&l=en&s=gen&releaseid=R174291&SystemID=INS_PNT_PM_1525&servicetag=&os=WW1&osl=en&deviceid=9805&devlib=0&typecnt=0&vercnt=1&catid=-1&impid=-1&formatcnt=1&libid=5&fileid=236819.

k) Touchpad driver

http://ftp.us.dell.com/input/R180045.exe

l) Laptop Integrated webcam

This was the trickiest of all. At first I got the error " device driver does not support current OS version". After I installed WIN XP SP 2 I was able to run setup but it always ended in failure. After repeated attempts and trying to make the cam locate drivers using device driver manager somehow 'hardware was properly detected and installed ( magically :))

http://ftp.us.dell.com/input/R165116.EXE

m) Bluetooth

http://ftp.us.dell.com/network/R140135.exe

===============================

Umm...this should pretty much do! Stay tuned for the next blog and your comments are most welcome!

changing the content page’s name that appears on IE window.

· On the default.aspx page, search for

<SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,multipages_homelink_text%>" EncodeMethod="HtmlEncode"/> -

<SharePoint:ProjectProperty Property="Title" runat="server"/>

· Replace <SharePoint:ProjectProperty Property="Title" runat="server"/> with the new title.

Changing the site’s home tab name: -

a) Rename the tab through SharePoint GUI as ‘HOME’

b) Open the master page, search for

<SharePoint:SPLinkButton runat="server" NavigateUrl="~site/" id="onetidProjectPropertyTitle">

<SharePoint:ProjectProperty Property="Title" runat="server" />

</SharePoint:SPLinkButton>

c) Replace <SharePoint:ProjectProperty Property="Title" runat="server" /> with site’s actual name.