SQL Server Auto Backup Database Script

This Script Is what I use on all my database servers, its never failed and is extremely useful.

Just change the @PATH and the @BaseLine days as you see fit, paste the code into a job and run it everyday at midnight or what ever time your backups tends to run.

TFS 2010 Windows sharepoint Services Search

You type a search in the text box and hit search, you are then greated with

“Your search cannot be completed because this site is not assigned to an indexer. Contact your administrator for more information.”

You have TFS 2010 installed and everything is working, apart from the Search Services in the sharepoint portals

You try to manually start the service in the windows services console but it fails

You have followed microsoft instructions to enable and start the service but you cannot see the search service in central administration > Operations > services on server

Easily Fixed

You just need to do a repair of your WSS 3 install through programs and features. there is a catch though. When you try to perform a repair you recieve another error

“Microsoft Windows SharePoint Services 3.0 1033 Lang Pack – Error 1706th An installation package for the product Microsoft Windows SharePoint Services 3.0 1033 Lang Pack can not be found. Try the installation again using a valid copy of the installation package ‘wssmui.msi’.”

From Microsoft Download the Service Pack for Windows SharePoint Services Language Pack from here 64bit or here 32bit and install.

Now perform your repair.

Now browse to Central administration > operations > services on server and you will see as if by magic the search service is now available to configure. Click the start.

Configure Windows SharePoint Services Search Service Settings on server

Service Account: can be a local account \ or can be a domain account \
Content Access Account: can also be a local or domain account
Search Database: this is created automatically

NOTE- I suggest Using the account that you configured for the TFS to use when you were installing TFS 2010, this is because it needs full access to the SQL server and should NOT need to be an admin on the machine or domain. If you use the same account it also keep maintenance easy

Final Step – Add Search to an application database

  • goto central administration > application management > manage > content databases
  • Select the application database (on a fresh TFS instal it should be “WSS_Content”)
  • Search Server – select the only item in the drop down list (should be the server name)

TFS 2010 Installation guide & post install tweaks

If you need a good guide to install TFS 2010 then you need to download the guide from this location

http://www.benday.com/downloads/tfs2010beta2installguide/BenDay_TeamFoundationServer2010beta2_InstallationGuide_alpha.pdf

Once you have followed the parts you need to, you might want to do as I did and make a few changes.

I also needed to do a few extra bits to have the functionality I required delivered to the server and TFS clients

  • Visual Studio 2010 and MSSQLMS (Microsoft SQL Server Management Studio) need to connect to TFS
  • VS 2010 must also compile and debug javascript/jquery in the background as much as it does for the .NET object model
  • I want to get the most out of my dev team so I am also going to install a couple of VS2010 extensions to make them work faster and more efficiently
  • The TFS 2010 server is going to have some handy Administration tools installed
  • TFS will also have Team Explorer 2010 installed and TFS 2010 service Pack
  • Use a FQDN for connectivity rather than machine name to access TFS requires loopback be disabled http://support.microsoft.com/kb/896861

So to begin with lets list the software and the download locations

loopback cure

HKLM\SYSTEM\CurrentControlSet\Control\Lsa\

add a REG_DWORD named “DisableLoopbackCheck”” and set it to decimal value 1

or

HKLM\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0

add a REG_MULTI_SZ and enter each domain name on new lines to allow loopback on only those domains

Changing Sharepoint URLs

http://social.technet.microsoft.com/Forums/en-US/sharepointadmin/thread/b1aab77a-6914-49a8-951c-792e899440e4/

http://social.msdn.microsoft.com/Forums/pl-PL/tfsgeneral/thread/2efb31f8-10ed-400b-8e22-4368a24e7640

unable to download web platform product list

Unable to download the Web Platform product list from . Check your network connection and try again. If the problem persists, report the issue on the Web Platform Installer forum at: http://go.microsoft.com/fwlink/?LinkId=145244.

Applies to Web platform installer 3 on server 2008

Verify you can browse to http://www.microsoft.com/web/webpi/3.0/WebProductList.xml

If you can then add the following registry key

HKLM\SOFTWARE|Microsoft\WebPlatformInstaller

Add string value (reg_sz) named “ProductXmlLocation”

Value http://www.microsoft.com/web/webpi/3.0/WebProductList.xml

Re run the Web Platform Installer and all should be well

.NET Entity Layer The member with identity ‘Result’ does not exist in the metadata collection

“The member with identity ‘Result’ does not exist in the metadata collection.
Parameter name: identity”

If you have stumbled across this error when trying to perform a transaction against your DB or any other action via your entity layer. If it is indeed a Microsoft SQL Database or any other database I would highly recommend you disable triggers on the affected tables and re run your test.

This error is the entity layer running home to its default error when either the error cannot be translated or the what ever is being returned from the transaction cannot be understood.

So if you stumble across this error, its because the entity layer is performing an operation that is causing a secondary separate operation which is where the underlying error is kicking back from, either because an error was raised or because the return is in an unexpected format.

ASP.NET Combine & Minify CSS & JSS on the fly (Also tested in Umbraco) in 5 easy steps

Automatically Combine, minify, compress and much more on the fly.
Here you will learn in 5 steps how to implement the combine and minify project originally from codeplex into any .net application. I’ve just tested this on an Umbraco installation and it works flawlessly, the project also makes use of 2 open source libraries.

The original project can be found http://combineandminify.codeplex.com/ I have converted this project from c# to vb and made some considerable further optimisations in the code around the caching mechanism.

The two other libraries included are:

EcmaScript.NET.modified.dll
Yahoo.Yui.Compressor.dll

