Sometimes there are errors when trying to remove a Domain Manager from an Enterprise Server via the DSM Explorer in Client Automation.
Although doing so through the DSM Explorer is the preferred method this document explains the steps needed to remove via SQL queries.
In such cases, a manual removal via SQL scripts can be helpful reestablish the connection between the Domain Manager and the Enterprise server.
Client Automation - All Versions
All Supported versions of Microsoft SQL Server
NOTE: This is a very safe procedure when run properly.
However as with any procedure that modifies the product database, extreme caution must be taken to ensure no data is
lost or compromised that could result in an unintended issue in your environment.
Please read the below very carefully and test before using in a production setting:
Procedure to manually Unlink the Domain Manager (DM) from the Enterprise Server (ES):
**Only if the DM being removed still exists.
IMPORTANT: Do not attempt the below without a full and validated MDB backup on both(all) servers involved.
If there is a failure, a complete restore of the MDB should be done.
Always have CAF stopped on all Servers involved AND unlink the replication task on all Domains belonging to the Enterprise,
even if they are not involved in this procedure. This is to ensure against MDB writes to the ES MDB being attempted during the process.
Also it will keep your ES MDB backup current as further updates will not be made.
PERFORM THIS STEP ON THE DOMAIN MANAGER IF IT STILL EXISTS:
This is the actual SQL Script that will remove data from your Domain Manager (DM) MDB***:
***NOTE: Before the below, you can run the query "Select * from CA_N_TIER".
Only one row for the Domain Database server should be listed (and likely one for the ES).
If more than one listing for the DM is returned, contact support immediately
USE MDB
Go
DECLARE @domain_id int
DECLARE domain_id_cursor CURSOR FOR
select domain_id from ca_n_tier
where domain_uuid NOT in
(select set_val_uuid from ca_settings s
where s.set_id = 1)
OPEN domain_id_cursor
FETCH NEXT FROM domain_id_cursor INTO @domain_id
WHILE (@@FETCH_STATUS = 0)
BEGIN
delete from bckfile where object_domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from UNITTYPE where domainid = @domain_id
delete from NCOVERVW where domainid = @domain_id
delete from urc_ab_computer where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from statmod where object_domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from statjob where object_domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_manager_component where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_manager where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_engine where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_discovered_software where sw_def_uuid in
(select sw_def_uuid from ca_software_def where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id))
delete from inv_externaldevice_tree where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from inv_externaldevice_item where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from inv_generalinventory_tree where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from inv_generalinventory_item where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from inv_table_map where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from inv_root_map where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from inv_tree_name_id where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from inv_item_name_id where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_agent_component where server_uuid in (select server_uuid from ca_server where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id))
delete from ca_agent where domain_id = @domain_id
delete from ca_link_dis_hw_user where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from am_external_device where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_discovered_user where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_server_component where server_uuid IN (select server_uuid from ca_server where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id))
delete from ca_server where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_discovered_hardware_network where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_discovered_hardware where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_group_member where group_domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_replication_status
delete from ca_replication_conf
update ca_n_tier set parent_domain_uuid = NULL where domain_uuid IN
(select set_val_uuid from ca_settings s where s.set_id = 1)
delete from csm_property where name like '%repl%'
delete from ca_n_tier where domain_id = @domain_id
FETCH NEXT FROM domain_id_cursor INTO @domain_id
END
delete from LINKJOB where jobid IN (select jobid from NCJOBCFG where joname like '%Replication%')
CLOSE domain_id_cursor
DEALLOCATE domain_id_cursor
GO
PERFORM THIS STEP AGAINST THE ENTERPRISE SERVER MDB DATABASE:
This is the actual SQL Script that will remove data from your Enterprise Server (ES) MDB****:
****NOTE: Replace the one instance of <Enter the name of domain here> below with the name of the Domain Manager being removed from this Enterprise.
USE MDB
DECLARE @domain_id int
-- Please modify the cursor to enter the name of the domain to be unlinked from enterprise
DECLARE domain_id_cursor CURSOR FOR
select domain_id from ca_n_tier
where domain_uuid NOT in
(select set_val_uuid from ca_settings s
where s.set_id = 1) and label like '%<Enter the name of domain here>%'
OPEN domain_id_cursor
FETCH NEXT FROM domain_id_cursor INTO @domain_id
WHILE (@@FETCH_STATUS = 0)
BEGIN
-- Do the following with results
-- Delete the information from domain
delete from bckfile where object_domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from UNITTYPE where domainid = @domain_id
delete from NCOVERVW where domainid = @domain_id
delete from urc_ab_computer where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from statmod where object_domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from statjob where object_domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_manager_component where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_manager where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
update ca_engine set dis_hw_uuid=null where domain_uuid in (select domain_uuid from ca_manager
where domain_uuid in (select domain_uuid from ca_n_tier where parent_domain_uuid is NULL))
delete from ca_engine where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_discovered_software where sw_def_uuid in
(select sw_def_uuid from ca_software_def where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id))
delete from inv_externaldevice_tree where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from inv_externaldevice_item where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from inv_generalinventory_tree where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from inv_generalinventory_item where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from inv_table_map where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from inv_root_map where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from inv_tree_name_id where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from inv_item_name_id where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_agent_component where server_uuid IN (select server_uuid from ca_server where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id))
delete from ca_agent where domain_id = @domain_id
delete from ca_link_dis_hw_user where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from am_external_device where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_discovered_user where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_server_component where server_uuid not in (select server_uuid from ca_server where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id))
delete from ca_server where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_discovered_hardware_network where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_discovered_hardware where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_group_member where group_domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_group_member where member_domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_replication_status where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
delete from ca_replication_conf where domain_uuid IN (select domain_uuid from ca_n_tier where domain_id = @domain_id)
-- FINAL QUERY
delete from ca_n_tier where domain_id = @domain_id
FETCH NEXT FROM domain_id_cursor INTO @domain_id
END
CLOSE domain_id_cursor
DEALLOCATE domain_id_cursor
GO
POST PROCEDURE STEPS:
For additional information on either the supported version of Client Automation or Microsoft SQL Server
Please consult the Client Automation's Compatibility Matrix found at this link: