So where did all these GUIDs come from?

Project Server 2007 makes much more use of GUIDs to identify different entities than the previous version so I thought I’d do a quick post to explain what they are, why we use them and how you should use them.  GUIDs were originally a priestly class in ancient Celtic societies.  No sorry, that was Druids.  GUIDs are Globally Unique Identifiers and are 128 bit numbers usually represented in the database and ULS logs as a sequence of hexadecimal digits.  They are not guaranteed to be unique – but with 2122 or 5.3×1036 to choose from you shouldn’t see duplicates (or if you do it might be the right day to buy that lottery ticket!).

One future benefit the move to GUIDs could give us is the potential for consolidation of servers – or the use of replication between servers – where we can be sure that all the entities are unique.  With Project Server 2003 there would always be a project 101 in every server, so difficult to combine data from two servers.  GUIDs lead the way to federated servers.

One place where you may need to use GUIDs is as an identifier for new users you add through the FormsAuthUpgrade tool.  A recent support case had a customer sure that his GUIDs in his users.xml file were correct but still got an error:

Error: An error occurred creating user janedoe in membership provider. Error: Guid should contain 32 digits with 4 dashes

Closer examination showed the GUIDs had the character “g” and they should only contain hexadecimal digits (So 0-9 and a-f).  In my testing I have been known to start with one GUID and just change the last numbers for other users so I can see how this can happen (pseudo GUIDs – as my colleagues call them).  Better to use a tool to give you a new unique one.  Visual Studio can do this through Tools, Create GUID – or you can do it in code. 

If you have ever had to search logs or the database looking for a particular GUID then you will also appreciate that you don’t want too many that look the same – and better still to have the first few characters different.  In most cases if you look at the first 4 or 5 digits you would be unlucky to find duplicates in even a large dataset.  To find out even more see the entry on Wikipedia

One useful relationship you should be aware of is that the Correlation Id you see in the queue and in the logs will actually be the Project GUID for any project-related queue job.

Technorati Tags: Project Server 2007