Client machine making thousands of calls to SharePoint sites

——- Still researching this topic ——

Randomly each day, my computer was making thousands of calls to a couple SharePoint sites.  Using Fiddler, I could see that the calls were being made through WebDav.

User-Agent: Microsoft-WebDAV-MiniRedir/6.1.7601

Then I notice that the first call of the batch was always to this web service:

/_vti_bin/publishedlinksservice.asmx

Googled around and found this post.  It’s related to SP2007 but it helped to find the answer.

http://blogs.msdn.com/b/jorman/archive/2009/07/30/my-sharepoint-sites-memberships-general-overview-on-how-this-functionality-works.aspx

After reading the post, I opened Word, clicked on File –>Save and Send –> Save to SharePoint.  There it was, all of the sites that my computer was reaching out to every day.  Taking things one more step deeper, I opened a document library, selected the Library tab in the ribbon, then selected Connect to Office.  From there select Manage SharePoint Sites.  Displayed was listed the libraries that I had created connections to.

http://mysite.yourdomain.com/_layouts/MyQuickLinks.aspx

All of the sites that are displayed in the Save to SharePoint section of Office are stored here:

HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Common\Server Links\Published\My Site\

I deleted the My Site folder, opened Word and all of the sites were cleared out.

Also cleared out the following folder:

HKEY_Current_User\Software\Microsoft\Office\14.0\Common\Portal\Link Providers\

Next I need to make sure the folder doesn’t get repopulated with random sites!

Count the number of columns that contain a value

Say you have three columns that you want to find if a value exists in, then count the columns that contain that string.

In my list, I created three columns.

cOne, cTwo, cThree

All have a field type of single line of text.

Then I created a calculated column named cCalc.

The formula for cCalc is:

=COUNT(FIND(“Taco”,cOne),FIND(“Taco”,cTwo),FIND(“Taco”,cThree))

In my formula, I’m searching each field for the word Taco.  Keep an eye on your case usage.  Taco is not the same as taco.

Find function:

http://office.microsoft.com/en-us/sharepoint-server-help/find-function-HA001160996.aspx

Count function:

http://office.microsoft.com/en-us/windows-sharepoint-services-help/count-function-HA001160977.aspx

Office SharePoint Server Standard Site features must be enabled

In SharePoint Designer 2010, I was attempting to create an approval task for an item.  When I tried to added the action to the workflow, I received the following error.

Cannot insert this action. To use task process actions, the Office SharePoint Server Standard Site features must be enabled for this site by an administrator.

At the site and site collection I made sure SharePoint Server Standard Site features was enabled.  Taking it one step further, I also enabled SharePoint Server Enterprise Site features.  Still the workflow wasn’t working correctly.  Navigated back to the site collection features and activated the Workflows feature.  Refreshed SharePoint Designer and all of the actions worked.

Credit goes to Giles Hamson.

http://spandps.com/2012/04/03/spd-2010-cannot-insert-this-action-sp2010-sharepoint-ps2010-msproject-projectserver-in/

Does creating a folder start a workflow?

Does creating a folder cause a workflow to run?

Yes, when you create a folder, SharePoint treats it like you are uploading a new document.

If you only want to run a workflow on documents that are created or changed, you will need to add a step to your workflow.

The workflow condition would be:

If Current Item: Content Type equals Folder

Stop workflow

Doing this will stop the workflow each time a folder is added or changed.

 

Update users display name in SharePoint

The script below will allow you to change a users display name in SharePoint.


# add SharePoint snap-in if needed

 	$ntName = "domain\XXX"
	$displayName = "New Name"
 	$webApp = "http://webapp.sharepointed.com/"
	$user = Get-SPUser -web $webApp -Identity $ntName
	
	Get-SPWebApplication $webApp | Get-SPSite -Limit ALL | Get-SPWeb -Limit ALL | ForEach-Object {
		Set-SPUser -Identity $user -DisplayName $displayName -Web $_.URL
	}

SharePoint Specified cast is not valid

SharePoint pages were not loading on one server in our farm after doing a registry updated.

http://msdn.microsoft.com/en-us/library/aa973248.aspx

Turned out that a Key value was incorrectly set. Once the Key value was fixed, pages started loading.

Server Error in ‘/’ Application.
——————————————————————————–

Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not valid.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidCastException: Specified cast is not valid.]
Microsoft.SharePoint.SPRequestManager.get_SPRequestsPerThreadWarning() +26657440
Microsoft.SharePoint.SPRequestManager.Add(SPRequest request, Boolean shareable) +340
Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(SPSite site, String name, Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous) +27989305
Microsoft.SharePoint.SPRequestManager.GetContextRequest(SPRequestAuthenticationMode authenticationMode) +268
Microsoft.SharePoint.Administration.SPFarm.get_RequestAny() +173
Microsoft.SharePoint.SPRegionalSettings.get_GlobalInstalledLanguages() +27
Microsoft.SharePoint.Administration.SPTemplateFileSystemWatcher.RefreshInstalledLocales() +60
Microsoft.SharePoint.Administration.SPTemplateFileSystemWatcher.Initialize() +69
Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.System.Web.IHttpModule.Init(HttpApplication app) +931
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +480
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +336
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +350
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +382

