Skip to content

Instantly share code, notes, and snippets.

@mbratukha
Forked from Krizzzn/app.config
Last active February 12, 2016 16:41
Show Gist options
  • Select an option

  • Save mbratukha/24276aa9994802cc445e to your computer and use it in GitHub Desktop.

Select an option

Save mbratukha/24276aa9994802cc445e to your computer and use it in GitHub Desktop.
C# - accessing service reference with the headers Negotiate, Ntlm
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="NintexWorkflowWSSoap">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://intranet.aDomain.net/_vti_bin/nintexworkflow/workflow.asmx"
binding="basicHttpBinding" bindingConfiguration="NintexWorkflowWSSoap"
contract="Nintex.Service.NintexWorkflowWSSoap" name="NintexWorkflowWSSoap" />
</client>
</system.serviceModel>
</configuration>

this gist solves the MessageSecurityException "The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'Negotiate,NTLM'.".

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Principal;
using System.ServiceModel;
namespace TheTestConsole
{
class Program
{
static void Main(string[] args)
{
var client = new Nintex.Service.NintexWorkflowWSSoapClient("NintexWorkflowWSSoap");
client.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
client.ClientCredentials.Windows.ClientCredential.Domain = "aDomain";
client.ClientCredentials.Windows.ClientCredential.UserName = "aName";
client.ClientCredentials.Windows.ClientCredential.Password = "*********";
var result = client.PublishFromNWFXml(m, "Request List", "Approval", false);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment