DisableLoopbackCheck – FTW (SharePoint Alternate Access Mapping, Access Denied – Solved)

While configuring my local alternate access mappings in my local SharePoint workspace, I was unable to connect to the newly created site through the AAM url (i.e. http://foo.bar.com).  The solution is to create a DWORD registry key called “DisableLoopbackCheck” with a value of “1” here:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa

This will allow you to create AAMs based on host names to the local server.

http://www.harbar.net/archive/2009/07/02/disableloopbackcheck-amp-sharepoint-what-every-admin-and-developer-should-know.aspx

Boom.  Now on to solve the actual problem I’m working on 🙂

Symptoms:
Alternate Access Mapping – 401.1, unable to authenticate to new AAM site, Access Denied on new AAM configuration

SharePoint_Config database marked as suspect — Solution

Recently, my SharePoint_Config database was marked as suspect.  Yikes!  Had to run the following to fix it:

Use Master
EXEC sp_resetstatus ‘SharePoint_Config’

ALTER DATABASE SharePoint_Config SET EMERGENCY DBCC checkdb(‘SharePoint_Config’)

ALTER DATABASE SharePoint_Config SET SINGLE_USER WITH ROLLBACK IMMEDIATE DBCC CheckDB (‘SharePoint_Config’, REPAIR_ALLOW_DATA_LOSS)

ALTER DATABASE SharePoint_Config SET MULTI_USER EXEC sp_resetstatus ‘SharePoint_Config’
GO

Phew!

Also, I knew something was up when I saw the error “Cannot connect to configuration database” and “The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered.” when logging into SharePoint PowerShell.

SharePoint Ribbon Customization — object reference error: Microsoft.Web.CommandUI.RibbonRenderer.AllGroupsControlsTrimmed

Was getting this error all day:

System.NullReferenceException: Object reference not set to an instance of an object.    at Microsoft.Web.CommandUI.RibbonRenderer.AllGroupsControlsTrimmed(DataNode xn, RibbonRenderContext rrc)

And finally came across someone with an answer — you have to remove ALL COMMENTS from your CommandUIDefinition and CommandUIHandler

Never would have thought of that – hopefully helps someone else (or possibly Future Rich).

-Rich

SharePoint JavaScript Ribbon Events with jQuery

After hours of hacking away and searching – I finally asked google the right question and came by this gem for triggering SharePoint Ribbon events with jQuery.  Thanks dennispg!

Trigger an event whenever the SharePoint 2010 ribbon changes
http://spmonkeypoint.wordpress.com/2012/05/16/trigger-an-event-whenever-the-sharepoint-2010-ribbon-changes/

From his site: ”

// Fires ‘ribbontabselected’ every time the ribbon selection changes

ExecuteOrDelayUntilScriptLoaded(function () {
CUI.Ribbon.prototype.$L_old = CUI.Ribbon.prototype.$L;
CUI.Ribbon.prototype.$L = function () {
this.$L_old();
$(document).trigger(‘ribbontabselected’, [this.get_selectedTabCommand()]);
};
}, ‘cui.js’);

// Fires ‘ribbontabselected’ after the ribbon has been initialized after load
ExecuteOrDelayUntilScriptLoaded(function () {
var pm = SP.Ribbon.PageManager.get_instance();
pm.add_ribbonInited(function () {
$(document).trigger(‘ribbontabselected’, [SP.Ribbon.PageManager.get_instance().get_ribbon().get_selectedTabCommand()]);
});
}, ‘sp.ribbon.js’);

// Example code for binding to the event
$(document).on(‘ribbontabselected’, function (e, selectedTabCommand) {
if (selectedTabCommand != “ReadTab”) {
alert(selectedTabCommand);
}
}); ”

Trigger an event whenever the SharePoint 2010 ribbon changes

Attach SPEventReceiver to base Content Type

My awesome coworker discovered that you can get an Event Handler tied to a base Content Type if do it via code rather than declaratively (apparently it does not work when you do it declaratively).  I thought this was pretty sweet.

 

SPContentType ct = web.ContentTypes[“MyBaseContentType”];

SPEventReceiverDefinition addedDef = ct.EventReceivers.Add();

addedDef.Assembly = “Foo.BarNamespace, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=7dafd816eb0743e8”;

addedDef.Class = “Foo.BarNamespace.SPWEB.EventReceivers.BaseContentTypeEventRcvr.BaseContentTypeEventRcvr”;

addedDef.Name = “ItemAdded Event”;

addedDef.Type = SPEventReceiverType.ItemAdded;

addedDef.SequenceNumber = 1000;

addedDef.Synchronization = SPEventReceiverSynchronization.Synchronous;

addedDef.Update();

ct.Update(true);

SPEventReceiverDefinition updatedDef = ct.EventReceivers.Add();

updatedDef.Assembly = “Foo.BarNamespace, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=7dafd816eb0743e8”;

updatedDef.Class = “Foo.BarNamespace.SPWEB.EventReceivers.BaseContentTypeEventRcvr.BaseContentTypeEventRcvr”;

updatedDef.Name = “ItemUpdated Event”;

updatedDef.Type = SPEventReceiverType.ItemUpdated;

updatedDef.SequenceNumber = 1000;

updatedDef.Synchronization = SPEventReceiverSynchronization.Synchronous;

updatedDef.Update(); ct.Update(true);

Tanveer Khan’s SharePoint Blog: Error occurred in deployment step ‘Add Solution’: Cannot insert duplicate key row in object ‘dbo.Solutions’ with unique index ‘Solutions_BySiteAndSolutionId

This guy saved me from having to smash my computer out of frustration 🙂  Thanks!

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

While deploying a sandbox solution I encountered this error in VS 2010 .

” Error occurred in deployment step ‘Add Solution’: Cannot insert duplicate key row in object ‘dbo.Solutions’ with unique index ‘Solutions_BySiteAndSolutionId’.”

There was no problem whatsoever with the solution as I had deployed this solution multiple times on the site collection.On analysis I realised the only change i had done was”I had deleted a site and again recreated a site with the same name and url” and when i try and deploy after that, I got this error.

Resolution:

-Open the project properties and point the property Site URL to some other url and save it.

-Then, remove the url added in the above step and enter the URL of the site which was giving the error initially.(site where you actually want to deploy the sandbox solution.)

And it should work !!

Seems like VS 2010 caches the property and so when deploying the sanbox solution , it gives this error.

via Tanveer Khan’s SharePoint Blog: Error occurred in deployment step ‘Add Solution’: Cannot insert duplicate key row in object ‘dbo.Solutions’ with unique index ‘Solutions_BySiteAndSolutionId.

theAngryBadger: Sharepoint 2010: Caml with against Metadata/Taxonomy field

Sharepoint 2010: Caml with against Metadata/Taxonomy fieldThe below Caml is an example of how to use the <In> statement against the Metadata/Taxonomy field in a list:<Query>   <Where>    <In>    <FieldRef LookupId=TRUE Name=your taxonomy field internal name />    <Values>     <Value Type=Integer> your taxonomy field wssid </Value>    </Values>   </In>  </Where></Query>

via theAngryBadger: Sharepoint 2010: Caml with against Metadata/Taxonomy field.

Enabling Hidden Features in SharePoint 2010

Learned this while reading an article on enabling Managed Metadata.

useful this will be one day, young sharepoint jedi…

“As a side note, when you read about features that aren’t showing in your UI, and you want to track them down, head on over to your SharePoint feature directory, which is typically:C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURESFind the subfolder for the feature you are interested in, and find the Feature.xml file within. Open it with a text reader, copy the ID for the feature, and plug it into the commands above. Run it and you’ll be able to install any of the hidden features.Hopefully this will save someone else a major search hassle.”

via SharePoint 2010: Enabling Managed Metadata features « Blah-de-blah-blog.