[HttpException (0x80004005): Specified cast is not valid.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11335878
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +88
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4355300

——————————————————————————–
Version Information: Microsoft .NET Framework Version:2.0.50727.5472; ASP.NET Version:2.0.50727.5456

Cleaning up a drop off library mess

You installed SharePoint, then your power users enabled the content organizer feature all over your farm. This isn’t necessarily a bad thing, but if it’s not being used, turn it off! Less load on the farm, the better off you will be.

You will find plenty of examples on the web about cleaning up this mess, but I took a slightly different approach. Before disabling the feature and deleting the library, I first checked to make sure the library was empty and no content org rules had been created.

Start-SPAssignment -Global

$web = Get-SPWeb "http://webapp.sharepointed.com"
$feature = Get-SPFeature "7ad5272a-2694-4349-953e-ea5ef290e97c" 

   if ($web.Features[$feature.ID]) 
   {
            $corList = $web.lists["Content Organizer Rules"]
            $dolList = $web.lists["Drop Off Library"]
            
            #check for Cont Org Rules and items in Drop Off Library
            if(($corList.ItemCount -eq 0) -and ($dolList.ItemCount -eq 0))
            {
                  #disable the feature
                  Disable-SPFeature -Identity "7ad5272a-2694-4349-953e-ea5ef290e97c" -Url $_.URL -Confirm:$false
                  
                  #remove the Drop Off Library
                  $dolList.AllowDeletion = $true
                  $dolList.Update()
                  $dolList.Delete()
            }
   } 

Stop-SPAssignment -Global

Accessing search.asmx from a site collection

My goal was to setup a desktop app to query the SharePoint Search Web Service located at: http://webApp/managedPath/siteCollection/_vti_bin/search.asmx

Guide for creating the app:
http://msdn.microsoft.com/en-us/library/ff394650.ASPX

In my app, I needed to query a site collection, not the root site. Also needed to pass in my test-account username, password, and domain.

Error 1:

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Attempted to perform an unauthorized operation.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
.....

Error 2:

System.Net.WebException: The request failed with HTTP status 401: Unauthorized.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)

Error1 was the primary issue.
Error2 was related to an incorrect login.

When creating my app, I used a web reference pointing to http://webApp/managedPath/siteCollection/_vti_bin/search.asmx . After receiving Error1 countless times, I opened the App.config file. In there I found the answer…

For some great reason, Visual Studio updated the reference to point to the root web app, not the site collection.

http://webApp/_vti_bin/search.asmx

Updated the App.config file to point to the site collection, no more Error1.

http://webApp/managedPath/siteCollection/_vti_bin/search.asmx

Connection I used:

//queryService.Credentials = System.Net.CredentialCache.DefaultCredentials;
queryService.Credentials = new NetworkCredential("testAccountName", "thePassword", "domain");

Use PowerShell to Create Year and Month Folders in Library

How do you create a year and month folder structure in a SharePoint document library?

Every year, I needed to create a folder structure in a report library that looks like this:

Next Year – 01 …… 12

Using PowerShell I’m able to create the parent folder (year), then create the subfolders (months).

*NOTE*
This can be executed using a scheduled task or using a workflow in SharePoint Designer with the help of the iLoveSharePoint add in.

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

$spWeb = Get-SPWeb "http://sharepointed.com/sites/reports"
$spDocLib = $spWeb.Lists["TacoReports"]

$yearFolder = (get-date (Get-Date).AddYears(1) -UFormat "%Y")

$targetFolder = $spWeb.GetFolder($spDocLib.RootFolder.ServerRelativeUrl + "/$yearFolder")

if($targetFolder.Exists -eq $false)
{
    $spFolder = $spDocLib.AddItem("",[Microsoft.SharePoint.SPFileSystemObjectType]::Folder,$yearFolder)
	$spFolder.Update()

	$i = 1
	While ($i -le 12)
	{
		$subFolder= "{0:D2}" -f $i
		$spSubFolder = $spDocLib.AddItem($spFolder.Folder.ServerRelativeUrl,[Microsoft.SharePoint.SPFileSystemObjectType]::Folder,$subFolder)
		$spSubFolder.Update()

		$i++
	}
}

Get the current year and add one.
Check if the new folder already exist.
Create the year folder.
Then create the twelve subfolders (one for each month).

Task ‘SharePoint’ reported error (0x80004005): an error occurred in this SharePoint list

From what I have read in other blogs and forums, this might not be the fix for everyone.

Error in Outlook:
0x80004005

Using Fiddler, I was seeing the same reference to http://randomSite.SP.com.

In my case, it turned that I had an outdated / not used URL in my Alternate Access Mappings.
Default Zone was set to http://goodSite.SP.com
Intranet Zone was set to http//randomSite.SP.com

Once http://randSIte.SP.com was removed, the Outlook error went away.
(removing the mapping did NOT induce an IISreset.)

Alternate Access Mappings can be found here:
http://YourCentralAdminSite/_admin/AlternateUrlCollections.aspx

Full error:
Task ‘SharePoint’ reported error (0x80004005) : ‘An error occurred in this SharePoint List (site name – list name). Try updating the folder again. If the problem continues, contact the SharePoint site administrator. HTTP 500.
The server returned the following error message: Exception of type
‘Microsoft.SharePoint.SoapServer.SoapServerException’ was thrown.’

Fiddler referenced this web service:
GetListItemChangesSinceToken