GP 2013 and 2015 GP Web Services "Exception message: The security object does not exist"

After moving the GPWEBSECURITY database for GP Web Services and running a repair we received the following error opening the Security Console:

“Exception message: The security object does not exist. Missing Key: 25cc1a21-2cc4-4b13-a1c8-eea186fb688a”

Turns out we ran the wrong repair.  DO NOT run the repair from the GP Web Services Configuration Console.  Instead, launch the GP Setup.exe from the GP installation media.  This will detect the existing install and give you the option to repair.I used information from the following link and updated it for the new web services that does not run in IIS:

https://support.microsoft.com/en-us/kb/943949

To determine the scopes in the ADAM database, use the Authorization Manager (Azman.msc) Microsoft Management Console (MMC) snap-in to browse the database. To do this, follow these steps:

  1. Click Start, click Run, type azman.msc, and then click OK.
  2. On the Action menu, click Open Authorization Store.
  3. Click Active Directory.
  4. In Windows Explorer, open the following folder:
    C:Program FilesMicrosoft DynamicsGPWebServicesWebServices
  5. Use Notepad to open the DynamicsSecurity.config file.
  6. Copy the following value for the AzManConnectionString setting:
    mssql://Driver={SQL Server};Server={MySqlServerMyInstance};/GPWEBSECURITY/DynamicsGPWebServices
  7. Paste the value into the Store Name field in the Open Authorization Store window, and then click OK.
  8. Expand the DynamicsSecurityService store.
  9. Expand 25cc1a21-2cc4-4b13-a1c8-eea186fb688a to view the scopes. A folder graphic designates the scopes that are installed and that have an assigned integer value.

I was able to verify that the database in the new GPWEBSECURITY database did not contain the data from the original database.  I restored from backup.  Reran the repair.

NOTE: I also had to search all .config files in the install folders for the original MyOldSqlServerMyOldInstance and replace it with the MyNewSqlServerMyNewInstance.

I used FNR.exe from codeplex.