K2 Roles

This is an article on K2 Roles.

Personally I think that K2 have made a mistake in their handling of AD Groups as destinations.

It seems to upick the group into it’s parts as the Activity is entered.  Which is great until a new user joins the team. They can’t perform actions on the item until it has been moved state.

Clearing Down The Transaction Log

I have a colleague to thank for this:

This is blisteringly fast and just works.

use Core

go

checkpoint

go

backup log “Core” with truncate_only

go

DBCC SHRINKFILE ( “Core_log” )

go

use OtherDB

go

checkpoint

go

backup log “OtherDB” with truncate_only

go

DBCC SHRINKFILE ( “OtherDB_log” )

go

WCF Nightmare

I have been having fun with WCF.  I have been trying to switch off anonymous authentication using WSHttpBinding. Then I found this post.  It explains that WSHttpBinding over HTTP requires anonymous authentication to be enabled.  I had accidentally set this up in an environment that I did make work.

Kerberos Success Story

I have finally worked out how to get Kerberos to work in an application that uses:

  • SharePoint 2007
  • WCF
  • SQL Server 2005
The Microsoft implementation of Kerberos seems to have been thrown together as an afterthought.
The key tool is setspn and that is an optional download which is gui-only and has no protection for the user.
The documentation is generally unclear and there is a lot of erroneous information out there. Some of the functionality required is only visible to some of the domian admins – so that if you don’t have this right then you have no way of knowing what to ask for.

Kerberos is what you need to use to solve the “two hop problem”.  This happens when a service that is called by a client needs to impersonate the client to another service.  NTLM will simply fail to authenticate and the call is made as the annonymous user.

The process of getting Kerberos to work is actually quite simple once you understand a few details.
The concept is that you must have a chain of trust running from the server all the way back to the client.

The client needs to be using Kerberos.
The server needs to be using Kerberos.
The identity of the process running on the server needs to be trusted for delegation if it wants to call another server.
You need to set up a SPN for the called server.

Solution to the Remote Desktop Clipboard bug

Here is a solution to the clipboard bug under the windows Remote Desktop.

The bug is that the session will only remember the first item copied to the clipboard.
The previous solution was to log off and on again – which is not appropriate for nested virtual machines.

This solution consists of killing and restarting rdpclip.exe.
I am tempted to create a utility that does just that.

Using XML parameters in SQL Server 2000 and above

The following is a minimal sample of extracting attribute based an element based data from an xml document in SQL Server.

declare @text varchar(1000)
set @text = ‘<a firstname=”Joe” surname=”Blogs” >42</a>’
DECLARE @idoc int
select @text

declare @name varchar(10)
declare @name2 varchar(10)

— Create an internal representation of the XML document.
EXEC sp_xml_preparedocument @idoc OUTPUT, @text
— Execute a SELECT statement using OPENXML rowset provider.
SELECT @name=surname, @name2 = [firstname]
FROM OPENXML (@idoc, ‘/a’,1)
      WITH ([firstname]  varchar(10),
            surname varchar(20))

select @name, @name2

SELECT age=[text]
FROM OPENXML (@idoc, ‘/a/text()’,2)

EXEC sp_xml_removedocument @idoc

log4net documentation

This is a great starter article for log4net.

I recently moved an application from using the Microsoft Enterprise Application logging block to log4net.
This was caused by a problem with WCF and the EAB.  There was an odd error that appeared to claim that different versions of the EAB were in use in different locations of the system (they were not!) however replacing it with the much simpler to configure log4net solved the problem. I did add a thin wrapper class so that my code is not tied to log4net.

log4net only requires that you deploy a single dll (compared to the three for EAB) and the configuartion entries are a quater the length (and don’t need a config tool to set up).