Monday, March 21, 2011

Steps to Add Deployment Administrator in MSCRM 4.0 from Database


Hello friends,

After a long busy schedule, today I want to share my one of the recent experience when I was caught in a problem which was arise by my small mistake J and then I managed to overcome to the solution.

Recently we needed import one of our CRM organizations from one deployment to other but due to some technical reasons the import got failed. Due to that failure before restarting import again, I needed to remove all the false entries which got created in MSCRM_CONFIG database during the failed import action. Within few minutes I managed to remove all the referential entries from all the tables related to the failed to import organization. 

But later on when I opened Deployment Manager, it did not allowed me to open it and responded me with below error
“Only the administrators are able to use deployment manager. you are not a deployment administrator.”
and later on I found that during the deletion of the false entries, by mistake all the entries related to deployment managers also got deleted.

After searching for couple of hours I managed to add Deployment Administrator from database and I want to share you the steps I followed to achieve the same.

Step 1: Get "systemuserid" for the user whom you want as a "Deployment Administrator" from CRM Database
Query: 
select systemuserid,fullname from systemuser where fullname like '%prathmesh%'

Step 2: Open SQL Server Management Studio and fire below query against MSCRM_CONFIG database
Query: 
SELECT Id, UserId
FROM SystemUserOrganizations
WHERE CrmUserId = <<systemuserid>> --Replace <> by the systemuserid got from step 1

Step 3: Fire Below query to get Administrator Security Role Id
Query:
SELECT Id FROM SecurityRole WHERE name = 'Administrator'

Step 4: Fire below query to Insert a record in SystemUserRoles table of MSCRM_CONFIG database
Query:
INSERT INTO SystemUserRoles
(
     [Id]
     ,[SecurityRoleId]
     ,[SystemUserId]
     ,[IsDeleted]
)
VALUES
(
     NEWID(), -- new Guid
     ,<<SecurityRoleId>>  --Replace "Id" Guid found from Step 3
     ,<<UserId>> --replace "UserId" Guid found from step 2
     ,0
)

Step 5: Add Name to SystemUser table using below query
Query:
UPDATE SystemUser
SET name  <<mydomain\username>>  -- User's domain name\username
WHERE Id = <<UserId>>  -- Replace "UserId" Guid found from step 2


Hope this post helps you jump out of a situation in which I was caught… J

Feel free to post the query in case you need help for Dynamics CRM and this post.