Skip to main content
Notice removed Draw attention by CommunityBot
Bounty Ended with Falak Mahmood's answer chosen by CommunityBot
mistake corrected
Source Link
Sergei Sergeev
  • 11.6k
  • 5
  • 32
  • 49

I am struggling with calling search.asmx service from asp.net page. I've created proxy class using svcutil.exe and run request using following code:

var binding = new BasicHttpBinding();
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
binding.Security.Transport.Realm = string.Empty;
binding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;
var service = new QueryServiceSoapClient(binding, new EndpointAddress("http://mysite/_vti_bin/search.asmx"));
service.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
var res = service.QueryEx(qXMLString);

Web application is set up using Kerberos authentication, I got exception

The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'

in method System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication
I've tried set up service.ClientCredentials.Windows.AllowNtlm = true; but error is the same.

What can be the cause of this problem?

Thanks in advance.

UPD:

I've tried above code to run in a console app, and all working fine, exception is thrown form asp.net codebehind only.

UPD2:

User which run this code has appropriate permissions in SharePoint (actually console app runs under the same user as codebehind).

I am struggling with calling search.asmx service from asp.net page. I've created proxy class using svcutil.exe and run request using following code:

var binding = new BasicHttpBinding();
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
binding.Security.Transport.Realm = string.Empty;
binding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;
var service = new QueryServiceSoapClient(binding, new EndpointAddress("http://mysite/_vti_bin/search.asmx"));
service.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
var res = service.QueryEx(qXMLString);

Web application is set up using Kerberos authentication, I got exception

The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'

in method System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication
I've tried set up service.ClientCredentials.Windows.AllowNtlm = true; but error is the same.

What can be the cause of this problem?

Thanks in advance.

UPD:

I've tried above code to run in a console app, and all working fine, exception is thrown form asp.net codebehind only.

I am struggling with calling search.asmx service from asp.net page. I've created proxy class using svcutil.exe and run request using following code:

var binding = new BasicHttpBinding();
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
binding.Security.Transport.Realm = string.Empty;
binding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;
var service = new QueryServiceSoapClient(binding, new EndpointAddress("http://mysite/_vti_bin/search.asmx"));
service.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
var res = service.QueryEx(qXMLString);

Web application is set up using Kerberos authentication, I got exception

The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'

in method System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication
I've tried set up service.ClientCredentials.Windows.AllowNtlm = true; but error is the same.

What can be the cause of this problem?

Thanks in advance.

UPD:

I've tried above code to run in a console app, and all working fine, exception is thrown form asp.net codebehind only.

UPD2:

User which run this code has appropriate permissions in SharePoint (actually console app runs under the same user as codebehind).

Tweeted twitter.com/#!/StackSharePoint/status/293297820738396161
some more info added
Source Link
Sergei Sergeev
  • 11.6k
  • 5
  • 32
  • 49

I am struggling with calling search.asmx service from asp.net page. I've created proxy class using svcutil.exe and run request using following code:

var binding = new BasicHttpBinding();
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
binding.Security.Transport.Realm = string.Empty;
binding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;
var service = new QueryServiceSoapClient(binding, new EndpointAddress("http://mysite/_vti_bin/search.asmx"));
service.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
var res = service.QueryEx(qXMLString);

Web application is set up using Kerberos authentication, I got exception

The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'

in method System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication
I've tried set up service.ClientCredentials.Windows.AllowNtlm = true; but error is the same.

What can be the cause of this problem?

Thanks in advance.

UPD:

I've tried above code to run in a console app, and all working fine, exception is thrown form asp.net codebehind only.

I am struggling with calling search.asmx service from asp.net page. I've created proxy class using svcutil.exe and run request using following code:

var binding = new BasicHttpBinding();
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
binding.Security.Transport.Realm = string.Empty;
binding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;
var service = new QueryServiceSoapClient(binding, new EndpointAddress("http://mysite/_vti_bin/search.asmx"));
service.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
var res = service.QueryEx(qXMLString);

Web application is set up using Kerberos authentication, I got exception

The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'

in method System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication
I've tried set up service.ClientCredentials.Windows.AllowNtlm = true; but error is the same.

What can be the cause of this problem?

Thanks in advance.

I am struggling with calling search.asmx service from asp.net page. I've created proxy class using svcutil.exe and run request using following code:

var binding = new BasicHttpBinding();
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
binding.Security.Transport.Realm = string.Empty;
binding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;
var service = new QueryServiceSoapClient(binding, new EndpointAddress("http://mysite/_vti_bin/search.asmx"));
service.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
var res = service.QueryEx(qXMLString);

Web application is set up using Kerberos authentication, I got exception

The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'

in method System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication
I've tried set up service.ClientCredentials.Windows.AllowNtlm = true; but error is the same.

What can be the cause of this problem?

Thanks in advance.

UPD:

I've tried above code to run in a console app, and all working fine, exception is thrown form asp.net codebehind only.

Notice added Draw attention by Sergei Sergeev
Bounty Started worth 200 reputation by Sergei Sergeev
Source Link
Sergei Sergeev
  • 11.6k
  • 5
  • 32
  • 49

SharePoint 2010 Query service authentication problem

I am struggling with calling search.asmx service from asp.net page. I've created proxy class using svcutil.exe and run request using following code:

var binding = new BasicHttpBinding();
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
binding.Security.Transport.Realm = string.Empty;
binding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;
var service = new QueryServiceSoapClient(binding, new EndpointAddress("http://mysite/_vti_bin/search.asmx"));
service.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
var res = service.QueryEx(qXMLString);

Web application is set up using Kerberos authentication, I got exception

The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'

in method System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication
I've tried set up service.ClientCredentials.Windows.AllowNtlm = true; but error is the same.

What can be the cause of this problem?

Thanks in advance.