• The specified Active Directory user already exists as a Dynamics 365 user


    在创建用户的时候突然报错

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

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: The specified Active Directory user already exists as a Dynamics 365 user.Detail: 
    <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
      <ActivityId>8db0abce-0c48-42b8-bd70-f7ac7ef395d3</ActivityId>
      <ErrorCode>-2147214036</ErrorCode>
      <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
      <Message>The specified Active Directory user already exists as a Dynamics 365 user.</Message>
      <Timestamp>2020-04-15T06:18:00.8358708Z</Timestamp>
      <ExceptionRetriable>false</ExceptionRetriable>
      <ExceptionSource i:nil="true" />
      <InnerFault i:nil="true" />
      <OriginalException i:nil="true" />
      <TraceText i:nil="true" />
    </OrganizationServiceFault>
    
    

    但检查了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分钟吧

    参考文章:https://community.dynamics.com/crm/b/raorapolumsdynamicscrmblog/posts/the-specified-active-directory-user-already-exists-as-a-crm-user

  • 相关阅读:
    2020以去过半,写一下上半年的总结跟下半年的计划
    js实现浏览器打印功能
    看不见远程新建git分支
    Vue中导出Excel表格方法
    SVN命令使用详解
    IOS NSTimer 定时器用法总结
    静态库与动态库的区别?
    iOS 本地缓存实现 方案借鉴
    IOS开发中NSRunloop跟NSTimer的问题
    FMDB
  • 原文地址:https://www.cnblogs.com/cndota2/p/12706286.html
Copyright © 2020-2023  润新知