Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

Dynamics CRM 2013: connection through IFD using the SDK fails with ADFS

$
0
0
public static string[] AuthenticateToCrm(string organization, string username, string password)
        {

            CrmConnection crmConnection = CrmConnection.Parse(String.Format("Url=https://{0}.acom.be:443; Username={1}; Password={2}", organization, username, password));
            UnitOfWorkHelper.CurrentDataStore = new HttpContextDataStore();
            // Get the organization service proxy.
            //_credentials = new ClientCredentials();
            //_credentials.Windows.ClientCredential = new NetworkCredential(username, password);
            using (OrganizationService organizationProxy = new OrganizationService(crmConnection))
            {
            Guid userid = ((WhoAmIResponse)organizationProxy.Execute(new WhoAmIRequest())).UserId;

The above code fails on the WhoAmIRequest() when accessing our Dynamics CRM 2013 installation using ADFS with an IFD. We can still access our CRM using the website, but when we try to connect using the SDK, it fails, but only when using the IFD. When we are on the internal network, it works just fine. We tried both with an external website on Azure, a clickonce app connecting with a VPN from the outside, and both of these on a local development machine. it works fine when we use the local machine, but when we try to connect from outside, it fails.

The error we get is:

[SocketException (0x274c): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 31.193.178.74:80]
   System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +208
   System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +464

[WebException: Unable to connect to the remote server]
   System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) +6532257
   System.Net.HttpWebRequest.GetRequestStream() +13
   System.ServiceModel.Channels.WebRequestHttpOutput.GetOutputStream() +55

[EndpointNotFoundException: There was no endpoint listening at http://fed.acom.be/adfs/services/trust/13/username that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.]
   System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +10736583
   System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +336
   Microsoft.IdentityModel.Protocols.WSTrust.IWSTrustContract.Issue(Message message) +0
   Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.Issue(RequestSecurityToken rst, RequestSecurityTokenResponse& rstr) +41
   Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1.Issue(AuthenticationCredentials authenticationCredentials) +773
   Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1.AuthenticateInternal(AuthenticationCredentials authenticationCredentials) +409
   Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1.AuthenticateFederationInternal(AuthenticationCredentials authenticationCredentials) +223
   Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1.Authenticate(AuthenticationCredentials authenticationCredentials) +150
   Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1.Authenticate(ClientCredentials clientCredentials) +79
   Microsoft.Xrm.Sdk.Client.OrganizationServiceConfiguration.Authenticate(ClientCredentials clientCredentials) +10
   Microsoft.Xrm.Client.Services.OrganizationService.CreateUserTokenResponse(CrmConnection connection, IServiceConfiguration`1 config) +507
   Microsoft.Xrm.Client.Services.OrganizationService.GetUserTokenResponse(CrmConnection connection, IServiceConfiguration`1 config) +238
   Microsoft.Xrm.Client.Services.OrganizationService.ToOrganizationServiceProxy(CrmConnection connection) +150
   Microsoft.Xrm.Client.Services.OrganizationService.ToOrganizationService(CrmConnection connection) +10
   Microsoft.Xrm.Client.Services.<>c__DisplayClass2.<.ctor>b__0() +18
   System.Lazy`1.CreateValue() +180
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +22
   System.Lazy`1.get_Value() +10896525
   Microsoft.Xrm.Client.Services.InnerOrganizationService.get_Value() +104
   Microsoft.Xrm.Client.Services.OrganizationService.Dispose() +13
   aca.crm2011.sendgrid.CrmConnector.AuthenticateToCrm(String organization, String username, String password) in e:\VS\tfs_cp\Acasa\SendGrid\Main\aca.crm2011.sendgrid\aca.crm2011.sendgrid\Old_App_Code\CrmConnector.cs:44
   aca.crm2011.sendgrid.Account.Login.OnAuthenticate(Object sender, AuthenticateEventArgs e) in e:\VS\tfs_cp\Acasa\SendGrid\Main\aca.crm2011.sendgrid\aca.crm2011.sendgrid\Account\Login.aspx.cs:18
   System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +9856026
   System.Web.UI.WebControls.Login.AttemptLogin() +119
   System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +75
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +114
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +252
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35

We don't know what causes it. I've checked the mentioned endpoint and that gives a 404 on http and a service unavailable on HTTPS.

Does anyone have any suggestions on what to do with this?


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>