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'.".
-
-
Save mbratukha/24276aa9994802cc445e to your computer and use it in GitHub Desktop.
C# - accessing service reference with the headers Negotiate, Ntlm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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