2

I am using SDL Tridion 9.6 trying to create a custom application. While trying to connect to wcf core service, I am getting the following

Error:

The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Basic realm="domain"'.

Any help is appreciated.

class Program
    {
        static ICoreService GetNewClient(string username, string password)
        {
            var binding = new BasicHttpsBinding()
            {
                MaxBufferSize = 4194304, // 4MB
                MaxBufferPoolSize = 4194304,
                MaxReceivedMessageSize = 4194304,
                ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas()
                {
                    MaxStringContentLength = 4194304, // 4MB
                    MaxArrayLength = 4194304,
                },
                Security = new BasicHttpsSecurity()
                {
                    Mode = BasicHttpsSecurityMode.Transport,
                    Transport = new HttpTransportSecurity()
                    {
                        ClientCredentialType = HttpClientCredentialType.Windows,                        

                    },
                    
                    
                }
                
      
            };
            //hostname = string.Format("{0}{1}{2}", hostname.StartsWith("http") ? "" : "http://", hostname, hostname.EndsWith("/") ? "" : "/");
            var endpoint = new EndpointAddress("https://xxx.xxx.xxx.xxx/webservices/CoreService201701.svc/basicHttp");
            ChannelFactory<ICoreService> factory = new ChannelFactory<ICoreService>(binding, endpoint);
            factory.Credentials.Windows.ClientCredential = new System.Net.NetworkCredential(username, password);
            return factory.CreateChannel();
        }
        static async Task Main(string[] args)
        {
            var client = GetNewClient(@"domain\userid", "password");
            var user = await client.GetCurrentUserAsync();
        }
    }
2
  • Welcome to Tridion StackExchange, could you please elaborate a bit more detail on how is your CME authentication set up, Are you using access management for the CME authentication?
    – Velmurugan
    May 9, 2023 at 6:44
  • Hi @Velmurugan, thanks for replying to the question. I am not connecting through the Access Management but as a window user. I was given user name and password in the form username: domain\userid
    – arjun
    May 9, 2023 at 14:34

1 Answer 1

1

In your client code, you're configuring Windows Authentication ( ClientCredentialType = HttpClientCredentialType.Windows), but the error returned by the CM server says that it expects HTTP Basic Authentication.

Most likely, your CM server is configured for LDAP Authentication (which uses HTTP Basic Authentication between client and server). You can verify this by checking if the LdapAuthenticationHttpModule is enabled in the Webservices web app.

2
  • 1
    Updated the security binding as follows and it worked: binding.Security.Mode = BasicHttpsSecurityMode.Transport; binding.Security.Transport = new HttpTransportSecurity() { ClientCredentialType = HttpClientCredentialType.Basic };
    – arjun
    May 14, 2023 at 23:15
  • If this answer helped you, please mark it as an answer - this will help other users with the same question.
    – Nuno Linhares
    Oct 12, 2023 at 5:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.