Reading Groove Web Services Registry Keys

Applies to: SharePoint Workspace 2010 | Visual Studio 2008

You will find in programming with Groove Web Services that you will need registry keys over and over again. The following examples show you how to get and decrypt these registry keys.

Warning

For security purposes, you should read in these values every time you need them.

Getting the Groove Keys from the Registry

The registry keys are stored in a CurrentUser registry hive. The LocalRequestKey and LocalResponseKey are encrypted using DPAPI CurrentUser encryption. To get the string values of the LocalRequestKey and LocalResponseKey keys, you should call the Unprotect([], [], DataProtectionScope) method.

The following code reads the registry keys, decrypts the request and response keys, and gets the string values for the keys:

// define strings for keys
string requestKey = "";
string responseKey = "";
string httpPort = "";
string groovePID = "";

grooveWebServicesRegKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(
  "Software\\Microsoft\\Office\\Groove\\WebServices");

if (grooveWebServicesRegKey != null)
{
  // Get request key and response key and decrypt them
  Object regValue = grooveWebServicesRegKey.GetValue("LocalRequestKey");
  if (regValue != null) 
  {
    byte[] unprotectedData = ProtectedData.Unprotect((byte[] regValue,
      null, DataProtectionScope.CurrentUser);
    requestKey = Encoding.Unicode.GetString(unprotectedData);
  }
  regValue = grooveWebServicesRegKey.GetValue("LocalResponseKey");
  if (regValue != null) 
  {
    byte[] unprotectedData = ProtectedData.Unprotect((byte[] regValue,
      null, DataProtectionScope.CurrentUser);
    responseKey = Encoding.Unicode.GetString(unprotectedData);
  }
  
  // Get local HTTP port and process PID string values from keys
  regValue = grooveWebServicesRegKey.GetValue("GrooveLocalHTTPPort");
  if (regValue != null) httpPort = regValue.ToString();
  regValue = grooveWebServicesRegKey.GetValue("GrooveLocalHTTPServerPID");
  if (regValue != null) groovePID = regValue.ToString();
}
if (requestKey == "")
{
  // Groove is not running, handle error
}

To call the Unprotect([], [], DataProtectionScope) method, you must add a reference to the .NET System.Security assembly in your C# project and add the following line to your C# file:

using System.Security.Cryptography;

This code fragment also uses the Getstring([]) method.

See Also

Reference

Groove Web Services Registry Keys

Concepts

Security in Groove Web Services