码迷,mamicode.com
首页 > 其他好文 > 详细

Dynamics CRM 365 创建用户的时候报:The specified Active Directory user already exists as a Dynamics 365 user

时间:2020-09-17 22:55:37      阅读:32      评论:0      收藏:0      [点我收藏+]

标签:erb   dir   color   背景   环境   数据库   bsp   sts   active   

用代码创建CRM账号,域用户创建后,创建CRM账号时某种原因报错,再次创建相同账号的时候,就会报错:The specified Active Directory user already exists as a Dynamics 365 user

技术图片

 

日志下载下来之后,详细信息显示如下:The specified Active Directory user already exists as a Dynamics 365 user

但检查了systemuser这张表发现确实是没有这个用户的,那为什么还会有这个错误呢?
背景:想起来之前还原过一次DB,只还原了业务库,没有还原MSCRM_Config这个库
原因:这个用户之前由于某种原因在环境2中创建了一次,但没有在环境1中创建,后来还原环境1的Org_MSCRM的数据库到环境2,导致环境2中的这个用户信息被删除掉了,
但是:用户的信息创建后不仅仅只存在systemuser这张表中,还会在MSCRM_Config的一些表中存储相关信息,所以当再次在环境2创建该用户时,就会提示已经存在,不允许在创建了。

解决办法:删除掉MSCRM_Config库中跟这个用户相关的一些信息,主要存在SystemUserOrganizations和SystemUserAuthentication这两个表中,具体SQL语句如下

  • 查询系统中已经不存在的用户在SystemUserOrganizations中的信息
select *
from SystemUserOrganizations
where organizationid=29CA5B3F-8FD1-E611-93FB-00155DC81318 and
crmuserid not in (
select systemuserid
from [Org_MSCRM].dbo.systemuserbase)

 

  • 查询系统中已经不存在的用户在SystemUserAuthentication中的信息
select *
from SystemUserAuthentication
where userid in (
select userid
from SystemUserOrganizations
where organizationid=29CA5B3F-8FD1-E611-93FB-00155DC81318 and
crmuserid not in (
select systemuserid
from [Org_MSCRM].dbo.systemuserbase)
)

 

  • 删除系统中已经不存在的用户在SystemUserOrganizations中的信息
delete
from SystemUserOrganizations
where organizationid=29CA5B3F-8FD1-E611-93FB-00155DC81318 and
crmuserid not in (
select systemuserid
from [Org_MSCRM].dbo.systemuserbase)
  • 删除系统中已经不存在的用户在SystemUserAuthentication中的信息
delete
from SystemUserAuthentication
where userid in (
select userid
from SystemUserOrganizations
where organizationid=29CA5B3F-8FD1-E611-93FB-00155DC81318 and
crmuserid not in (
select systemuserid
from [Org_MSCRM].dbo.systemuserbase)
)

备注:DB中删除完之后,需要等待一会才可以正常创建,等个5-10分钟吧

 

Dynamics CRM 365 创建用户的时候报:The specified Active Directory user already exists as a Dynamics 365 user

标签:erb   dir   color   背景   环境   数据库   bsp   sts   active   

原文地址:https://www.cnblogs.com/parkerchen/p/13656422.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!