Id = [ID]的帐户不存在

问题描述 投票:0回答:1

我正在尝试从Dynamics CRM检索自己的名字,但是在检索过程中我一直收到此消息。 (代码成功地通过WhoAmIRequest将我的用户ID返还给我)System.ServiceModel.FaultException`1 [Microsoft.Xrm.Sdk.OrganizationServiceFault]具有ID = [ID]的帐户不存在。

   IOrganizationService oServiceProxy;
            try
            {
                //Create the Dynamics 365 Connection:
                CrmServiceClient oMSCRMConn = new Microsoft.Xrm.Tooling.Connector.CrmServiceClient("AuthType=Office365;Username=_username;Password=_password;URL=https://hrrevuat.crm4.dynamics.com/;");

                //Create the IOrganizationService:
                oServiceProxy = (IOrganizationService)oMSCRMConn.OrganizationWebProxyClient != null ?
                        (IOrganizationService)oMSCRMConn.OrganizationWebProxyClient :
                        (IOrganizationService)oMSCRMConn.OrganizationServiceProxy;
                if (oServiceProxy != null)
                {


                    //Get the current user ID:
                    Guid userid = ((WhoAmIResponse)oServiceProxy.Execute(new WhoAmIRequest())).UserId;



                    if (userid != Guid.Empty)
                    {
                        Console.WriteLine("Connection Successful!");
                        oServiceProxy.Retrieve("account", userid, new ColumnSet("name"));
                    }
                }
                else
                {
                    Console.WriteLine("Connection failed...");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error - " + ex.ToString());
            }

提前感谢!

c# dynamics-crm dynamics-crm-online dynamics-crm-365
1个回答
0
投票

您从WhoAmIRequest获得的用户ID属于systemuser实体,而不属于帐户实体。

oServiceProxy.Retrieve("systemuser", userid, new ColumnSet("fullname"));
© www.soinside.com 2019 - 2024. All rights reserved.