SharePoint Central Administration Content Database in Suspect Mode

Yesterday my worst fears came true. On my development environment where all my SharePoint 2010 projects are located my Central Administration site suddenly didn’t respond. It only returned HTTP error: 404 – What!!

ISS was running, no problems with AppPool, SQL server was running og the weirdest parts was that all my sites was running as well! Only CA site was down.

So the nasty part began where eventviewers, log file crawling, google searching etc. where analysed in details.

The logs and eventviewers had a lot of
– “Login failed for user ‘INTELLISOFT\sp_workerprocess’. Reason: Failed to open the explicitly specified database.”
but also this
– “During redoing of a logged operation in database ‘SharePoint_AdminContent_00bd9b82-4cf1-4846-975a-2b5b8d5287a5’, an error occurred at log record ID (3173:321:29). Typically, the specific failure is previously logged as an error in the Windows Event Log service. Restore the database from a full backup, or repair the database.”

You don’t have to be a SQL Server brain to figure out that this is gonna make your life a nightmare. And on top of all I had just spent several hours updating some Sharepoint solution that needed a blank sitecollection for testing. And with no access til CA, your pretty much out of luck.

So i went to SQL Server Management Studio and noticed that among all my databases the SharePoint_AdminContent_GUID was marked “Suspect”!

After googling this error like crazy the only thing I could find at the beginning was to restore a backup of the AdminContent database. But sadly enough on my dev environment I haven’t got backups of the individual databases. I only backup my Visual Studio projects regular and the entire VMware machine once in a while.

So with many hours of restoration in mind i started copying  the last backup from my NAS to the laptop. Meanwile I googled some more and luckily enough I found this article  by Mehuil K Bhuva who has just become my biggest idol. Mehuil describes how you run some repair jobs on your corrupt database and in my case the database got restored and is now up and running again.

So Mehuil: From now om I am officially your biggest fan. You just saved me hours and hours of restoring my dev environment and now there is a god chance that I can actually deliver the solution to my customer in time. Thanks again for taking your time to write this amazing article. All I did was to replace the DB name with my own. Run all the SQL commands in one query and after a few minutes the “suspect” mark was gone and CA was running again. Can’t get my arms down – you saved my life!

I decided to write this post so that more people can find Mehuils solution and to let everyone know that it worked for me.

For the complete article on what you should do please visit Mehuils blog.
To make sure that this knowledge isn’t lost I have pasted the SQL Query below but all credit goes to Mehuil on this one – Great work!

1. locate your mdf and ldf files in your SQL Server data directory

2. start up SQL Server Management studio at click “New Query”

3. Insert this below and make sure that you replace database name with your own

Use master
–Verify whether Database has any issues
EXEC sp_resetstatus “SharePoint_AdminContent_38c5cc2d-aeec-4dc2-b7a5-65457250ae2c.mdf”

—Alter database and put it on Emergency Mode
ALTER DATABASE “SharePoint_AdminContent_38c5cc2d-aeec-4dc2-b7a5-65457250ae2c” SET EMERGENCY DBCC checkdb(‘SharePoint_AdminContent_38c5cc2d-aeec-4dc2-b7a5-65457250ae2c’)

–Set the database in the Single User mode
ALTER DATABASE “SharePoint_AdminContent_38c5cc2d-aeec-4dc2-b7a5-65457250ae2c” SET SINGLE_USER WITH ROLLBACK IMMEDIATE

–Repair the database and allow data loss
DBCC CheckDB(‘SharePoint_AdminContent_38c5cc2d-aeec-4dc2-b7a5-65457250ae2c’,REPAIR_ALLOW_DATA_LOSS)

–Set the database back to Multi-User mode
ALTER DATABASE “SharePoint_AdminContent_38c5cc2d-aeec-4dc2-b7a5-65457250ae2c” SET MULTI_USER

–Ensure Database is reset
EXEC sp_resetstatus ‘SharePoint_AdminContent_38c5cc2d-aeec-4dc2-b7a5-65457250ae2c’

