Category Archives: Home

WCF: Unauthorized client authentication with server header Ntlm, Negotiate

This (like just about all posts on this blog) is more of a reminder to myself in case I ever see this problem again.

Whilst running some integration tests that exercise end to end WCF functionality I encountered an odd problem that only seemed to manifest itself when I was running the test application against the service running within IIS (or so I thought).  When the service was running in Visual Studio 2008’s Cassini server, all my tests pass, but when I reconfigure to point to IIS (the dev environment sits on Windows 2008 Server R2) I get the following error:

The HTTP request is unauthorized with client authentication scheme ‘Ntlm’. The authentication header received from the server was ‘Negotiate,NTLM’.

At this point in time I’m a relative WCF noob and WCF security is (I’m led to believe) a huge topic that I just don’t have much time to learn about right now.  My debugging process is fairly simple:

  • I know the tests work when running against the dev environment so it’s not code.
  • The solution uses Web Deploy projects.  So I delete the virtual application in IIS and rebuild.  That deploys correctly, so it’s not the deployment.
  • The exact same settings running against localhost work for another Service I recently checked in, so I know that this should work.
  • I checked to ensure that the configurations for that other Service were identical (where it mattered) to the one that had problems with authentication.
  • I was using Fiddler to ensure that the client is talking to the service and that the service in turn is talking to other stubbed services.

That last point is where I kind of tripped up and where my WCF  and general ignorance raised its head.

I had configured the client to use Fiddler’s localhost equivalent (ipv4.fiddler) in order to view the messages that are sent across the wire.  The server was naturally configured to just use localhost.  Although fiddler can and does intercept ipv4.fiddler and routes it to localhost, WCF – or more likely Windows Authentication – sees it as a domain and will point out that there’s a mismatch in authentication – hence the 401 error above.

The solution in the end was very simple – ensure that all client endpoints match all server endpoints and that security is configured the same way for both client and service – the problem then goes away. It took a bit of Google magic but I eventually found this post on Stackoverflow which pointed me in the right direction.

Mac: MacBook Pro hard disk upgrade

It didn’t take long before my requirements for my laptop exceeded the capabilities of the thing.  The bottom of the range specification of a 250GB hard disk with 4GB of RAM is very quickly overcome when trying to run Windows 7 and Visual Studio 2010 through Parallels.  The latest refresh of the MacBook Pro didn’t take my fancy either – it just doesn’t seem worth the money and I may as well wait out another year.  So what’s a geek to do when the laptop’s hard disk is straining due to my having carelessly thrown two operating systems at it as well as a couple of development environments (that’s XCode rather than TextMate) and my whole music collection?

Well I could have upgraded the entire laptop but where’s the fun in that.  A quick look on brings up a a very reasonably priced Western Digital Scorpio Black 500GB.  Under £50 for a hdd that’s twice the capacity and much faster than my current one – yes please.  Might as well upgrade the RAM at the same time (because modern OS’s need more than 2GB each to run smoothly), but sadly Scan was out of stock.

So the problem becomes very simple: What steps are required to migrate hard disks without losing any data or settings when you run Windows 7 on a BootCamp partition with Parallels (although I imagine the same process applies to VMWare Fusion)?

I needed:

  1. An external hard disk of some description (I bought another 3.5″ SATA, which I was going to re-use after in my desktop, together with an external HDD enclosure that I am already using for my media center). This will preferably be bigger than your existing laptop’s HDD.
  2. A MacBook Pro (mid-2010 vintage although I don’t see why it wouldn’t work with something older).
  3. A tiny tiny phillips screwdriver and a size 0 Torx screwdriver.
  4. TimeMachine (comes with Mac).
  5. WinClone (free download).
  6. The original OSX install CD that comes with the MacBook
  7. Lots and lots of Time…

The first thing I did after connecting the new external hdd to the laptop (via USB) was to partition it into 2.  One partition would be for the OSX backup and the other for the BootCamp image.

Next, run TimeMachine to take a full backup of your OSX installation.  Set the destination to the external disk and wait for a few hours.  TimeMachine will back absolutely everything up… EXCEPT the BootCamp partition.  Which is where WinClone comes in.  After TimeMachine has finished, run WinClone and take an image of the BootCamp partition.  I placed this image directly on the partition of the external HDD reserved for it.

Once both of these processes have finished, power down and swap the hard disks round.  The actual assembly/disassembly time was in the region of 15 minutes – less if you have a Torx screwdriver, but a small set of pliers will do the trick too.  Rather than describe the process there’s a very succinct video on YouTube showing the process.

With that out the way, power up the laptop and pop the OSX CD in.  When the bootstrapping process has completed, OSX will ask whether you want to restore from a backup.  It wasn’t entirely intuitive and in your face like most of Apple’s prompts, but you’ll need to look for a menu item at the top for the utility to restore.  Before you do that though you will need to create a partition on the new hard disk (otherwise there’s nowhere for the OS to install to) and this can be found in the Disk Utility.  You can then set TimeMachine to restore to the new partition you’ve created on your brand new hard disk.  After waiting for what seemed like a long time (overnight) your laptop will be ready to go… almost.

What’s still missing is the Windows installation that’s still sitting as an image on the external hard disk.  Fire up BootCamp again and recreate a BootCamp partition.  As I now have a larger hard disk I can afford a larger Windows partition, so I created it twice as big as my last one.  Once that’s been created (don’t go through the whole process, just create the partition), I used WinClone to restore the image onto the new BootCamp partition.  However, because I increased the partition space and want to take advantage of that exra space, I needed to do one more thing.  The Tools menu on WinClone has a menu option to Expand NTFS Filesystem, use this on the new BootCamp partition and you’re pretty much all set.

