How To Find Default Organization For Any User In Multiple Organization CRM Deployment

How To Find Default Organization For Any User In Multiple Organization CRM Deployment

Rate This
  • Comments 1

 

-Log in to SQL Server where we have CRM databases <org>_MSCRM and MSCRM_CONFIG. We have 4 different tables from where we will have to fetch the user entries.

 

-SystemUserBase,

-SystemUserOrganizations,

-SystemUser and then

-Organization

 

Refer to the following diagram which will help you understand how different tables are related for a specific user.

 

 

 

 

 

Run following queries one by one and fetch the GUID values as follows:-

 

Run below query on ORG_MSCRM database :-

 

Select domainname,systemuserid from systemuserbase where domainname ='domainname\username'

 

Note:-

domainname\username is for the affected user.

 

Copy SystemUserID = 7F0F58A8-5ED0-E111-B576-00155D5AC438

 

 

 

 

Run following query in MSCRM_CONFIG database :-

 

USE [MSCRM_CONFIG]

select UserId from systemuserorganizations where CrmUserId='7F0F58A8-5ED0-E111-B576-00155D5AC438'

 

Copy UserId = D058E3E4-EF63-E111-97DA-00155D5AC42A

 

 

 

  USE [MSCRM_CONFIG]

select defaultOrganizationId from SystemUser where id='D058E3E4-EF63-E111-97DA-00155D5AC42A'

 

Copy default org id= 076DC913-4564-4569-9A8C-9CD1C4A4ABA2

 

  

 

USE [MSCRM_CONFIG]

select DatabaseName,UniqueName from organization where id = '076DC913-4564-4569-9A8C-9CD1C4A4ABA2'

 

 

Default Org XXX_MSCRM

 

This way we can find the default organization for any user.

Leave a Comment
  • Please add 4 and 3 and type the answer here:
  • Post
  • That's a lot of work to just do this:

    Select a.domainname

    ,a.systemuserid

    ,d.DatabaseName

    ,d.uniquename

    from <Org Name>_MSCRM.dbo.systemuserbase a WITH (NOLOCK)

    inner join MSCRM_CONFIG.dbo.SystemUserOrganizations b WITH (NOLOCK)

    on a.SystemUserId = b.CRMUserId

    inner join MSCRM_CONFIG.dbo.SystemUser c WITH (NOLOCK)

    on b.UserId = c.id

    inner join MSCRM_CONFIG.dbo.Organization d WITH (NOLOCK)

    on c.DefaultOrganizationId = d.id

    where a.domainname ='Domain\Username'

Page 1 of 1 (1 items)