It is quite easy to create an account in MS CRM using its interface but, if there is a need, it can also be achieved programmatically using its web services.
This is helpful in situations where one doesn’t have the access to the MS CRM Server. But one needs to add the following web service URL to the application.
http://<Server Name: Port>/MSCRMServices/2007/CrmServiceWsdl.aspx
And enter CrmSdk as the Web Reference Name.
VB.Net
Dim MFSCrm As New CrmSdk.CrmService MFSCrm.Url = GetCrmServiceForOrganization(OrgName)'Organization name. Dim MFSToken As New CrmSdk.CrmAuthenticationToken MFSToken.AuthenticationType = 0 MFSToken.OrganizationName = OrgName MFSCrm.CrmAuthenticationTokenValue = MFSToken Dim sn As New System.Net.NetworkCredential sn.UserName = "***" 'CRM Server User Name sn.Password = "*********" 'CRM Server Password sn.Domain = "*******" 'CRM Server Domain name MFSCrm.Credentials = sn Dim newAccountId As Guid Dim newAccount As New CrmSdk.account newAccount.name = AccName ' Name of the account to be created newAccountId = MFSCrm.Create(newAccount)
C#.Net
CrmSdk.CrmService MFSCrm = new CrmSdk.CrmService(); MFSCrm.Url = GetCrmServiceForOrganization(OrgName); CrmSdk.CrmAuthenticationToken MFSToken = new CrmSdk.CrmAuthenticationToken(); MFSToken.AuthenticationType = 0; MFSToken.OrganizationName = organizationName; MFSCrm.CrmAuthenticationTokenValue = MFSToken; System.Net.NetworkCredential sn = new System.Net.NetworkCredential(); sn.UserName = "***"; sn.Password = "*********"; sn.Domain = "***"; MFSCrm.Credentials = sn; CrmSdk.account newAccount = new CrmSdk.account(); newAccount.name = accountName; Guid newAccountId = MFSCrm.Create(newAccount);