Answered by:
Connect to Organization service authentication issue using SDK code?

Question
-
I am trying to run the SDK project using WSDL to connect to online CRM with live id.
It worked fine for Connecting Discovery Service. Failed with Organization Service - exceptions when executing WhoAmI request:
"ID3242: The security token could not be authenticated or authorized."
OrganizationRequest request = new OrganizationRequest(); request.RequestName = "WhoAmI"; OrganizationResponse response = (OrganizationResponse)client.Execute(request);
I followed the setup.txt file.Thanks,
Thursday, February 2, 2012 5:34 PM
Answers
-
You should be able to change the sample project in wsdlbasedproxies folder to target .NET Framework 3.5. You can right click the project in solution explorer, and change "Target framework" so that it targets .NET framework 3.5.
Daniel Cai | http://danielcai.blogspot.com | Follow @danielwcai- Marked as answer by Guangming Monday, February 6, 2012 8:54 PM
Friday, February 3, 2012 10:47 PM
All replies
-
Did you configure OrganizationServiceProxy object correctly?
daemon linThursday, February 2, 2012 6:38 PM -
1.8.3.2
MVDThursday, February 2, 2012 6:40 PM -
Are you connecting to an Online instance hosted outside of North America ? If so, have a look at http://mscrmuk.blogspot.com/2012/01/using-wsdl-proxies-with-crm-online-its.html
Microsoft CRM MVP - http://mscrmuk.blogspot.com http://www.excitation.co.uk- Edited by DavidJennawayMVP, Moderator Thursday, February 2, 2012 9:49 PM
Thursday, February 2, 2012 9:45 PMModerator -
it should be in NA. Here is from Discovery WSDL (BTW Organization WSDL does not have similar node though):
so I used urn:crmna:dynamics.com in program.cs.
<ms-xrm:AuthenticationPolicy xmlns:ms-xrm="http://schemas.microsoft.com/xrm/2011/Contracts/Services"><ms-xrm:Authentication>LiveId</ms-xrm:Authentication><ms-xrm:SecureTokenService><ms-xrm:Identifier>uri:WindowsLiveID</ms-xrm:Identifier><ms-xrm:LiveTrust><ms-xrm:AppliesTo>urn:crmna:dynamics.com</ms-xrm:AppliesTo><ms-xrm:TrustVersion>WSTrustFeb2005</ms-xrm:TrustVersion><ms-xrm:SecurityMode>TransportWithMessageCredential</ms-xrm:SecurityMode><ms-xrm:LivePolicy>MBI_FED_SSL</ms-xrm:LivePolicy><ms-xrm:LiveIdAppliesTo>http://Passport.NET/tb</ms-xrm:LiveIdAppliesTo></ms-xrm:LiveTrust></ms-xrm:SecureTokenService></ms-xrm:AuthenticationPolicy>
Friday, February 3, 2012 7:02 PM -
I did not that. I am using that wsdl based proxies demo located at ..\SDK\samplecode\cs\wsdlbasedproxies\online\ folder.
I tried the quickstart one and it works perfectly.
Friday, February 3, 2012 7:04 PM -
not sure whay you meant here?Friday, February 3, 2012 7:05 PM
-
I figured it out why.
Here is something funny I found with the help from David's post:
I tried arbitrarily to use
"urn:crm:dynamics.com" for Organization - WORKED!, and urn:crmna:dynamics.com (this is from WSDL!!!) for Discovery.
However, I was stuck in another issue. My project is to create a SharePoint Timer Job to check one entity in CRM and then update a list in SharePoint. The problem here is SharePoint project is .net Framework 3.5; and the SDK sample is .net Framework 4.0.
Is there any way to trweak the WSDL based project to based on Framework 3.5?
The other solution is go with pure SOAP client with wrappers - it would be too much work to make a request though!
http://code.msdn.microsoft.com/CRM-Online-2011-WebServices-14913a16
Any recommendation on the architect direction?
thanks,
Friday, February 3, 2012 10:01 PM -
You should be able to change the sample project in wsdlbasedproxies folder to target .NET Framework 3.5. You can right click the project in solution explorer, and change "Target framework" so that it targets .NET framework 3.5.
Daniel Cai | http://danielcai.blogspot.com | Follow @danielwcai- Marked as answer by Guangming Monday, February 6, 2012 8:54 PM
Friday, February 3, 2012 10:47 PM -
with little bit of tweaks:
changed one special folder referred to Environment.SpecialFolder.ApplicationData from
Environment.SpecialFolder.UserProfile on windows 7Monday, February 6, 2012 8:57 PM