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();
}
}