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