Hello,
I have been pulling my hair out over last week trying to resolve this issue. After configuring IFD on dynamics 365 server on premise. I am able to log in via browser with no issue, but when i use sdk, particularly CrmServiceClient to connect i get the following error. ID3242: The security token could not be authenticated or authorized. I am sure the username and password are correct, i have tried with multiple different users and different username formatting (domain\user , user, user@domain.com) all resulting in same error. I am able to login using the login login test however and got the following output:
Microsoft.Xrm.Tooling.CrmConnectControl Information: 8 : Created CrmConnectionManager Microsoft.Xrm.Tooling.CrmConnectControl Information: 8 : CheckBoxState = False Microsoft.Xrm.Tooling.CrmConnectControl Information: 8 : CheckBoxState = False Microsoft.Xrm.Tooling.CrmConnectControl Information: 8 : Using CRM deployment type Prem Microsoft.Xrm.Tooling.CrmConnectControl Information: 8 : SSL Connection = True Microsoft.Xrm.Tooling.CrmConnectControl Information: 8 : Discovery URI is = cgecrm.cge-led.ca/.../Discovery.svc Microsoft.Xrm.Tooling.Connector.CrmServiceClient Information: 8 : DiscoverOrganizations - Initializing Discovery Server Object with cgecrm.cge-led.ca/.../Discovery.svc Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : DiscoverOrganizations - attempting to connect to CRM server @ cgecrm.cge-led.ca/.../Discovery.svc Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : DiscoverOrganizations - created CRM server proxy configuration for cgecrm.cge-led.ca/.../Discovery.svc - duration: 00:00:00.7184254 Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : DiscoverOrganizations - proxy requiring authentication type : Federation Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : DiscoverOrganizations - Authenticated via Federation. Auth Elapsed:00:00:00.1253930 Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : DiscoverOrganizations - service proxy created - total create duration: 00:00:00.8463114 Microsoft.Xrm.Tooling.Connector.CrmServiceClient Information: 8 : DiscoverOrganizations - Discovery Server Get Orgs Call Complete - Elapsed:00:00:00.9008526 Microsoft.Xrm.Tooling.CrmConnectControl Information: 8 : Found 1 Org(s) Microsoft.Xrm.Tooling.CrmConnectControl Verbose: 16 : DiscoveryServer indicated organization service location = cgecrm.cge-led.ca/.../Organization.svc Microsoft.Xrm.Tooling.CrmConnectControl Information: 8 : Organization Service URI is = cgecrm.cge-led.ca/.../Organization.svc Microsoft.Xrm.Tooling.CrmConnectControl Information: 8 : Validating connection to Microsoft Dynamics CRM... Microsoft.Xrm.Tooling.Connector.CrmServiceClient Information: 8 : Process is bypassed.. OrgDetail object was provided Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : DiscoveryServer indicated organization service location = cgecrm.cge-led.ca/.../Organization.svc Microsoft.Xrm.Tooling.Connector.CrmServiceClient Information: 8 : Organization Service URI is = cgecrm.cge-led.ca/.../Organization.svc Microsoft.Xrm.Tooling.Connector.CrmServiceClient Information: 8 : ConnectAndInitCrmOrgService - Initializing Organization Service Object Microsoft.Xrm.Tooling.Connector.CrmServiceClient Information: 8 : ConnectAndInitCrmOrgService - Requesting connection to Org with CRM Version: 8.2.1.176 Microsoft.Xrm.Tooling.Connector.CrmServiceClient Information: 8 : ConnectAndInitCrmOrgService - Using ISerivceManagement Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : ConnectAndInitCrmOrgService - attempting to connect to CRM server @ cgecrm.cge-led.ca/.../Organization.svc Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : ConnectAndInitCrmOrgService - created CRM server proxy configuration for cgecrm.cge-led.ca/.../Organization.svc - duration: 00:00:00.2722966 Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : ConnectAndInitCrmOrgService - proxy requiring authentication type : Federation Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : ConnectAndInitCrmOrgService - Authenticated via Federation. Auth Elapsed:00:00:00.0433442 Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : ConnectAndInitCrmOrgService - service proxy created - total create duration: 00:00:00.3171417 Microsoft.Xrm.Tooling.Connector.CrmServiceClient Information: 8 : ConnectAndInitCrmOrgService - Proxy created, total elapsed time: 00:00:00.3171417 Microsoft.Xrm.Tooling.Connector.CrmServiceClient Information: 8 : Beginning Validation of CRM Connection Microsoft.Xrm.Tooling.Connector.CrmServiceClient Information: 8 : Validation of CRM Connection Complete, total duration: 00:00:00.1209141 Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : New Batch Manager Created, Max #of Batches:50000, Max #of RequestsPerBatch:5000 Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : Claims Connection Token Debug: SecurityToken is Not Null Current Time is: 08/15/2017 13:11:03 + 2 Min for ValidFrom Check Only Token ValidFrom is 08/15/2017 13:14:14, Is Valid = False Token ValidTo is 08/15/2017 14:14:14, Is Valid = True Microsoft.Xrm.Tooling.Connector.CrmServiceClient Warning: 4 : Claims Connection reset tripped SecurityToken is Not Null Start From is Valid False End At is Valid True Microsoft.Xrm.Tooling.Connector.CrmServiceClient Warning: 4 : Re-Authenticating due to expired token @ 08/15/2017 09:11:03 Microsoft.Xrm.Tooling.Connector.CrmServiceClient Warning: 4 : Claims Connection reset tripped SecurityToken is Not Null Start From is Valid False End At is Valid True Microsoft.Xrm.Tooling.Connector.CrmServiceClient Warning: 4 : Re-Authenticating due to expired token @ 08/15/2017 09:11:04 Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : Executed Command - RetrieveEntity : GetEntityMetadata : duration: 00:00:00.1852494
And i get the following when trying to connect with console application:
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Information: 8 : Discovery URI is = cgecrm.cge-led.ca/.../Discovery.svc Microsoft.Xrm.Tooling.Connector.CrmServiceClient Information: 8 : DiscoverOrganizations - Initializing Discovery Server Object with cgecrm.cge-led.ca/.../Discovery.svc Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : DiscoverOrganizations - attempting to connect to CRM server @ cgecrm.cge-led.ca/.../Discovery.svc'CRMSimpleConsole4.vshost.exe' (CLR v4.0.30319: CRMSimpleConsole4.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Transactions\v4.0_4.0.0.0__b77a5c561934e089\System.Transactions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.'CRMSimpleConsole4.vshost.exe' (CLR v4.0.30319: CRMSimpleConsole4.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.VisualStudio.Diagnostics.ServiceModelSink\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Diagnostics.ServiceModelSink.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.'CRMSimpleConsole4.vshost.exe' (CLR v4.0.30319: CRMSimpleConsole4.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Channels\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Channels.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.'CRMSimpleConsole4.vshost.exe' (CLR v4.0.30319: CRMSimpleConsole4.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : DiscoverOrganizations - created CRM server proxy configuration for cgecrm.cge-led.ca/.../Discovery.svc - duration: 00:00:01.6441543 Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : DiscoverOrganizations - proxy requiring authentication type : Federation'CRMSimpleConsole4.vshost.exe' (CLR v4.0.30319: CRMSimpleConsole4.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel.Selectors\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.Selectors.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.'CRMSimpleConsole4.vshost.exe' (CLR v4.0.30319: CRMSimpleConsole4.vshost.exe): Loaded 'C:\ApplicationDevelopment\CRMSimpleConsole4\CRMSimpleConsole4\bin\Debug\Microsoft.Xrm.Sdk.Deployment.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Source : System.ServiceModel Method : ReadResponse Date : 8/15/2017 Time : 9:29:32 AM Error : ID3242: The security token could not be authenticated or authorized. Stack Trace : at System.ServiceModel.Security.WSTrustChannel.ReadResponse(Message response) at System.ServiceModel.Security.WSTrustChannel.Issue(RequestSecurityToken rst, RequestSecurityTokenResponse& rstr) at Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1.Issue(AuthenticationCredentials authenticationCredentials) at Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1.AuthenticateInternal(AuthenticationCredentials authenticationCredentials) at Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1.AuthenticateFederationInternal(AuthenticationCredentials authenticationCredentials) at Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1.Authenticate(AuthenticationCredentials authenticationCredentials) at Microsoft.Xrm.Sdk.Client.DiscoveryServiceConfiguration.Authenticate(AuthenticationCredentials authenticationCredentials) at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.ClaimsIFDFailOverAuth[T](IServiceManagement`1 servicecfg, Uri homeRealm, ClientCredentials userCredentials, ClientCredentials deviceCredentials, Int32 depthLevel, Boolean tryNetworkCred) at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.CreateAndAuthenticateProxy[T](IServiceManagement`1 servicecfg, Uri ServiceUri, Uri homeRealm, ClientCredentials userCredentials, ClientCredentials deviceCredentials, String LogString) at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.DiscoverOrganizations(Uri discoveryServiceUri, Uri homeRealmUri, ClientCredentials clientCredentials, ClientCredentials deviceCredentials) at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.DiscoverOrganizations(Uri discoveryServiceUri, Uri homeRealmUri, NetworkCredential networkCredential) at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.InitCRM2011Service() ====================================================================================================================== Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Unable to Login to Dynamics CRM