Hit execute and wait for a few minutes. It took around 4 minutes on my system.

Once done a refresh of your SQL Server object explorer should remove the “Suspect” marking and your CA site should be running again.


, ,

Leave a comment

Installing SharePoint 2010 on a closed network

I just had the “pleasure” of installing SP2010 on a customers offline network. Apparently most prerequisites are downloaded on the fly which result in great troubles when out SharePoint servers aren’t connected to the outside world.

After having manually installed a few prerequisites I discovered this great article contained direct download links to all prerequisites. Thanks Dave!

Note that the 2 prerequisites regarding speech may just open the installer and disappear again but they perform their job anyway. At least as far as SharePoint are concerned. Also note that the Analysis Services ADOMS.NET comes in a version for both SQL Server 2008 and SQL Server 2008R2. I tried using the R2 version because my SQL Server is R2. However the prerequisites installer will only recognise installing the NOT R2 version – didn’t dvelve too much into that.

Leave a comment

Troubleshooting “The search request was unable to connect to the Search Service”

When working with search in SharePoint 2010 you might run into the error “The search request was unable to connect to the Search Service” in the Core Results webpart.

If or when this happens you should check a few things

Is the search service running?
Go to the server that handles search requests and select Start > Administrative tools > Services. Locate the service “SharePoint Server Search 14” and check that it is running

Is the Webapplication associated with the Search Server Service?
Go to Central administration > Manage Webapplications > click on the Webapplication that troubles you > Click Service Connection. In the windows “Configure Service Application associations” ensure that Search Service Application is checked

Have you altered the settings in the Search Core Results webpart?
Locate your Search Core results webpart > Edit Web Part > Location properties > select Location: none. If you might have selected “Local FAST search results” it wil result in the error “The search request was unable to connect to the Search Service” when FAST isn’t configured.

If none of these suggestions work and you might have found something else that could be causing this error please let me know.

1 Comment

Custom mysite masterpage for Personal sites

I just had to write down some notes on the steps needed to take when you want to set your own custom master page for every personal site.

If you don’t have the complete overview on how mysites and personal sites works together you should read this first: Sharepoint 2010 Mysite in detail

Since personal sites are in fact sitecollections (one per user) and masterpage settings are scoped to sitecollection you need feature staplers to have every new site use your own custom master page instead of the one default (v4.master)
You should furhtermore know at personal sites are created on the fly from the Mysite host when clicking “My Content” if you don’t already have one.

So here are the steps.

