Showing posts with label sharepoint. Show all posts
Showing posts with label sharepoint. Show all posts

Thursday, August 18, 2011

Fun with SharePoint and PowerShell: Part 1 of ?

I gave a session at SharePoint Saturday the Conference in DC last weekend called “Applied PowerShell: PowerShell for the SharePoint Server Admin”. (I know it is an annoyingly long name, but I’m not really that creative.) The session basically consisted of me talking about and demonstrating a bunch of really cool things I had learned to do with PowerShell as it pertained to SharePoint.

I’ve been meaning to write a blog post with all of the slides and scripts that I showed during the session but it is an overwhelming large amount of content and I keep putting it off. So, I have decided to meet you (my imaginary reader) half way and do it over the course of several blog posts.

This is not a planned series and I have no idea how may parts there will be. But hey, I know this is part 1. Smile

Script 1: Applying a Theme to One or More Sites/Webs

Disclaimer for those who actually attended fore mentioned session: No, this wasn’t actually covered. Deal with it. Smile with tongue out

Let me start by saying that I don’t really like themes in SharePoint. I work for a company (http://www.northridge.com) that has a design team in house and makes really cool master pages and so I prefer not to resort to themes. However, sometimes you are stuck with OOTB and I get that. If you happen to be stuck with OOTB, themes got much cooler with SharePoint 2010. You can actually take a PowerShell theme and upload it to the Theme Gallery and apply it to your site.

This is because SharePoint 2010 now uses .thmx files for it’s themes. To prove my point see screen shots below:

image image

SharePoint 2010

PowerPoint 2010

I know what you’re thinking, “But Craig, I already knew all of that where is the script?!?!”. Well, it is important to understand that if you are going to do a custom them (not one of the ones that come OOTB) then you will need a THMX file to apply. So lets fast forward and assume you already have a THMX file and you want to apply that to your site(s).

There are two basic steps: add the THMX file to the Theme Gallery, and set the web to use said theme.

Step 1: Add the Theme to the Theme Gallery

This step is pretty straight forward. We just need to add a file to the gallery. I’ve written a simple function that is generic and adds a file from the file system to a specified document library within a given web. Let’s take a look:

function Add-SPFileToLibrary
{
param
(
[String] $file,
[Microsoft.SharePoint.SPWeb] $web,
[String] $LibraryName
)
$lib = $web.GetFolder($LibraryName)

# Prepare to upload
$replaceExistingFiles = $true
$fileName = [System.IO.Path]::GetFileName($file)
$fileStream = [System.IO.File]::OpenRead($file)

# Upload document
$spfile = $lib.Files.Add($fileName, $fileStream, $replaceExistingFiles);

# Commit
$lib.Update();
}




Cool! So, I just need to know what the library’s name is and then I should be good to go. Let’s take a look at the library’s that are provisioned by default in a web.







image


Hmm… that doesn’t seem to have what I need. Nothing that says theme at least. Lets take a look at all of the lists that get provisioned by default.








image



Ah ha! “Theme Gallery” looks like what I want. Lets investigate further!







image


Now we are making progress! From this I can see that the folder I am looking for is “_catalogs/theme”. Ok, let’s put it all together.




$site = Get-SPSite "http://nr01-crtru-lt01/"
Add-SPFileToLibrary -file "C:\Themes\MyNewTheme.thmx" -LibraryName "_catalogs/theme" -web $site.RootWeb
$site.Dispose()



A couple things to note about this. 1) The gallery only exists at the RootWeb of a site collection. 2) Always dispose of instantiated SPSite and SPWeb objects!



Ok, now the theme has been uploaded but it is still not applied to the site. Let’s do something about that.



Step 2: Apply the Theme


In the UI this is really easy. You go to Site Settings, click on Site Theme, choose your theme, and apply. In PowerShell the answer is not so obvious. If you do a little exploring with the Get-Member you may come across $web.Theme and think this is your answer. But alas, this is not the case. The theme property on SPWeb is actually a leftover from v3 themes from 2007. Definitely NOT what we want.



After some digging around on MSDN I ran across Microsoft.SharePoint.Utilities.ThmxTheme. This little utility class gives us access to serveral functions that when put together give us what we are looking for. I’ll spare you the painful iterations of getting to where we want to be and just give you the script.




