2017-03-06 6 views
0

이 예외가 발생했습니다. "지원 사용자에게이 작업에 대한 권한이 없습니다" 나는 사용자에 대한 레코드에 대한 액세스 권한을 부여하려고합니다. 이건 내 코드입니다 :CRM SDK 2015의 레코드에 GrantAccess를 부여하려고 할 때이 오류가 발생했습니다.

public void GrantAccess(Guid targetId, Guid principleId) 
    { 

     using (var service = new OrganizationService(_con)) 
     { 
      var request = new GrantAccessRequest() 
      { 
       Target = new EntityReference(Account.EntityLogicalName, targetId), 
       PrincipalAccess = new PrincipalAccess() 
       { 
        AccessMask = AccessRights.ReadAccess, 
        Principal = new EntityReference(principleId.ToString()) 
       } 
      }; 
      service.Execute(request); 
     } 
    } 

내 생성자 | 같은 것입니다 :

private static readonly string ConStr = "Url=http://crm.[ourdomain].com:90/Test; Domain=[ourdomain]; Username=[user]; Password=[password];"; 

내가 예를 들어 나는이 방법을 얻을, 데이터를 읽을 모시 : RetrieveSharedPrincipalsAndAccessResponse RevokeAccessRequest에 의해 더욱 I "RevokeAccess을" 하지만 액세스 권한을 부여하거나 수정할 수는 없습니다.

EDIT1 전체 스택 오류 :

System.ServiceModel.FaultException`1 was unhandled 
    Action=http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/ExecuteOrganizationServiceFaultFault 
    HResult=-2146233087 
    Message=Support user does not have permission on this operation 
    Source=mscorlib 
    StackTrace: 
    Server stack trace: 
     at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) 
     at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) 
     at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 
     at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 
    Exception rethrown at [0]: 
     at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 
     at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 
     at Microsoft.Xrm.Sdk.IOrganizationService.Execute(OrganizationRequest request) 
     at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.ExecuteCore(OrganizationRequest request) 
     at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.Execute(OrganizationRequest request) 
     at Microsoft.Xrm.Client.Services.OrganizationService.<>c__DisplayClass19.<Execute>b__18(IOrganizationService s) 
     at Microsoft.Xrm.Client.Services.OrganizationService.InnerOrganizationService.UsingService[TResult](Func`2 action) 
     at Microsoft.Xrm.Client.Services.OrganizationService.Execute(OrganizationRequest request) 
     at CRMConsole.Queries.GrantAccess(Guid targetId, Guid principleId) in D:\Projects\CRM\CRMPrivileges\CRMConsole\Queries.cs:line 142 
     at CRMConsole.Program.Main(String[] args) in D:\Projects\CRM\CRMPrivileges\CRMConsole\Program.cs:line 20 
     at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) 
     at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
     at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
     at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
     at System.Threading.ThreadHelper.ThreadStart() 
    InnerException: 

나는 계정 개체에 대한 사용자 액세스를 확인하고, 그 사용자 깊이 그것에 읽기 액세스 할 수 있습니다. 그 외에도 crm 웹 페이지 UI에서이 엔티티를 연결 자격 증명에있는 현재 사용자와 공유 할 수 있습니다.

+0

이 오류 메시지의 정확한 문구를 확인할 수 있습니까? 아마도 스택 추적과 함께 전체 오류 메시지를 게시하십시오. 또한, 'principleId'에 의해 참조 된 사용자는 공유되는 엔티티 유형에 대한 읽기 - 소유자 권한을 갖습니다. – Nicknow

+0

Edit1에서 자세한 내용을 작성했습니다. –

+0

CRM에 연결하는 데 사용하는 사용자, 즉 연결 문자열의 사용자 이름에 CRM에 어떤 사용 권한이 있습니까? – Nicknow

답변

0

너무 말도 안돼 그러나 문제는 코드이 줄을이었다

Principal = new EntityReference(principleId.ToString()) 

은 우리가 같은 개체 이름을 선언해야합니다 :

Principal = new EntityReference(SystemUser.EntityLogicalName,principleId)