Answered by:
Urgent : How to authenticate and retrieve data from Microsoft Dynamics CRM 2011 (Web)

Question
-
Hello All,
I am new to Microsoft Dynamics CRM. I added SOAP service reference in my project like "https://SERVERNAME/XRMServices/2011/Organization.svc" named "MicrosoftDynamicsCRMSoapService" and I am able to create client object as :
Now can you please tell me that how to authenticate and access data (like account, contact etc) using this client object ?MicrosoftDynamicsCRMSoapService.OrganizationServiceClient organizationServiceClient =
new MicrosoftDynamicsCRMSoapService.OrganizationServiceClient();
- Edited by JaiHariHar Friday, August 23, 2013 9:09 AM
Friday, August 23, 2013 7:53 AM
Answers
-
Hi,
credentials.UserName.UserName = ConfigurationManager.AppSettings["username"];
credentials.UserName.Password = ConfigurationManager.AppSettings["userPassword"];
deviceCredentials.UserName.UserName = ConfigurationManager.AppSettings["dusername"];
deviceCredentials.UserName.Password = ConfigurationManager.AppSettings["duserid"]; organizationUri = new Uri(ConfigurationManager.AppSettings["orgurl"]);
homeRealmUri = null;
using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, deviceCredentials))
{
IOrganizationService service = (IOrganizationService)serviceProxy;// your Code ....
}
Refer the below links it will helps you,
http://kellyhoang.blogspot.in/2012/06/crm-2011-online-authentication-for.html
http://www.c-sharpcorner.com/UploadFile/aravindbenator/crm-2011-online/
http://msdn.microsoft.com/en-us/library/gg509027.aspx
- Marked as answer by JaiHariHar Friday, August 23, 2013 2:28 PM
Friday, August 23, 2013 9:15 AM -
To authenticate and Retrieve data (e.g. opportunity, contact, account), I am now using following type of code :
#region Authenticate and Retrieve Details from the CRM #region Authentication and Proxy Creation string UserName = "username"; //your Windows Live ID or Microsoft Dynamics CRM ID string Password = "password"; // your password Uri OrganizationUri = new Uri("https://SERVERNAME/XRMServices/2011/Organization.svc"); ClientCredentials Credentials = new ClientCredentials(); Credentials.UserName.UserName = UserName; Credentials.UserName.Password = Password; //OrganizationServiceProxy serviceProxy; using (OrganizationServiceProxy serviceProxy =
new OrganizationServiceProxy(OrganizationUri, null, Credentials, GetDeviceCredentials())) { IOrganizationService service = (IOrganizationService)serviceProxy; #endregion Authentication and Proxy Creation #region Query expression //opportunityQuery QueryExpression opportunityQuery = new QueryExpression { EntityName = "opportunity", ColumnSet = new ColumnSet("name") }; //accountQuery QueryExpression accountQuery = new QueryExpression { EntityName = "account", ColumnSet = new ColumnSet("name") }; //contactQuery QueryExpression contactQuery = new QueryExpression { EntityName = "contact", ColumnSet = new ColumnSet("fullname") }; #endregion Query expression #region Retrieving Records var opportunities = service.RetrieveMultiple(opportunityQuery); var accounts = service.RetrieveMultiple(accountQuery); var contacts = service.RetrieveMultiple(contactQuery);
#endregion Retrieving Records
#endregion Authenticate and Retrieve Details from the CRM
- Marked as answer by JaiHariHar Friday, August 23, 2013 2:38 PM
- Edited by JaiHariHar Friday, August 23, 2013 2:41 PM
Friday, August 23, 2013 2:36 PM
All replies
-
Hi,
credentials.UserName.UserName = ConfigurationManager.AppSettings["username"];
credentials.UserName.Password = ConfigurationManager.AppSettings["userPassword"];
deviceCredentials.UserName.UserName = ConfigurationManager.AppSettings["dusername"];
deviceCredentials.UserName.Password = ConfigurationManager.AppSettings["duserid"]; organizationUri = new Uri(ConfigurationManager.AppSettings["orgurl"]);
homeRealmUri = null;
using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, deviceCredentials))
{
IOrganizationService service = (IOrganizationService)serviceProxy;// your Code ....
}
Refer the below links it will helps you,
http://kellyhoang.blogspot.in/2012/06/crm-2011-online-authentication-for.html
http://www.c-sharpcorner.com/UploadFile/aravindbenator/crm-2011-online/
http://msdn.microsoft.com/en-us/library/gg509027.aspx
- Marked as answer by JaiHariHar Friday, August 23, 2013 2:28 PM
Friday, August 23, 2013 9:15 AM -
Thanks a lot B sreenivasulu, the links were very helpful for me.
- Edited by JaiHariHar Friday, August 23, 2013 2:32 PM
Friday, August 23, 2013 2:31 PM -
To authenticate and Retrieve data (e.g. opportunity, contact, account), I am now using following type of code :
#region Authenticate and Retrieve Details from the CRM #region Authentication and Proxy Creation string UserName = "username"; //your Windows Live ID or Microsoft Dynamics CRM ID string Password = "password"; // your password Uri OrganizationUri = new Uri("https://SERVERNAME/XRMServices/2011/Organization.svc"); ClientCredentials Credentials = new ClientCredentials(); Credentials.UserName.UserName = UserName; Credentials.UserName.Password = Password; //OrganizationServiceProxy serviceProxy; using (OrganizationServiceProxy serviceProxy =
new OrganizationServiceProxy(OrganizationUri, null, Credentials, GetDeviceCredentials())) { IOrganizationService service = (IOrganizationService)serviceProxy; #endregion Authentication and Proxy Creation #region Query expression //opportunityQuery QueryExpression opportunityQuery = new QueryExpression { EntityName = "opportunity", ColumnSet = new ColumnSet("name") }; //accountQuery QueryExpression accountQuery = new QueryExpression { EntityName = "account", ColumnSet = new ColumnSet("name") }; //contactQuery QueryExpression contactQuery = new QueryExpression { EntityName = "contact", ColumnSet = new ColumnSet("fullname") }; #endregion Query expression #region Retrieving Records var opportunities = service.RetrieveMultiple(opportunityQuery); var accounts = service.RetrieveMultiple(accountQuery); var contacts = service.RetrieveMultiple(contactQuery);
#endregion Retrieving Records
#endregion Authenticate and Retrieve Details from the CRM
- Marked as answer by JaiHariHar Friday, August 23, 2013 2:38 PM
- Edited by JaiHariHar Friday, August 23, 2013 2:41 PM
Friday, August 23, 2013 2:36 PM