Exchange 2010 SP2 Database Upgrade (from v1.2.6 to v2.0)

When upgrading from WSP v1.2.6 to v2 it is necessary to update the location of where the ABMP (AddressBook Mailbox Policies) path can be found, this information is stored within the WSP Database. If this path is not correct you will not be able to create new organizations. This script should be applied directly after an upgrade from 1.2.1.6 to the latest 2.0 release. If you are performing a manual update, then it should be applied after running update_db.sql

The default location of the ABMP can differ depending upon what values that were used when Exchange 2010 SP2 was installed.
The default location is:
CN=AddressBook Mailbox Policy, CN=First Organization, CN=MICROSOFT EXCHANGE, CN=SERVICES, CN=CONFIGURATION, DC=DOMAIN, DC=COM

NOTE: “First Organization” may not be correct on your server.

In the example below the CN name had been created with an alternative name of Midlands Hosting (highlighted blue),

WARNING: If you do not use the correct values you will need to rewrite your database entries again with the correct values and the script cannot be ran twice.

Use ADSI edit to ensure you have the correct CN value.
Please amend the Green items within the provided script to suit your installation variables and then run the script on your WSP database server.

DECLARE @NetBIOSDomain nvarchar(20)
DECLARE @ExchangeOrgRoot nvarchar(256)

SET @NetBIOSDomain = ‘YOURDOMAIN
SET @ExchangeOrgRoot = ‘CN=First Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=YOURDOMAIN,DC=YOURTLD

UPDATE ExchangeAccounts SET SamAccountName = @NetBIOSDomain+’\’+AccountName WHERE AccountID IN (SELECT AccountID FROM ExchangeAccounts WHERE AccountType IN (3,7) AND SamAccountName = ”)

INSERT INTO ServiceItemProperties (ItemID, PropertyName, PropertyValue) (SELECT SP.ItemID, ‘AddressBookPolicy’,
PV = ‘CN=’+SP.PropertyValue+’ Address Policy,CN=AddressBook Mailbox Policies,’ + @ExchangeOrgRoot
FROM ServiceItemProperties AS SP
WHERE (PropertyName = ‘OrganizationID’) AND (ItemID IN
(SELECT ItemID
FROM ServiceItemProperties AS ServiceItemProperties_1
WHERE (PropertyName = ‘GlobalAddressList’) AND (PropertyValue <> ”))))

UPDATE SP SET PropertyValue=’CN=’+SP2.PropertyValue+’ Rooms,CN=All Address Lists,CN=Address Lists Container,’+@ExchangeOrgRoot
FROM ServiceItemProperties AS SP
JOIN ServiceItemProperties AS SP2 ON SP.ItemID = SP2.ItemID AND SP.PropertyName=’RoomsAddressList’
WHERE (SP2.PropertyName = ‘OrganizationID’) AND (SP2.ItemID IN
(SELECT ItemID
FROM ServiceItemProperties AS ServiceItemProperties_1
WHERE (PropertyName = ‘GlobalAddressList’) AND (PropertyValue <> ”)))

Download the script file here: organizationupdate-2.0.sql