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 2


-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.




-SystemUser and then



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'



domainname\username is for the affected user.


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





Run following query in MSCRM_CONFIG database :-



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


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





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


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





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 1 and 6 and type the answer here:
  • Post
  • That's a lot of work to just do this:

    Select a.domainname




    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 =

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

    on c.DefaultOrganizationId =

    where a.domainname ='Domain\Username'

  • Thanks Susan. Yes, this query will directly fetch the default org for a user and save your time but if someone wants to understand the concept how user records are related in different table they should know the concept.

Page 1 of 1 (2 items)