is this is correct code for CRM 4 Authenication on Primes
-
19 Mayıs 2012 Cumartesi 09:58
1.is this code is corrrect for CRM 4(onPrimes) Authentication on Active Directory
2.i am not get the CrmDiscoveryService class and there is no reference .Dll in the CRM SDK 4 from where i includ it..........
// STEP 1: Instantiate and configure the CrmDiscoveryService Web service. CrmDiscoveryService discoveryService = new CrmDiscoveryService(); discoveryService.UseDefaultCredentials = true; discoveryService.Url = "http://localhost/MSCRMServices/2007/AD/CrmDiscoveryService.asmx"; // STEP 2: Retrieve the desired organization name and endpoint URL from the // CrmDiscoveryService Web service. RetrieveOrganizationsRequest orgRequest = new RetrieveOrganizationsRequest(); RetrieveOrganizationsResponse orgResponse = (RetrieveOrganizationsResponse)discoveryService.Execute(orgRequest); OrganizationDetail orgInfo = null; foreach (OrganizationDetail orgDetail in orgResponse.OrganizationDetails) { if (orgDetail.OrganizationName.Equals("AdventureWorksCycle")) { orgInfo = orgDetail; break; } } if (orgInfo == null) throw new Exception("The organization name is invalid."); // STEP 3: Create and configure an instance of the CrmService Web service. CrmAuthenticationToken token = new CrmAuthenticationToken(); token.AuthenticationType = 0; // See Microsoft.Crm.Sdk.AuthenticationType token.OrganizationName = orgInfo.OrganizationName; CrmService crmService = new CrmService(); crmService.Url = orgInfo.CrmServiceUrl; crmService.CrmAuthenticationTokenValue = token; crmService.Credentials = System.Net.CredentialCache.DefaultCredentials; // STEP 4: Invoke a CrmService Web service method. WhoAmIRequest whoRequest = new WhoAmIRequest(); WhoAmIResponse whoResponse = (WhoAmIResponse)crmService.Execute(whoRequest);
Tüm Yanıtlar
-
19 Mayıs 2012 Cumartesi 11:02
Hi Sohail,
Your code seemed OK, its from the sdk sample: http://msdn.microsoft.com/en-us/library/cc151053.aspx
Here is the msdn article to add the CrmDiscoveryServer Web reference: http://msdn.microsoft.com/en-us/library/cc151009.aspx
Eric UNG [Senior Analyst Programmer :: Sydney, Australia]
-
21 Mayıs 2012 Pazartesi 04:01
Hi Sohail,
Yep. Your code is correct. If you already know the details of the CRM Server you are connecting to, you can reduce a few seconds by going straight to Step 3. The Step 1 and 2 is only required if you don't know both the URL of the CRM Server and the organization name.
I hope this helps. If my response answered your question, please mark the response as an answer and also vote as helpful.
Dimaz Pramudya - CRM Developer - CSG (Melbourne) www.xrmbits.com http://twitter.com/xrmbits
- Yanıt Olarak Öneren Dimaz Pramudya (www.xrmbits.com) 21 Mayıs 2012 Pazartesi 04:01
- Yanıt Olarak İşaretleyen sohail450 15 Haziran 2012 Cuma 09:22