Мы недавно настроили наш Dynamics CRM для использования ADFS для IFD. Мы пытаемся подключиться к нему с .Net 3.5, поэтому мы не можем использовать CRM SDK. Ниже приведен код, который мы использовали перед настройкой IFD, и он работал нормально.Подключение к Dynamics CRM с IFD без использования SDK
HttpsTransportBindingElement httpTransport = new HttpsTransportBindingElement();
httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Ntlm;
httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
httpTransport.MaxReceivedMessageSize = 1024 * 1024 * 1024;
SecurityBindingElement securityElement = SecurityBindingElement.CreateSspiNegotiationBindingElement(true);
TextMessageEncodingBindingElement textMessageEncoding = new TextMessageEncodingBindingElement();
textMessageEncoding.MaxReadPoolSize = 64;
textMessageEncoding.MaxWritePoolSize = 16;
textMessageEncoding.WriteEncoding = Encoding.UTF8;
CustomBinding customBinding = new CustomBinding(securityElement, textMessageEncoding, httpTransport);
customBinding.OpenTimeout = new TimeSpan(0, 0, 120);
customBinding.ReceiveTimeout = new TimeSpan(0, 0, 120);
customBinding.SendTimeout = new TimeSpan(0, 0, 120);
string remoteAddress = String.Empty;
remoteAddress = "https://" + ServiceUri + "/OrgName/XrmServices/2011/Organization.svc";
ChannelFactory<IOrganizationService> factory = new ChannelFactory<IOrganizationService>(customBinding, remoteAddress);
ClientCredentials loginCredentials = factory.Endpoint.Behaviors.Find<ClientCredentials>();
factory.Endpoint.Behaviors.Remove(loginCredentials);
// step two - instantiate your credentials
loginCredentials = new ClientCredentials();
loginCredentials.Windows.ClientCredential = new System.Net.NetworkCredential(UserName, Password, Domain);
factory.Endpoint.Behaviors.Add(loginCredentials);
IEnumerable<OperationDescription> operations = factory.Endpoint.Contract.Operations;
foreach (OperationDescription operation in operations)
{
DataContractSerializerOperationBehavior dcsob = operation.Behaviors.Find<DataContractSerializerOperationBehavior>();
if (dcsob == null)
{
dcsob = new DataContractSerializerOperationBehavior(operation);
}
operation.Behaviors.Remove(dcsob);
dcsob.MaxItemsInObjectGraph = 1012 * 1024 * 1024;
operation.Behaviors.Add(dcsob);
}
_orgProxy = factory.CreateChannel();
Теперь, когда мы пытаемся подключиться к CRM с этим кодом, что возвращается следующее сообщение об ошибке: </StackTrace><ExceptionString>System.ServiceModel.Security.MessageSecurityException: Security processor was unable to find a security header in the message. This might be because the message is an unsecured fault or because there is a binding mismatch between the communicating parties. This can occur if the service is configured for security and the client is not using security.</ExceptionString></Exception></TraceRecord>
Мой вопрос является то, что заголовки дополнительной безопасности мне нужно, и как я могу изменить привязки к включить их?
Если вы хотите увидеть, как Microsoft смотрит на эту статью http://blogs.msdn.com/b/crm/archive/2012/11/02/building-clients-for-windows-phone-and- windows-8-rt.aspx и загрузите источник http://download.microsoft.com/download/1/A/A/1AA59217-D571-4E65-B037-FE59DD945A13/CRMSLSample.zip. Он был опубликован для людей, которые будут использовать при создании Windows 8 Phone и RT Apps (которые не поддерживают .NET 4 и WIF), но могут также использоваться для проекта .NET 3.5 (который не может использовать .NET 4 DLL) – Nicknow