At this point, Parallels still complains that it can’t find the Virtual Machine you’ve just lovingly restored into the new BootCamp partition.  That’s because it’s still looking for it on the old hard disk.  Power down the Virtual Machine and look in the Config menu.  Switch the hard disk in the dropdown to point to your new disk and then restart the VM.  Windows will go through a process of checking the disks but after that everything should be back to normal.

And so ends (part of) my laptop upgrade journey.  It was a lot easier than I thought it would be (this being an Apple product and all).  Next up is a RAM upgrade but that should be a lot easier now I’ve opened it up once already.

5 months later…

Time flies. Since getting my MacBook Pro I have been procastinating. That is not to say I have done nothing with my time – I’ve brought myself up to date with ASP.NET MVC 2, learned how to implement and query with NHibernate 3.0 (using the new Linq provider, Criteria and even some HQL), written a web application using .NET 4 (and got it working correctly in a continuous integration build server), learned how to use the new templating features in jQuery and finally grokked javascript’s functions as first class citizen concept. I also put my MacBook through its paces and did some tutorials on Ruby, Rails and node.js.

When I’m not at work (coding), I tend to sit at the computer at home (and code) or read (about code and how to make my code better). After doing this for close to 2 years now I think I’m about ready for a break and my dear wife has provided me with a distraction – Finance.

She’s kindly bought me a copy of Finance – The Basics by Erik Banks and even though I’m only on the 2nd chapter I’m already finding it an interesting and easy to grasp book (so far!). I opted for the Kindle version which is marginally cheaper than the paperback, although I would recommend anyone else to go for the paperback version. The Kindle is a very nice format and for reading it is as good (if not better) than reading a proper book, however the digital version of this book is disappointing with regards to the diagrams that come with it.

One would have thought that being a proper e-book that is bought from Amazon for an Amazon device, that things like diagrams would be crisp and clear and that diagrams would flow nicely together with the text. Sadly this is not the case. The diagrams are all washed out and fuzzy. Enlarging them makes no difference, if anything the diagram gets worse. I’m not even talking about complex graphs (I’m only on chapter 2!). A simple box containing text (same size as the content) looks washed out. I can appreciate that something like vector graphics would be beyond the capabilities of a humble e-reader, but at least include a decent size graphic with the book. This isn’t a gripe at Amazon, well maybe it is a little if only due to quality control, but publishers really should make a better effort than just dumping some ASCII in a file and flogging it at the same price as a physical book.

So there we go, a short update of my life, a slight diversion of interests and a mini-review/whinge of my new Kindle 3 (WIFI only version).

Mac: Macbook Pro – My first week

I went and bought a 13″ Macbook Pro last Saturday – the base model with no bells or whistles. Impulse brought me to the Apple Store on Regent Street and impulse compelled me to buy one on the spot. Common sense would have told me to exhibit some patience and buy the laptop online with a faster hard disk, but impulse won.

I’ve been wanting a laptop for a while now. I satisfied my craving for a state of the art desktop PC last Christmas and I felt it was time to finally get a laptop – the missing piece in my digital lifestyle. I’ve always been curious about the “Mac World”. A mystical place I thought, staring enviously from my “Microsoft World”. All “Mac People” ever went on about was how much better it was than the “Windows way”, so I thought I’d give it a go. With the advent of programs like VMWare, Parallels and Boot Camp I thought I could always flee to the safety of Windows – either on the laptop or back to my desktop – a risky strategy in these economically challenging times.

As it turns out my fears were unjustified. My initial use case (and justification) was that I simply needed a small device on which to browse the web, check on emails and do some lightweight programming on (perhaps learning a bit about Ruby and this thing called ‘Rails’). And in this regard the Macbook Pro simply excels. It’s fast, it’s simple and it does what I want it to. Let’s ignore for the moment that for this simple use case I could have gone and bought a £250 netbook – it’s not an economic itch to scratch by any means.

As a professional web developer I could not resist installing a few other ‘extras’ though. Firefox and Chrome quickly joined Safari, as did TextMate, QuickSilver and Ruby. Solving problems on proved to be fun using Ruby and when I get stuck doing something there’s always Microsoft’s Remote Desktop Connection to my PC where I can fire up Visual Studio for some brute force calculations (8 logical cores… wooo!).

So far it’s been good, but then it’s only been a week and the novelty of actually having a laptop hasn’t worn off yet. I have noticed that I tend to use the laptop in the living room or in bed now instead of being glued to my desktop. That is not so much a statement of how much I enjoy using Mac OS X (I still have some ‘issues’ with that) but of how nice it is to be able to just fire up a TextMate instance or browser and ‘do stuff’ whilst still being ‘sociable’ with my other half.

I have resolved to create a website for my upcoming wedding and I think I will probably do some of it on this laptop. It will be interesting to see how well it will cope when used in anger.

I’ve moved the blog to WordPress

So the first thing a true geek does is write their own blog type website.  Until they realise that under the hood it’s a little more complex than throwing together a few tables, mixing in a bit of CSS and Javascript and then being done with it.  The pragmatic geek on the other hand will eventually cede defeat and use something off the shelf.

My original goal with redoing the website was to learn to use ASP.NET MVC together with techniques and methodologies that all the cool kids were using – things like TDD, IoC, SOLID principles, ORM (Subsonic & Linq2Sql) etc.  So, I’ve been there, done that and now I’m ready (finally!) to use a weblog that was created by people who know what blogging software is supposed to do.

I won’t port my old content into this shiny toy – there wasn’t much and I’m none too happy with the shoddy quality of it anyway.

So here’s to 2010 and more posts on stuff!