1. Create your own custom masterpage (ofcourse 🙂 and wrap it into a feature to make it appear to the Masterpage gallary for new sitecollections.

2. Create a feature with a feature receiver for setting the master page

The code for the feature receiver could look like this

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
                SPWeb web = ((SPSite)properties.Feature.Parent).RootWeb;
                web.MasterUrl = web.MasterUrl.Substring(0, web.MasterUrl.LastIndexOf('/') + 1) + "MyOwnCustom.master";
                web.CustomMasterUrl = web.CustomMasterUrl.Substring(0, web.CustomMasterUrl.LastIndexOf('/') + 1) + "MyOwnCustom.master";
            catch (Exception ex)
                //Write error to ULS (Unified Logging System - 14/Logs) if desired (Remember to specify: using Microsoft.Office.Server.Diagnostics;)
                //PortalLog.LogString("MyOwnCustom master- Feature receiver: Set Master for new Personal sites - Error: " + ex.ToString());

The scope of this feature should be Site (Sitecollection)

3. Create another feature (the stapling feature)
This feature is used to tell Sharepoint which feature should be actived when a site is created using a certain sitedefinition.

<Elements xmlns="">
  <FeatureSiteTemplateAssociation Id="A392DA98-270B-4e85-9769-04C0FDE267AA" TemplateName="SPSPERS#0" />
  <!-- Publishing Prerequisites -->
  <FeatureSiteTemplateAssociation Id="AEBC918D-B20F-4A11-A1DB-9Ed84D79C87E" TemplateName="SPSPERS#0" />
  <!-- Publishing Resources -->
  <FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="SPSPERS#0" />
  <!-- SharePoint Server Publishing Infrastructure - Scope: Site -->
  <FeatureSiteTemplateAssociation Id="D0DF37FC-060A-4F57-AE3F-310C2D438551" TemplateName="SPSPERS#0" />
  <!-- Custom Publishing Layouts -->
  <FeatureSiteTemplateAssociation Id="98D8A361-DDF6-4771-A285-64D23E0E556C" TemplateName="SPSPERS#0" />
  <!-- Feature receiver for setting custom master (code)-->

Notice that some other features should be activated before you can set your own master. (Se the complete list of features here – for use in other scenarios)
The “Custom Publishing Layouts” feature is my own custom feature that holds my custom masterpages, pagelayouts, styles etc.
The “Feature receiver for setting custom master” is the feature that reference my feature receiver (se step 2)
Notice that the sitedefinition for Personal sites are named SPSPERS#0 (See a complete list of sitetemplates here)

The scope of this feature should be farm (Farm) – Se this post if you have trouble with the error: “The Project Item “[Item Name]” cannot be deployed through a Feature with Farm  – It sure as hell gave me some headaches – dammit!
scope” when trying to deploy your solution/WSP

4. Deploy the solution and try to create a new personal site.

If I have left something out please let me know


Sharepoint 2010 sitetemplates

Getting pretty tired of finding the complete list of sitetemplates on Sharepoint 2010.

By using the powershell command: get-spwebtemplate you’ll get the complete list of templates available

The complete list is:

Name Title LocaleId Custom
GLOBAL#0 Global template 1033 False
STS#0 Team Site 1033 False
STS#1 Blank Site 1033 False
STS#2 Document Workspace 1033 False
MPS#0 Basic Meeting Workspace 1033 False
MPS#1 Blank Meeting Workspace 1033 False
MPS#2 Decision Meeting Workspace 1033 False
MPS#3 Social Meeting Workspace 1033 False
MPS#4 Multipage Meeting Workspace 1033 False
CENTRALADMIN#0 Central Admin Site 1033 False
WIKI#0 Wiki Site 1033 False
BLOG#0 Blog 1033 False
SGS#0 Group Work Site 1033 False
TENANTADMIN#0 Tenant Admin Site 1033 False
ACCSRV#0 Access Services Site 1033 False
ACCSRV#1 Assets Web Database 1033 False
ACCSRV#3 Charitable Contributions Web Database 1033 False
ACCSRV#4 Contacts Web Database 1033 False
ACCSRV#6 Issues Web Database 1033 False
ACCSRV#5 Projects Web Database 1033 False
BDR#0 Document Center 1033 False
OFFILE#0 (obsolete) Records Center 1033 False
OFFILE#1 Records Center 1033 False
OSRV#0 Shared Services Administration Site 1033 False
PPSMASite#0 PerformancePoint 1033 False
BICenterSite#0 Business Intelligence Center 1033 False
SPS#0 SharePoint Portal Server Site 1033 False
SPSPERS#0 SharePoint Portal Server Personal Space 1033 False
SPSMSITE#0 Personalization Site 1033 False
SPSTOC#0 Contents area Template 1033 False
SPSTOPIC#0 Topic area template 1033 False
SPSNEWS#0 News Site 1033 False
CMSPUBLISHING#0 Publishing Site 1033 False
BLANKINTERNET#0 Publishing Site 1033 False
BLANKINTERNET#1 Press Releases Site 1033 False
BLANKINTERNET#2 Publishing Site with Workflow 1033 False
SPSNHOME#0 News Site 1033 False
SPSSITES#0 Site Directory 1033 False
SPSCOMMU#0 Community area template 1033 False
SPSREPORTCENTER#0 Report Center 1033 False
SPSPORTAL#0 Collaboration Portal 1033 False
SRCHCEN#0 Enterprise Search Center 1033 False
PROFILES#0 Profiles 1033 False
BLANKINTERNETCONTAINER#0 Publishing Portal 1033 False
SPSMSITEHOST#0 My Site Host 1033 False
ENTERWIKI#0 Enterprise Wiki 1033 False
SRCHCENTERLITE#0 Basic Search Center 1033 False
SRCHCENTERLITE#1 Basic Search Center 1033 False
SRCHCENTERFAST#0 FAST Search Center 1033 False
visprus#0 Visio Process Repository 1033 False

LocaleId’s other than 1033 (english) removed for clarity

, , ,

Leave a comment

Active Directory Tasks in C#

This is a great collection of codesamples regarding C# and Active Directory

Leave a comment

Setting the width of a MultipleLookupField control

When using a MultipleLookupField control in a webpart you can easily make the server create the select / deselect logic for you. The result of rendering a MultipleLookupField control will look something like this.


Unfortunately you haven’t got much control over how the control gets rendered and width properties aren’t easily changes. In this case the lookup values are too long and some of the text are therefore unreadable. Changing the width og the two listboxes (Select controls) should be proven rather difficult. However I came up with two different approaches. One where you do it by javascript and one where you can do it server-side in the webpart code.

Clientside approach:

You need to know the select element id for this one so it isn’t really all that useful unless you use something like a Content editor webpart to hold the script. But if you have the problem on just one specific page it can be an easy solution that doesn’t require any coding.

The javascript goes something like this

var Cand = document.getElementById(‘ctl00_m_g_5b989ee3_2686_4be0_be92_248cf98a2c16_RESEmneLU_ctl00_SelectCandidate’); = “300px”; = “300px”;
var Result = document.getElementById(‘ctl00_m_g_5b989ee3_2686_4be0_be92_248cf98a2c16_RESEmneLU_ctl00_SelectResult’); = “300px”; = “300px”;

The rendered MultipleLookupControl automatically gets two HTML select controls (SelectCandidates that holds the candidate values and SelectResult that holds the selected values). You simply changes the width of these two controls and their parent divs. You should of course replace the id’s (ctl00_m_g_5b989ee3_2686_4be0_be92_248cf98a2c16_RESEmneLU_ctl00_SelectCandidate) with your own. Find then by viewing the sourcecode in your browser

Serverside apporach:

The server-side approach is really doing the same just without having the add any Content Editor webparts and without having to know the rendered clientid. All sharepoint controls are initially inherited from the basic Control Class (System.Web.UI.Control) which have the property ClientID that represents the rendered clientID that we had to know with the Clientside approach.

The code for the client side could look something like this

        protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)

        private string AddJavascript(string clientID)
            string s = “”;
            s += “”;
            s += “<script>\n”;
            s += string.Format(“var Cand = document.getElementById(‘{0}_ctl00_SelectCandidate’);\n”, clientID);
            s += “ = ‘300px’;\n”;
            s += “ = ‘300px’;\n”;
            s += string.Format(“var Result = document.getElementById(‘{0}_ctl00_SelectResult’);\n”, clientID);
            s += “ = ‘300px’;\n”;
            s += “ = ‘300px’;\n”;
            s += “</script>”;
            return s;

You can then change the new width values or pass it along the method call to AddJavascript as a parameter.

Regardless of the approach you select the end result should look like this

By the way – You can use the MultipleLookUpField in both a PageLayout and a custom webpart.

In a pagelayout the control could look something like this: <SharePointWebControls:MultipleLookupField runat=”server” id=”MainAreasField” FieldName=”MainAreas”/>
In a webpart the control could look something like this (Placed in the CreateChildControls section): 
                MultipleLookupField MainAreasLookup = new MultipleLookupField();
                MainAreasLookup.ID = “MainAreasLU”;
                MainAreasLookup.ListId = SubscriptionList.ID;
                MainAreasLookup.FieldName = “MainAreas”;
                MainAreasLookup.ControlMode = SPControlMode.Edit;
                MainAreasLookup.ItemId = SubscriptionID;

Good luck.

, ,

Leave a comment