SharePoint List Adapter and HTTPS

  • Hi

    I was wondering whether anyone had managed to get the codeplex SSIS SharePoint List Adapter components working with an HTTPS sharepoint site?

    I can get them to work with HTTP but i get the following error with HTTPS and I have full control of the sharepoint site i'm trying to connect to.

    The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from server was 'Negotiate, NTLM', ---> System.Net.Exception: The remote server returned an error: (401) Unauthorized.

    Cheers

  • In the earlier version of the SharePoint List adapters you had to modify the SharePointUtility code which is a VB project to be able to support HTTPS. Basically it uses the SharePoint list webservice and the WCF client configuration is performed in SharePointUtility code which needs to be modified to support HTTPS.

    Here is some of the code that you can modify and try

    Public Function RemoteCertificateValidationCallback(ByVal sender As Object, ByVal certificate As System.Security.Cryptography.X509Certificates.X509Certificate, ByVal chain As System.Security.Cryptography.X509Certificates.X509Chain, ByVal sslPolicyErrors As System.Net.Security.SslPolicyErrors) As Boolean

    Return True

    End Function

    ''' <summary>

    ''' Resets the conneciton for the current client which is used for the lists service

    ''' </summary>

    ''' <remarks></remarks>

    Private Sub ResetConnection()

    System.Net.ServicePointManager.ServerCertificateValidationCallback = New System.Net.Security.RemoteCertificateValidationCallback(AddressOf RemoteCertificateValidationCallback)

    ' Setup the binding with some enlarged buffers for SharePoint

    Dim binding = New BasicHttpBinding()

    ' Change the security mode if we're using http vs https

    If (_sharepointUri.Scheme.ToLower() = "http") Then

    binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly

    ElseIf (_sharepointUri.Scheme.ToLower() = "https") Then

    binding.Security.Mode = BasicHttpSecurityMode.Transport

    Else

    Throw New ArgumentException("SharePoint URL Scheme is not recognized: " + _sharepointUri.Scheme)

    End If

    '@@ binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows

    '@@ binding.Security.Transport.ProxyCredentialType = HttpClientCredentialType.Windows

    'binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm

    ' Send credentials and adjust the buffer sizes (SharePoint can send big packets of data)

    If (_sharepointUri.Scheme.ToLower() = "http") Then

    binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm

    ElseIf (_sharepointUri.Scheme.ToLower() = "https") Then

    binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows

    binding.Security.Transport.ProxyCredentialType = HttpClientCredentialType.Windows

    End If

    binding.MaxReceivedMessageSize = Int32.MaxValue

    binding.ReaderQuotas.MaxBytesPerRead = Int32.MaxValue

    binding.ReaderQuotas.MaxArrayLength = Int32.MaxValue

    binding.ReaderQuotas.MaxDepth = Int32.MaxValue

    binding.ReaderQuotas.MaxNameTableCharCount = Int32.MaxValue

    binding.ReaderQuotas.MaxStringContentLength = Int32.MaxValue

    binding.ReceiveTimeout = New TimeSpan(24, 0, 0)

    ' Create the client with the given settings

    Dim ep = New EndpointAddress(_sharepointUri)

    ' Create the client object

    If (Not _sharepointClient Is Nothing) Then

    Dim dispose As IDisposable = _sharepointClient

    dispose.Dispose()

    _sharepointClient = Nothing

    End If

    _sharepointClient = New ListsSoapClient(binding, ep)

    ' Only need to add this once, the endpoint will be shared for future instances

    Dim clientCredentials As Description.ClientCredentials = _

    (From e In _sharepointClient.Endpoint.Behaviors _

    Where TypeOf (e) Is Description.ClientCredentials).Single()

    clientCredentials.Windows.AllowedImpersonationLevel = _

    TokenImpersonationLevel.Impersonation

    clientCredentials.Windows.ClientCredential = _credential

    End Sub


    Naveen Abraham

  • Do you have any code on Claims Based authentication? I'm receiving

    Error System.ServiceModel.Security.MessageSecurityException: The HTTP request was forbidden with client authentication scheme 'Negotiate'. ---> System.Net.WebException: The remote server returned an error: (403) Forbidden. at System.Net.HttpWebRequest.GetResponse() at....

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply