Changes to make this work with ADFS / IFD

May 25, 2012 at 11:24 AM

I got this to work with our non-Microsoft cloud CRM service - they use ADFS for authentication.

I had to make the following changes...

Connection.cs

Line 25
public bool ADFSMode {get; set;}

Line 65
XElement adfsElement = new XElement("ADFSMode");
adfsElement.SetValue(ADFSMode);
c.Add(adfsElement);
 
Line 92
var adfs = c.Element("ADFSMode");
if(adfs.Value.ToString() == "ADFS") {
  ADFSMode = true;
}
 
Line 196
if(this.ADFSMode) {
  ClientCredentials credentials = new ClientCredentials();
  credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
  credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
  credentials.UserName.UserName = this.Login;
  credentials.UserName.Password = this.Password;
  service = new OrganizationServiceProxy(serviceUrl, null, credentials, null);
} else {
  // This is an existing line...
  service = new OrganizationServiceProxy(serviceUrl, null, creds, null);
}

ConnectionDialog.xaml

Line 7
DesignHeight="280"

Line 48
<CheckBox Grid.Row="5" Grid.Column="2" Name="ADFSMode" Margin="4" Content="ADFS / IFD Mode" />


ConnectionDialog.xaml.cs

Line 71
c.ADFSMode = (bool)this.ADFSMode.IsChecked;

 

RibbonButton.xaml.cs

Line 160
if(Connection.CurrentConnection.ADFSMode) {
  string actualURL = Connection.CurrentConnection.ServerUrl;
  if(actualURL.EndsWith("/")) { actualURL = actualURL.Substring(0, actualURL.Length - 1); }
  actualURL += relativeUrl;
  return actualURL;
}

 

It works and publishes changes perfectly for me (although only done a couple so far).

Hope this helps someone out. If someone wants to include this in the main project, that would be cool.

Aug 18, 2012 at 6:08 PM

I have done the above changes and am able to connect to IFD CRM. But I am getting the below error when it is trying to load the ribbon for an entity. Please help.

Exception: FaultException`1

Message: Attempting to  select a readonly publisher for solution.

StackTrace: Server stack trace:    at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)   at Microsoft.Xrm.Sdk.IOrganizationService.Create(Entity entity)   at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.CreateCore(Entity entity)   at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.Create(Entity entity)   at VisualRibbonEditor.ServiceWrapper.CreateAsync(Entity entity, Action`1 callback) in D:\Documents and Settings\Office\My Documents\Downloads\crmvisualribbonedit-10810\VisualRibbonEditor\ServiceWrapper.cs:line 30   at VisualRibbonEditor.Solution.CreateSolutionThenAddEntityAndExport(Entity publisher) in D:\Documents and Settings\Office\My Documents\Downloads\crmvisualribbonedit-10810\VisualRibbonEditor\Solution.cs:line 386   at VisualRibbonEditor.Helpers.<>c__DisplayClass1.<GetRecordWithCondition>b__0(EntityCollection ec) in D:\Documents and Settings\Office\My Documents\Downloads\crmvisualribbonedit-10810\VisualRibbonEditor\Helpers.cs:line 39   at VisualRibbonEditor.ServiceWrapper.RetrieveMultipleAsync(QueryBase query, Action`1 callback) in D:\Documents and Settings\Office\My Documents\Downloads\crmvisualribbonedit-10810\VisualRibbonEditor\ServiceWrapper.cs:line 43   at VisualRibbonEditor.Helpers.GetRecordsWithCondition(String entityName, String attributeName, ConditionOperator op, Object attributeValue, Action`1 callback, String[] cols) in D:\Documents and Settings\Office\My Documents\Downloads\crmvisualribbonedit-10810\VisualRibbonEditor\Helpers.cs:line 71   at VisualRibbonEditor.Helpers.GetRecordWithCondition(String entityName, String attributeName, ConditionOperator op, Object attributeValue, Action`1 callback, String[] cols) in D:\Documents and Settings\Office\My Documents\Downloads\crmvisualribbonedit-10810\VisualRibbonEditor\Helpers.cs:line 47   at VisualRibbonEditor.Solution.SetupSolution_SolutionRetrieved(Entity solution) in D:\Documents and Settings\Office\My Documents\Downloads\crmvisualribbonedit-10810\VisualRibbonEditor\Solution.cs:line 357   at VisualRibbonEditor.Helpers.<>c__DisplayClass1.<GetRecordWithCondition>b__0(EntityCollection ec) in D:\Documents and Settings\Office\My Documents\Downloads\crmvisualribbonedit-10810\VisualRibbonEditor\Helpers.cs:line 43   at VisualRibbonEditor.ServiceWrapper.RetrieveMultipleAsync(QueryBase query, Action`1 callback) in D:\Documents and Settings\Office\My Documents\Downloads\crmvisualribbonedit-10810\VisualRibbonEditor\ServiceWrapper.cs:line 43   at VisualRibbonEditor.Helpers.GetRecordsWithCondition(String entityName, String attributeName, ConditionOperator op, Object attributeValue, Action`1 callback, String[] cols) in D:\Documents and Settings\Office\My Documents\Downloads\crmvisualribbonedit-10810\VisualRibbonEditor\Helpers.cs:line 71   at VisualRibbonEditor.Helpers.GetRecordWithCondition(String entityName, String attributeName, ConditionOperator op, Object attributeValue, Action`1 callback, String[] cols) in D:\Documents and Settings\Office\My Documents\Downloads\crmvisualribbonedit-10810\VisualRibbonEditor\Helpers.cs:line 47   at VisualRibbonEditor.Helpers.GetRecordByName(String entityName, String attributeName, Object attributeValue, Action`1 callback, String[] cols) in D:\Documents and Settings\Office\My Documents\Downloads\crmvisualribbonedit-10810\VisualRibbonEditor\Helpers.cs:line 30   at VisualRibbonEditor.Solution.<GetAppRibbon>b__13(EntityCollection ec) in D:\Documents and Settings\Office\My Documents\Downloads\crmvisualribbonedit-10810\VisualRibbonEditor\Solution.cs:line 337   at VisualRibbonEditor.ServiceWrapper.RetrieveMultipleAsync(QueryBase query, Action`1 callback) in D:\Documents and Settings\Office\My Documents\Downloads\crmvisualribbonedit-10810\VisualRibbonEditor\ServiceWrapper.cs:line 43   at VisualRibbonEditor.Solution.GetAppRibbon() in D:\Documents and Settings\Office\My Documents\Downloads\crmvisualribbonedit-10810\VisualRibbonEditor\Solution.cs:line 331   at VisualRibbonEditor.Solution.SetupSolution() in D:\Documents and Settings\Office\My Documents\Downloads\crmvisualribbonedit-10810\VisualRibbonEditor\Solution.cs:line 314   at VisualRibbonEditor.Solution.<Load>b__0(Object sender, DoWorkEventArgs e) in D:\Documents and Settings\Office\My Documents\Downloads\crmvisualribbonedit-10810\VisualRibbonEditor\Solution.cs:line 45


Developer
Sep 28, 2012 at 7:57 PM

Hi, PeteCrm.

I have included the changes you provided to the latest release.
Thanks alot for sharing it with everyone!

Regards