# Get a collection of available themes
$managedThemes = [Microsoft.SharePoint.Utilities.ThmxTheme]::GetManagedThemes($site)

# Get my new theme
$theme = $managedThemes | Where-Object {$_.Name -eq "My New Theme"}

# Apply theme to root web
$theme.ApplyTo($site.RootWeb,$true)



Awesome! That applies it to the RootWeb but what about all my lonely sub webs that didn’t get it. Well, you can use this nifty trick to set them all to “inherit” the theme from their parent site.




# Loop through each web in the site
foreach ($web in $site.AllWebs)
{
# Make sure it is not the root web
if (-not $web.isRootWeb)
{
# Set sub webs to inherit from root
[Microsoft.SharePoint.Utilities.ThmxTheme]::SetThemeUrlForWeb($web,[Microsoft.SharePoint.Utilities.ThmxTheme]::GetThemeUrlForWeb($site.RootWeb))
}
$web.Dispose()
}
$site.Dispose()



Ok, that does it. Let’s put it all together so we can use it over and over again!




# Adds a file to given library
function Add-SPFileToLibrary
{
param
(
[String] $file,
[Microsoft.SharePoint.SPWeb] $web,
[String] $LibraryName
)
$lib = $web.GetFolder($LibraryName)

# Prepare to upload
$replaceExistingFiles = $true
$fileName = [System.IO.Path]::GetFileName($file)
$fileStream = [System.IO.File]::OpenRead($file)

# Upload document
$spfile = $lib.Files.Add($fileName, $fileStream, $replaceExistingFiles);

# Commit
$lib.Update();
}

# Applys a theme to an entire site collection
function Update-SPSiteTheme
{
param
(
$Path,
$Name,
$Site
)
# Add the theme to the Theme Gallery
Add-SPFileToLibrary -file $Path -LibraryName "_catalogs/theme" -web $site.RootWeb
# Get a collection of available themes
$managedThemes = [Microsoft.SharePoint.Utilities.ThmxTheme]::GetManagedThemes($site)
# Get my new theme
$theme = $managedThemes | Where-Object {$_.Name -eq $Name}
# Apply theme to root web
$theme.ApplyTo($site.RootWeb,$true)
# Loop through each web in the site
foreach ($web in $site.AllWebs)
{
# Make sure it is not the root web
if (-not $web.isRootWeb)
{
# Set sub webs to inherit from root
[Microsoft.SharePoint.Utilities.ThmxTheme]::SetThemeUrlForWeb($web,[Microsoft.SharePoint.Utilities.ThmxTheme]::GetThemeUrlForWeb($site.RootWeb),$true)
}
$web.Dispose()
}
$site.Dispose()
}



Obviously the function needs some work (error handling, comment based help, etc.) but it should get the job done. Give it a try and let me know what you think.



Enjoy!

Wednesday, August 10, 2011

SharePoint Saturday The Conference – SharePoint and PowerShell unite!

This weekend SharePointers aplenty will converge on our nations capitol for three days SharePointy goodness. I fly out here in a couple hours to join them!

I had planned to write up a longer more descriptive post about the sessions I will be giving and why you should come see them but alas I was too busy making last minute updates to my demo VMs to really do them justice. Instead you get this.

Below are the agenda slides from my two sessions. I hope you will come out and learn the joys of SharePoint!

Taming the Beast: A SharePoint Survival Guide for the Server Admin

SPSTCDC_Taming_The_Beast

Applied PowerShell: PowerShell for the SharePoint Server Admin

SPSTCDC_Applied_PowerShell

Full schedule can be found here: http://www.spstc.org/blog/Lists/Posts/Post.aspx?ID=38

Saturday, May 14, 2011

Microsoft Tags = Really freaking cool!

So, I am headed to TechEd  this week and they are having a scavenger hunt with Microsoft Tags. I had seen the app in the Windows Phone marketplace but had not actually taken a look at it. I must say I’m really impressed.

If you are going to be in Atlanta for TechEd grab the free Microsoft Tag from here and join me in the scavenger hunt.

Once you have grabbed you can test it on the Tag below.

CraigToThePointTag

Have fun and if you are going to be there give me a shout!

PowerShell to remove web parts with errors from SharePoint 2010

One of the things that I run into whenever I do an upgrade from an older version of SharePoint to SharePoint 2010 is that not all of the custom functionality previously implemented still works. This is especially true when moving from WSS 2.0 to SharePoint 2010.

