Friday, October 2, 2009

Connect to CRM 1.2

#region "Connect to CRM 1.2"
///
/// This fucntion will connect to CRM 1.2
///

/// After sucessfully connection it will return CRM 1.2 user authentication
private Microsoft.CRM.Proxy.CUserAuth connectToCRM()
{
// BizUser proxy object
Microsoft.CRM.Proxy.BizUser bizUser = new Microsoft.CRM.Proxy.BizUser();
bizUser.Credentials = new System.Net.NetworkCredential(userName, password, domain);
bizUser.Url = strDir + "BizUser.srf";

try
{
userAuth = bizUser.WhoAmI();
//MessageBox.Show("Sucessfully connected to CRM 1.2");
}
catch (System.Web.Services.Protocols.SoapException ex)
{
MessageBox.Show("Unable to connect to CRM 1.2, Please check CRM 1.2 details.", ex.Message.ToString());
return null;
}

return userAuth;
}

#endregion

No comments: