venerdì 17 ottobre 2008 16:44
Is there a way to grab the CRM Database Name associated with an instance of CrmService?
For example, ideally would be something like below:
CrmService service = CrmServiceUtility.GetCrmService("CRM Server URL", " CRM Organization Name");
DatabaseInfo db = service.getAssociatedDatabase();
Tutte le risposte
venerdì 17 ottobre 2008 17:53Proprietario
You can only use CrmDeploymentService to get the database name.
venerdì 17 ottobre 2008 18:00You can try as
Add Web Reference: http://<server>/MSCRMServices/2007/CrmDeploymentService.asmx in your project
Create a class
public class CustomCrmService
public string getAssociatedDatabase(string organizationEntity)
CrmDeploymentService oService = new CrmDeploymentService();
oService.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
RetrieveAllRequest oReq = new RetrieveAllRequest();
oReq.EntityName = EntityName.Organization;
RetrieveAllResponse resp = (RetrieveAllResponse)oService.Execute(oReq);
string strDataBaseName = string.Empty;
foreach (Organization item in resp.Entities)
strDataBaseName = item.DatabaseName;
Call the method getAssociatedDatabase
CustomCrmService oService = new CustomCrmService();
string databaseName = oService.getAssociatedDatabase("Organization Name");
Maykon AlvesSpecialist Dynamics CRM - Brazil
sabato 18 ottobre 2008 15:08
Thank you. This is almost exactly what I needed.
One question though. It appears that DeploymentMangerService will fail with DefaultNetworkCredentials unless the logged in user has been added as a Deployment Manager.
Is there any way around this? I can hard code in the application administrator (see below), but I'd really prefer not too. I need it to be as flexible as possible.
oService.Credentials = new System.Net.NetworkCredential("CRMAPPADMIN", "CRMAPPADMIN");
sabato 18 ottobre 2008 16:58
You can add the user in Deployment Manager -> Deplyoment Administrators, so these users can access the web service. But in this scenario, the users would have the privilege to administrate CRM installation. This is not a best pratice.
The best option is to add the criptographed user and password in a config file and use this information only when you need.
CRM Specialist - Brazil