When a client has 50+ sites and these web parts are on every landing page the process of removing them manually is just out of the questions. So how do we solve this?

Well, in SharePoint 2007 I would have said that you should go bug a developer and have them write you a console application to loop through and remove any and all erroring web parts. However, in SharePoint 2010 the story is slightly different.

PowerShell to the rescue!!!

function Remove-SPErroringWebParts
{
[CmdletBinding()]

param
(
[parameter(ValueFromPipeline=$true,Mandatory=$true,Position=0)]
$Web
)

begin
{
Out-Host -InputObject "Beginning Remove-SPErroringWebParts..."
}

process
{
if ($Web -is [string]) {Out-Host -InputObject " This is a string.";$Web = Get-SPWeb $Web}
if ($Web -is [Microsoft.SharePoint.Administration.SPWebApplication]) {Out-Host -InputObject " This is a web app.";$Web = Get-SPSite -WebApplication $Web -Limit All -Confirm:$false}
if ($Web -is [Microsoft.SharePoint.SPSite[]]) {Out-Host -InputObject " This is an array of sites.";$Web | %{Set-AllBackToSiteDefinition -Web $_}}
if ($Web -is [Microsoft.SharePoint.SPSite] ) {Out-Host -InputObject " This is a site.";$Web = (Get-SPWeb -Site $Web -Limit All -Confirm:$false)}
if ($Web -is [array]) {" This is an array."; $Web | %{ Remove-SPErroringWebParts $_ } }
if ($Web -is [microsoft.SharePoint.SPWeb])
{
Out-Host -InputObject " This is a web."
$webpartmanager = $Web.GetLimitedWebPartManager(($Web.Url + "/default.aspx"), [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)

#Create a separate list of webparts to be deleted to avoid enumeration error
$webpartsToDelete = $webpartmanager.WebParts | ?{$_.ErrorMessage -ne $null}

foreach ($webpart in $webpartsToDelete)
{
if ($webpart.ErrorMessage -ne $null)
{
Out-Host -InputObject " Deleting webpart.."
$webpartmanager.DeleteWebPart($webpart)
}
}
$Web.Dispose()
}
}

end
{
Out-Host -InputObject "Finished Remove-SPErroringWebParts."
}
}



The function above looks far more complicated than it really is. I wrote it so that I could save it off and use it for later projects. To be honest, this function isn’t really done as I need to add a great deal of error handling, it only checks the “/default.aspx” page so if you have Publishing sites or even sites that use the Wiki Home Page it will not work, and there is some Out-Host commands that will most likely be changed to Out-Debug. However, I digress. Writing PowerShell for reusability is a completely different discussion that I will probably write about at a later date. Until then there are a couple really great blog posts you can check out if you are interested:




For now, lets take a look at what a more minimalistic approach would be.




$Web = Get-SPWeb "http://site/web"
$webpartmanager = $Web.GetLimitedWebPartManager(($Web.Url + "/default.aspx"), [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
$webpartsToDelete = $webpartmanager.WebParts | ?{$_.ErrorMessage -ne $null}
foreach ($webpart in $webpartsToDelete)
{
if ($webpart.ErrorMessage -ne $null)
{
Out-Host -InputObject " Deleting webpart.."
$webpartmanager.DeleteWebPart($webpart)
}
}
$Web.Dispose()



Much less code there but less power as well. This will obviously only work on an SPWeb object and the code would need to be adjusted for any other scope. Let’s take a look at the usage of the original function.

On an SPWeb object:




Get-SPWeb "http://server/site/web" | Remove-SPErroringWebParts


On an SPSite object:


Get-SPSite "http://server/site" | Remove-SPErroringWebParts


On an SPWebApplication object:


Get-SPWebApplication "http://server" | Remove-SPErroringWebParts


Or on an string:


"http://server/site/web" | Remove-SPErroringWebParts





Either way the function will loop through all of the “/default.aspx” pages on the SPWeb objects of the given scope and remove any web parts that have errors.

I’m sure I don’t have to tell you that this can be just as dangerous as it is helpful if you have web parts that are erroring that you are not aware of. As always use caution and I’m not responsible for anything you break while using anything you find here. Smile


I hope this helps! Any and all feedback is welcomed and appreciated. Let me know what you think!

Friday, May 13, 2011

Sign on as different user to SharePoint 2010 site published through TMG 2010

As of Service Pack 1, TMG now officially supports publishing SharePoint 2010 sites. If you have tried this you may have ran into an issue when trying to use the “Sign in as Different User” functionality. Fortunately Microsoft has released an update that resolves the issue.

http://support.microsoft.com/kb/2445386

The update is included in Software Update 1 rollup 3 for TMG SP1. This rollup can be found here:

http://support.microsoft.com/kb/2498770

However, just having applied the rollup does not solve the issue.  You will also need to run one of the following scripts on one of your TMG front ends.

For HTML Forms Authentication with Kerberos Constrained Delegation:

Const SE_VPS_GUID = "{143F5698-103B-12D4-FF34-1F34767DEabc}"
Const SE_VPS_NAME = "EnableSharepointSignIn"
Const SE_VPS_VALUE = true

Sub SetValue()

' Create the root object.
Dim root ' The FPCLib.FPC root object
Set root = CreateObject("FPC.Root")

'Declare the other objects that are needed.
Dim array ' An FPCArray object
Dim VendorSets ' An FPCVendorParametersSets collection
Dim VendorSet ' An FPCVendorParametersSet object

' Get references to the array object
' and to the network rules collection.
Set array = root.GetContainingArray
Set VendorSets = array.VendorParametersSets

On Error Resume Next
Set VendorSet = VendorSets.Item( SE_VPS_GUID )

If Err.Number <> 0 Then
Err.Clear

' Add the item.
Set VendorSet = VendorSets.Add( SE_VPS_GUID )
CheckError
WScript.Echo "New VendorSet added... " & VendorSet.Name

Else
WScript.Echo "Existing VendorSet found... value- " & VendorSet.Value(SE_VPS_NAME)
End If

if VendorSet.Value(SE_VPS_NAME) <> SE_VPS_VALUE Then

Err.Clear
VendorSet.Value(SE_VPS_NAME) = SE_VPS_VALUE

If Err.Number <> 0 Then
CheckError
Else
VendorSets.Save false, true
CheckError

If Err.Number = 0 Then
WScript.Echo "Done with " & SE_VPS_NAME & ", saved!"
End If
End If
Else
WScript.Echo "Done with " & SE_VPS_NAME & ", no change!"
End If

End Sub

Sub CheckError()

If Err.Number <> 0 Then
WScript.Echo "An error occurred: 0x" & Hex(Err.Number) & " " & Err.Description
Err.Clear
End If

End Sub

SetValue





For Integrated Authentication with Kerberos Constrained Delegation: You will need to run the script above as well as the script below.




Const SE_VPS_GUID = "{143F5698-103B-12D4-FF34-1F34767DEabc}"
Const SE_VPS_NAME = "UseOnlyNTLMForWindowsAuth"
Const SE_VPS_VALUE = 1

Sub SetValue()

' Create the root object.
Dim root ' The FPCLib.FPC root object
Set root = CreateObject("FPC.Root")

'Declare the other objects that are needed.
Dim array ' An FPCArray object
Dim VendorSets ' An FPCVendorParametersSets collection
Dim VendorSet ' An FPCVendorParametersSet object

' Get references to the array object
' and to the network rules collection.
Set array = root.GetContainingArray
Set VendorSets = array.VendorParametersSets

On Error Resume Next
Set VendorSet = VendorSets.Item( SE_VPS_GUID )

If Err.Number <> 0 Then
Err.Clear

' Add the item.
Set VendorSet = VendorSets.Add( SE_VPS_GUID )
CheckError
WScript.Echo "New VendorSet added... " & VendorSet.Name

Else
WScript.Echo "Existing VendorSet found... value- " & VendorSet.Value(SE_VPS_NAME)
End If

if VendorSet.Value(SE_VPS_NAME) <> SE_VPS_VALUE Then

Err.Clear
VendorSet.Value(SE_VPS_NAME) = SE_VPS_VALUE

If Err.Number <> 0 Then
CheckError
Else
VendorSets.Save false, true
CheckError

If Err.Number = 0 Then
WScript.Echo "Done with " & SE_VPS_NAME & ", saved!"
End If
End If
Else
WScript.Echo "Done with " & SE_VPS_NAME & ", no change!"
End If

End Sub

Sub CheckError()

If Err.Number <> 0 Then
WScript.Echo "An error occurred: 0x" & Hex(Err.Number) & " " & Err.Description
Err.Clear
End If

End Sub

SetValue





Once this is complete you should be able to Log in as a Different User to your hearts content.



I hope this helps!

Thursday, October 29, 2009

WSS and MOSS October CU Released

The October cumulative update for WSS 3.0 and MOSS 2007 has been released yesterday here are the KB article links for these fixes:

The fixes can be downloaded using the following links:

Monday, October 19, 2009

SharePoint 2010 – And the Downloadable Content keeps coming!!!

The content keeps trickling in. Microsoft has been releasing posters all day, (http://ctrulove.blogspot.com/2009/10/sharepoint-2010-posters-for-everyone.html) but wait, there’s more!

More POSTERS!!!!

SharePoint 2010- SharePoint Developer Platform Wall Poster - The SharePoint 2010 Developer Platform wall poster (PDF format) shows a view of the SharePoint 2010 developer tools, community ecosystem, execution environment, SharePoint Server 2010 workloads, and target application types. The poster is intended to be printed at 24 inches x 36 inches (61 centimeters x 91 centimeters).

SharePoint 2010- Developer Platform White Paper - This white paper provides an overview of the SharePoint 2010 Developer Platform for ASP.NET developers.

Enterprise Search Planning for SharePoint Server 2010 - This model describes primary architecture design decisions for search environments.

Design Search for SharePoint Server 2010 - This model describes the steps to determine a basic design for a SharePoint Server 2010 search architecture.

SharePoint Server 2010 Search Architecture - This model describes the physical and logical architecture components of the search system.

 

Learning and Evaluation Stuff Too!!!

SharePoint 2010- Getting Started with Development on SharePoint 2010- Hands on Labs in C# and Visual Basic - Use these 10 hands-on lab manuals for SharePoint 2010 to get started learning SharePoint 2010 development.

SharePoint 2010- Developer and IT Professional Learning Plan - This document provides information to help developers and IT professionals learn Microsoft SharePoint 2010.

SharePoint 2010- Professional Developer Evaluation Guide and Walkthroughs - The SharePoint 2010 developer evaluation guide describes the SharePoint 2010 developer platform, including walkthroughs of some of the new capabilities for developers.

SharePoint Server 2010 Evaluation Guide - Introduction and overview of SharePoint Server 2010 for IT pros.

I am sure there is more to come. Enjoy!

SharePoint 2010 and PowerShell

Great reference posted by Dmitry Sotnikov. 467 cmdlets!!!

http://dmitrysotnikov.wordpress.com/2009/10/19/sharepoint-2010-cmdlet-reference/

SharePoint 2010 Posters for Everyone!

Microsoft has apparently decided that posters are the way to go. In tandem with the start of the SharePoint Conference Keynote starting a deluge of SharePoint 2010 posters were released to http://download.microsoft.com. Below you can find them all for your viewing pleasure:

Services in SharePoint Products 2010 - Describes and illustrates the services architecture, including and common ways to deploy services in your overall solution design.

Hosting Environments for SharePoint 2010 Products - Summarizes the support for hosting environments and illustrates common hosting architectures.

Business Connectivity Services poster - Microsoft Business Connectivity Services enable users to interact with external data by using SharePoint lists and Microsoft Office 2010.

Topologies for SharePoint Server 2010 - Describes common ways to build and scale farm topologies, including planning which servers to start services on.

Cross-farm Services in SharePoint 2010 Products - Illustrates how to deploy services across farms to provide centralized administration of services.

SharePoint Enterprise Search - Compares and contrasts search technologies in SharePoint 2010 Products

Upgrade planning poster - Describes requirements and considerations for planning to upgrade to SharePoint Server 2010

Upgrade approaches poster - This model describes the three basic approaches to upgrading to SharePoint Server 2010: in-place, database attach, or a hybrid of the two.

Upgrade testing poster - To help ensure a smooth transition to SharePoint Server 2010, perform a trial upgrade to find issues likely to surface during the actual process.

Upgrading services poster - You need to give special consideration to the issues involved when you upgrade services from the previous version of SharePoint Server

Getting started with BI in SharePoint Server 2010 - Discusses the business intelligence tools available in SharePoint Server 2010

Enjoy!

SharePoint 2010 Upgrade Posters Now Available!

Just hours before the SharePoint Conference in Vegas, new content is already arriving out on http://download.microsoft.com. You can now get 4 posters that provide a lot of insight into the 2007 to 2010 upgrade process. And here they are:

Upgrade approaches poster - This model describes the three basic approaches to upgrading to SharePoint Server 2010: in-place, database attach, or a hybrid of the two.

Upgrading services poster - You need to give special consideration to the issues involved when you upgrade services from the previous version of SharePoint Server.

Upgrade planning poster - Describes requirements and considerations for planning to upgrade to SharePoint Server 2010.

Upgrade testing poster - To help ensure a smooth transition to SharePoint Server 2010, perform a trial upgrade to find issues likely to surface during the actual process.

Enjoy!

Thursday, October 1, 2009

SharePoint August CU re-released

You may have read that there was an issue with the previously released version of the WSS August CU. Well, Microsoft has now released a new version of the update that appears to not have the same problem.

You can find all the information here: http://blogs.msdn.com/joerg_sinemus/archive/2009/10/01/new-build-available-for-august-cu.aspx

Friday, September 18, 2009

What version of SharePoint am I running?

There is a very useful post by Penny Coventry, author of Office SharePoint Designer 2007 Step By Step, on the books website. It allows you to translate the SharePoint version number to the actual patches that have been applied.

http://www.sharepointdesignerstepbystep.com/Blog/Articles/How%20To%20find%20the%20SharePoint%20version.aspx

Thanks Penny!

WSS and MOSS August CU Issue

You may have heard that the WSS 3.0 and MOSS 2007 August CU is now available. It is, and can be found here:

WSS:

973400 The full server package for WSS
http://support.microsoft.com/default.aspx?scid=kb;EN-US;973400

MOSS:

973399 The full server package for MOSS
http://support.microsoft.com/default.aspx?scid=kb;EN-US;973399

However, there is an issue with the update that causes you not to be able to attach databases of earlier versions. This means that if you are doing an upgrade or server migration you should not install this update on the destination server unless it has already been applied to the incoming content databases.

Microsoft’s current solution is as follows:

    • Attach your databases on a June CU SharePoint Installation. My recommended environment would be Hyper-V and using snapshots.
    • Upgrade to August CU. Remember that you can run PSCONFIG from command-line more than one time if timeout or others happened.
    • Detach the databases.
    • The databases are now on August CU level and a re-attach to an already patched SharePoint installation with August CU should work.

Thursday, August 6, 2009

401.1 Error When Accessing SharePoint From Server

If you are running SharePoint Server 2007 or WSS 3.0 on  Windows Server 2003 SP1 or later you will run into authentication issues if you are trying to access a SharePoint site using host headers from the server itself (i.e. host file has portal.mydomain.com pointed to 127.0.0.1).  This issue manifests itself as the result of a loop back security check that Microsoft built in to Windows Server 2003 SP1 and later.  The purpose of the loopback check is to eliminate denial of service attacks however it causes issues with access SharePoint sites locally from the server.  In a typical production environment this is typically not a problem since you rarely access SharePoint sites (besides central admin) from  a front end web server itself.

You can read the detailed KB article at http://support.microsoft.com/kb/926642 & http://support.microsoft.com/kb/896861.

Here is a rundown of how to fix the problem.   I typically disable the loopback check in development scenarios; however, this is not recommended for production server environments.

Method 1: Disable the authentication loopback check
Re-enable the behavior that exists in Windows Server 2003 by setting the DisableLoopbackCheck registry entry in the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa registry subkey to 1. To set the DisableLoopbackCheck registry entry to 1, follow these steps on the client computer:

1. Click Start, click Run, type regedit, and then click OK. 

2. Locate and then click the following registry subkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa

3. Right-click Lsa, point to New, and then click DWORD Value. 

4. Type DisableLoopbackCheck, and then press ENTER. 

5. Right-click DisableLoopbackCheck, and then click Modify.

6. In the Value data box, type 1, and then click OK. 

7. Exit Registry Editor.

8. Restart the computer.

Note: You must restart the server for this change to take effect. By default, loopback check functionality is turned on in Windows Server 2003 SP1, and the DisableLoopbackCheck registry entry is set to 0 (zero). The security is reduced when you disable the authentication loopback check, and you open the Windows Server 2003 server for man-in-the-middle (MITM) attacks on NTLM.

Method 2: Create the Local Security Authority host names that can be referenced in an NTLM authentication request
To do this, follow these steps for all the nodes on the client computer:

1. Click Start, click Run, type regedit, and then click OK. 

2. Locate and then click the following registry subkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0

3. Right-click MSV1_0, point to New, and then click Multi-String Value

4. In the Name column, type BackConnectionHostNames, and then press ENTER. 

5. Right-click BackConnectionHostNames, and then click Modify. 

6. In the Value data box, type the CNAME or the DNS alias, that is used for the local shares on the computer, and then click OK.

Note: Type each host name on a separate line.

Note: If the BackConnectionHostNames registry entry exists as a REG_DWORD type, you have to delete the BackConnectionHostNames registry entry.

7. Exit Registry Editor, and then restart the computer.

Thursday, July 23, 2009

Windows SharePoint Services 3 Search Event ID 2436

I was combing through the event logs on a server I set up recently when I ran across an Warning event occurring exactly every hour.

Log Name:      Application
Source:        Windows SharePoint Services 3 Search
Date:          7/22/2009 6:34:03 PM
Event ID:      2436
Task Category: Gatherer
Level:         Warning
Keywords:      Classic
User:          N/A
Computer:      server.domain.com
Description:
The start address <sts3://SSP_URL/contentdbid={GUID}> cannot be crawled.

Context: Application 'Search index file on the search server', Catalog 'Search'

Details:
    The object was not found.   (0x80041201)

After much research to no avail I had almost given up and decided it didn’t actually matter as there was nothing in the SSP that I actually needed to search. However, it finally dawned on me that the issue was that there was no root site for the SSP Web Application, just the /ssp/admin. I created an empty root and the issue immediately went away.

Also, I slept much better knowing that my event logs were nice and clean. :-)

Tuesday, July 21, 2009

Web Part Management

There are times we want to manage Web parts on a SharePoint page but could not use "Edit Page" option, such as unhandled exception occurs in code and an error page is shown. In this case we normally use the Web part management page. SharePoint usually provides this link on the error page, but sometimes doesn't. So remembering the page will be helpful.

This is an application page called SPContnt.aspx. It takes one parameter url in the query string. So It would look something like

http://server/site/_layouts/spcontnt.aspx?url=http://server/site/default.aspx

This brings you to a page that will allow you to Close, Reset, and Delete Web Parts from the page.


Saturday, June 13, 2009

Rebuilding System Databases (/cry)

So, I spent about 4 hours between last night and this morning troubleshooting an issue with one of my SharePoint machines. The master SQL database had somehow become corrupted and the service would not start. When you attempt to start it you get the following error in the event log:

Event Type: Information
Event Source: MSSQLSERVER
Event Category: (2)
Event ID: 3417
Date: 6/18/2008
Time: 5:19:25 PM
User: N/A
Computer: SERVER_NAME
Description:
Cannot recover the master database. SQL Server is unable to run. Restore master from a full backup, repair it, or rebuild it. For more information about how to rebuild the master database, see SQL Server Books Online.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Data:
0000: 59 0d 00 00 0a 00 00 00 Y.......
0008: 0d 00 00 00 41 00 54 00 ....A.T.
0010: 4c 00 53 00 50 00 53 00 L.S.P.S.
0018: 44 00 30 00 31 00 56 00 D.0.1.V.
0020: 30 00 34 00 00 00 00 00 0.4.....
0028: 00 00
..

In order to repair the master database I had to invoke the setup.exe from the install disk from the command line. The syntax to do this is as follows:

start /wait \sqlfoder\setup.exe /qb INSTANCENAME=[instance] REINSTALL=SQL_Engine REBUILDDATABASE=1 SAPWD=[strong_password]

The only issue with this is that if you have installed any of the service packs (which you should have) then that statement gives you the following error:

Installation package for the product SQL Server 2005 (64bit) cannot be found. Please locate a valid SQLRUN_SQL.MSI

After some searching I found the solution and it is to first run this command:

\sqlfoder\setup.exe /qb INSTANCENAME=myinstance REINSTALL=SQL_Engine REINSTALLMODE=v

After that succeeds you can run the normal rebuild database command listed above and it will succeed as well.

Now all you have to do is reattach all of your databases and you are good to go!