C# Id为[Id]的帐户不存在
我正在尝试从dynamics CRM检索我自己的姓名文件,但在检索过程中我一直收到此消息。(代码成功地将我的用户id与请求一起返回) Id为[Id]的System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]帐户不存在C# Id为[Id]的帐户不存在,c#,dynamics-crm,dynamics-crm-online,dynamics-crm-365,C#,Dynamics Crm,Dynamics Crm Online,Dynamics Crm 365,我正在尝试从dynamics CRM检索我自己的姓名文件,但在检索过程中我一直收到此消息。(代码成功地将我的用户id与请求一起返回) Id为[Id]的System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]帐户不存在 IOrganizationService oServiceProxy; try { //Cr
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());
}
提前谢谢 从WhoAmIRequest中获取的用户ID属于systemuser实体,而不是account实体
oServiceProxy.Retrieve("systemuser", userid, new ColumnSet("fullname"));
从WhoAmIRequest获得的用户ID属于systemuser实体,而不是account实体
oServiceProxy.Retrieve("systemuser", userid, new ColumnSet("fullname"));