System.ServiceModel.Security.SecurityAccessDeniedException was caught RRS feed

  • Question

  • Hi All,

    I am getting the below issue when i try to connect to crm to console app. I am just running a simple test connect, passing username, password, url to the server.

    whoAmIRequest  whoAmIRequest = new WhoAmIRequest();

    WhoAmIResponse whoAmIResponse = (WhoAmIResponse)orgservice.Execute(whoAmIRequest);

    when debugging, it failed just after i passed the WhoAmIResponse line. Do you guys have any idea what the problem is? i have been googling over and over and still can't solve it. Please help.


    ================error below==================

    System.ServiceModel.Security.SecurityAccessDeniedException was caught
      Message=Access is denied.
        Server stack trace: 
           at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
           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)

    Thursday, February 5, 2015 6:44 PM

All replies

  • Hello,

    Could you please provide a code you use to get orgservice?

    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog

    Friday, February 6, 2015 6:03 AM
  • Hi

    getting usernmae, password domain and org from config.

    clientCredentialsTest.Windows.ClientCredential = new System.Net.NetworkCredential(userName, password, domain);

    using (orgServiceProxy = new OrganizationServiceProxy(new Uri(org), null, clientCredentialsTest, null))
                        #region Connecting to CRM
                        orgservice = (IOrganizationService)orgServiceProxy;
                        whoAmIRequest  whoAmIRequest = new WhoAmIRequest();
                        WhoAmIResponse whoAmIResponse = (WhoAmIResponse)orgservice .Execute(whoAmIRequest);

    Friday, February 6, 2015 6:47 AM