13. April 2011 12:17
CrmService _crmService = null;
public CrmService crmService
{
get
{
if (_crmService == null)
{
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.OrganizationName = CRMORGANISATION;
token.AuthenticationType = AuthenticationType.AD;
CrmService service = new CrmService();
service.Url = crmServerUri;
service.CrmAuthenticationTokenValue = token;
System.Net.NetworkCredential cred = new System.Net.NetworkCredential();
cred.Domain = base64Decode(ConfigurationSettings.AppSettings["DOMAIN"]);
cred.UserName = base64Decode(ConfigurationSettings.AppSettings["USER"]);
cred.Password = base64Decode(ConfigurationSettings.AppSettings["PASS"]);
service.Credentials = cred;
return service;
}
else
return _crmService;
}
}
13. April 2011 12:31
13. April 2011 12:34
13. April 2011 12:46
15. April 2011 15:27
System.ServiceModel.Description.ClientCredentials credentials = new System.ServiceModel.Description.ClientCredentials();
credentials.Windows.ClientCredential = new System.Net.NetworkCredential("username", "pwd", "domain");
Uri organizationUri = new Uri("http://server/org/XRMServices/2011/Organization.svc");
Uri homerealmuri = null;
OrganizationServiceProxy orgService = new OrganizationServiceProxy(organizationUri, homerealmuri, credentials, null);
IOrganizationService crmService = (IOrganizationService)orgService;
QueryExpression query = new QueryExpression("Account");
query.ColumnSet.AllColumns = true;
crmService.RetrieveMultiple(query);
OrganizationServiceClient orgClient;
orgClient = new OrganizationServiceClient();
orgClient.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("username", "pwd", "domain");
QueryExpression qb = new QueryExpression();
qb.EntityName = "account";
qb.ColumnSet = new ColumnSet().AllColumns; //hier funktioniert das auch nicht so wie im SDK! ->query.ColumnSet.AllColumns = true;
orgClient.RetrieveMultiple(qb);