Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Authenticated to CRM but getting authentication error when requesting via SDK

$
0
0

Hello, 

I'm having trouble making request to the CRM through the CRM SDK (Dynamics 2016 onPremise) even if the service object is telling that I'm authenticated. 

Here is the simple connexion and "WhoAmI" request:

ClientCredentials credentials = new ClientCredentials();
credentials.Windows.ClientCredential = (NetworkCredential)CredentialCache.DefaultNetworkCredentials;

IServiceConfiguration<IOrganizationService> serviceConfiguration = ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(new Uri(string.Format("{0}/{1}/XRMServices/2011/Organization.svc", Properties.Settings.Default.CrmServer, Properties.Settings.Default.CrmOrganisation)));
var serviceProxy = new OrganizationServiceProxy(serviceConfiguration, credentials) { Timeout = new TimeSpan(0, 10, 0) };
serviceProxy.EnableProxyTypes();

log.Info("IS AUTHENTICATED" + serviceProxy.IsAuthenticated);
log.Info("CHECKING USER");

WhoAmIResponse rep = (WhoAmIResponse)serviceProxy.Execute(new WhoAmIRequest());
var user = rep.UserId;

log.Info("WhoAmI request" + user.ToString());

It logs that I'm authenticated "IS AUTHENTICATED: True" but when executing the request, I'm getting the following error:

"System.ServiceModel.Security.SecurityNegociationException: The caller was not authenticated by the service"

What I'm doing wrong ? 


Viewing all articles
Browse latest Browse all 46379

Trending Articles



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