Along with a lot of custom code to automatically provide a cached based minify & compress  for your css & jss files. But it doesn’t stop there you can also use this project to remove white space from the html rendering to the client (default operation), all comments and commented code in .js and .css file includes is striped , you can insert VersionId’s in font urls and images and even preload images.

Ok so lets break it down.

What does it do and how?

Taking the .js and .css includes in particular, during the request life-cycle of the .net engine combineAndMinify will scan the header of the page just prior to rendering to the client, it will collect up the .js and .css includes, minify, compress, remove comments and white spaces and place the new combined content into the cache. So that’s one cache record for the .js and one for the .css. It will then strip out all the include references from the page header and replace them with a unique include reference pointing to the cached version for the browser to process. in your webconfig you have told IIS that all requests to .js and .css files must be routed through the combineandminify class, so when the browser then requests the include eg 33212cce52b6065a.js, the combineAndMinify handler then pulls the content from the cache and sends it to the client.

This process optimises your site in two ways, it caches the includes, and provides the client with only one include per type to request from the server.

The unique names are calculated using logic on various aspects, for example if you wished that the caching occur per page or for the entire website at domain level.

Out of the box the combineAndMinify is intelligent enough not to touch any include that references a different domain, and is in fact very customisable in that respect.

Furthermore it also knows when any of the files that it has cached change and will automatically update the cached version on the active request the change has been detected on.

See the full spec on codeplex.

Configuration settings:

configuration>combineAndMinify
Config Attribute Default Value Possbile Values
removeWhitespace false true/false
insertVersionIdInFontUrls false true/false
insertVersionIdInImageUrls false true/false
makeImageUrlsLowercase false true/false
prioritizedImages true true/false
preloadAllImages false true/false
cookielessDomains
enableCookielessDomains Always Never
Always/ReleaseModeOnly/DebugModeOnly
minifyJavaScript true true/false
minifyCSS true true/false
combineJavaScriptFiles PerGroup None/PerGroup/All
combineCSSFiles PerGroup None/PerGroup/All
headCaching None None/PerSite/PerFolder/PerPage/PerUrl
exceptionOnMissingFile Never Never/Always/ReleaseModeOnly/DebugModeOnly
active ReleaseModeOnly Never/Always/ReleaseModeOnly/DebugModeOnly

If your even half technical you can guess what half of these configuration settings do, if you need a further understanding on all the configuration settings please visit the codeplex project website because its beyond the scope of this how to.

Implementation

  1. Copy the binaries to your bin folder and add references to them or include the project into your solution
  2. Copy and rename “HeadAdapter.browser.txt” to HeadAdapter.browser to your App_Browsers folder
  3. make the required changes to your web.config file
  4. change the combineAndMinify config attribute “active” from “Never” to “Always”
  5. test the solution in firefox, ie or chrome and verify the compression in firebug F12 Developer tools or FireBug Lite respectively.

The vb.net converted, enhanced version of the project compiled to binaries and other  files you will need:

CombineAndMinify_Dlls

HeadAdapter.browser.txt

web.config.txt

If anyone has any problems at all, I will help where I can. If you want the vb.net version of this project then let me know and I’ll send it over.

Forms Authentication static content not loading

Using forms authentication, you may find that your css is not being applied, or other such static media isnt loading when you are not authenticated, ie when not logged in.

In order to diagnose where the problem is you need to understand how forms authentication walks hand in hand with IIS regardless if you are forcing all requests through the .net api or not.

The Scope of Forms Authentication

The FormsAuthenticationModule is managed code that is part of the ASP.NET runtime. Prior to version 7 of Microsoft’s Internet Information Services (IIS) web server, there was a distinct barrier between IIS’s HTTP pipeline and the ASP.NET runtime’s pipeline. In short, in IIS 6 and earlier, the FormsAuthenticationModule only executes when a request is delegated from IIS to the ASP.NET runtime. By default, IIS processes static content itself – like HTML pages and CSS and image files – and only hands off requests to the ASP.NET runtime when a page with an extension of .aspx, .asmx, or .ashx is requested.

IIS 7, however, allows for integrated IIS and ASP.NET pipelines. With a few configuration settings you can setup IIS 7 to invoke the FormsAuthenticationModule for all requests. Furthermore, with IIS 7 you can define URL authorization rules for files of any type. For more information, see Changes Between IIS6 and IIS7 Security, Your Web Platform Security, and Understanding IIS7 URL Authorization.

Long story short, in versions prior to IIS 7, you can only use forms authentication to protect resources handled by the ASP.NET runtime. Likewise, URL authorization rules are only applied to resources handled by the ASP.NET runtime. But with IIS 7 it is possible to integrate the FormsAuthenticationModule and UrlAuthorizationModule into IIS’s HTTP pipeline, thereby extending this functionality to all requests.

If you want IIS to integrate the dynamic and static content with the forms authentication module you set your application pool to “integrated” mode, if not you set it to “classic” mode, separating the authentication module from the static content such as css files and other such media.

Configuring forms based authentication

you typically use the webconfig file to setup security topology of your website, below is n example of a webconfig root entry to apply security to folder and files of your website application

here we are allowing all users to have access to the folder “css” found on the root of the web application

similarly here we grant access to all users for the themes folder

In this example we want only those users in the Admin role to have access to the contents of the Admin folder

Another post you may find useful http://scottonwriting.net/sowblog/archive/2009/09/28/163364.aspx

Information Technology, Life, Interesting Stumbles, Servers, Configuration, Topology, Security, Best Practices, Developing, Fire Fighting, Problem solving, Visual Studio 2005 – 2015 .NET 1.1 – 4.5, jQuery, JSON & much much more