You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by Xi Wang <wa...@gmail.com> on 2017/03/17 08:55:02 UTC

Authentication error connect to CMIS Web Services endpoint with using DotCMIS v0.7

Hi all,

I tried to use the CMIS Web Service endpoint demo released in
*https://chemistry.apache.org/dotnet/getting-started-with-dotcmis.html
<https://chemistry.apache.org/dotnet/getting-started-with-dotcmis.html>*
to access to my database, but I got the authentication error as below:
The HTTP request is unauthorized with client authentication scheme
'Anonymous'. The authentication header received from the server was 'Basic
realm="Authentication required"'.

I'm sure I have specified the username&pwd correctly to my C# application,
please see the code below:

using DotCMIS;
using DotCMIS.Client;
using DotCMIS.Client.Impl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

/*
*/

namespace testDotCmis
{
    class Program
    {
        static void Main(string[] args)
        {
            var parameters = new Dictionary<string, string>();

            parameters[SessionParameter.BindingType] =
BindingType.WebServices;
            parameters[SessionParameter.WebServicesRepositoryService] =
"https://[host address]/repositoryservice?wsdl";
            parameters[SessionParameter.WebServicesAclService] = "https://[host
address]/aclservice?wsdl";
            parameters[SessionParameter.WebServicesDiscoveryService] =
"https://[host address]/discoveryservice?wsdl";
            parameters[SessionParameter.WebServicesMultifilingService] =
"https://[host address]/multifilingservice?wsdl";
            parameters[SessionParameter.WebServicesNavigationService] =
"https://[host address]/navigationservice?wsdl";
            parameters[SessionParameter.WebServicesObjectService] =
"https://[host address]/objectservice?wsdl";
            parameters[SessionParameter.WebServicesPolicyService] =
"https://[host address]/policyservice?wsdl";
            parameters[SessionParameter.WebServicesRelationshipService] =
"https://[host address]/relationshipservice?wsdl";
            parameters[SessionParameter.WebServicesVersioningService] =
"https://[host address]/versioningservice?wsdl";
            parameters[SessionParameter.User] = "[username]";
            parameters[SessionParameter.Password] = "[pwd]";


            SessionFactory factory = SessionFactory.NewInstance();

            var repoInfoList = factory.GetRepositories(parameters);
            Console.WriteLine("Test");
            Console.ReadKey();
        }
    }
}

I also tested with Atompub&browser, they worked perfectly.

            var parameters = new Dictionary<string, string>();
            parameters[SessionParameter.BindingType] = BindingType.Browser;
            parameters[SessionParameter.BrowserUrl] = "https://[host
address]/browser";
            parameters[SessionParameter.User] = "[username]";
            parameters[SessionParameter.Password] = "[pwd]";
            SessionFactory factory = SessionFactory.NewInstance();

            var repoInfoList = factory.GetRepositories(parameters);

Could you help with this, please?

-- 
Best Regards.

Xi
-----------------------------------------------------------------
Polytech Nice-Sophia Antipolis
Western University
41 RUE DIDOT
75014 Paris, France

Linkin: Xi WANG <https://www.linkedin.com/in/xi-wang-a8577683>
Tel: *(+33)6 66 47 84 59 <%28%2B33%296%2066%2047%2084%2059>*
Mail: *wang.xi.polytech@gmail.com <wa...@gmail.com>*

Re: Authentication error connect to CMIS Web Services endpoint with using DotCMIS v0.7

Posted by Florian Müller <fm...@apache.org>.
Hi Xi,

The Web Services binding uses UsernameToken by default for the 
authentication (as defined by the CMIS specification). Your server 
doesn't seem to support that.

To turn on HTTP authentication add this line:

parameters[SessionParameter.AuthenticationProviderClass] = 
"DotCMIS.Binding.NtlmAuthenticationProvider";

(Don't be confused by "NTLM". The authentication provider handles both, 
basic auth and NTLM.)


And a final note: Do not use the Web Services binding if you don't have 
to! It's slow and cumbersome.


- Florian



> Hi all,
> 
> I tried to use the CMIS Web Service endpoint demo released in
> *https://chemistry.apache.org/dotnet/getting-started-with-dotcmis.html
> <https://chemistry.apache.org/dotnet/getting-started-with-dotcmis.html>*
> to access to my database, but I got the authentication error as below:
> The HTTP request is unauthorized with client authentication scheme
> 'Anonymous'. The authentication header received from the server was 
> 'Basic
> realm="Authentication required"'.
> 
> I'm sure I have specified the username&pwd correctly to my C# 
> application,
> please see the code below:
> 
> using DotCMIS;
> using DotCMIS.Client;
> using DotCMIS.Client.Impl;
> using System;
> using System.Collections.Generic;
> using System.Linq;
> using System.Text;
> using System.Threading.Tasks;
> 
> /*
> */
> 
> namespace testDotCmis
> {
>     class Program
>     {
>         static void Main(string[] args)
>         {
>             var parameters = new Dictionary<string, string>();
> 
>             parameters[SessionParameter.BindingType] =
> BindingType.WebServices;
>             parameters[SessionParameter.WebServicesRepositoryService] =
> "https://[host address]/repositoryservice?wsdl";
>             parameters[SessionParameter.WebServicesAclService] = 
> "https://[host
> address]/aclservice?wsdl";
>             parameters[SessionParameter.WebServicesDiscoveryService] =
> "https://[host address]/discoveryservice?wsdl";
>             parameters[SessionParameter.WebServicesMultifilingService] 
> =
> "https://[host address]/multifilingservice?wsdl";
>             parameters[SessionParameter.WebServicesNavigationService] =
> "https://[host address]/navigationservice?wsdl";
>             parameters[SessionParameter.WebServicesObjectService] =
> "https://[host address]/objectservice?wsdl";
>             parameters[SessionParameter.WebServicesPolicyService] =
> "https://[host address]/policyservice?wsdl";
>             parameters[SessionParameter.WebServicesRelationshipService] 
> =
> "https://[host address]/relationshipservice?wsdl";
>             parameters[SessionParameter.WebServicesVersioningService] =
> "https://[host address]/versioningservice?wsdl";
>             parameters[SessionParameter.User] = "[username]";
>             parameters[SessionParameter.Password] = "[pwd]";
> 
> 
>             SessionFactory factory = SessionFactory.NewInstance();
> 
>             var repoInfoList = factory.GetRepositories(parameters);
>             Console.WriteLine("Test");
>             Console.ReadKey();
>         }
>     }
> }
> 
> I also tested with Atompub&browser, they worked perfectly.
> 
>             var parameters = new Dictionary<string, string>();
>             parameters[SessionParameter.BindingType] = 
> BindingType.Browser;
>             parameters[SessionParameter.BrowserUrl] = "https://[host
> address]/browser";
>             parameters[SessionParameter.User] = "[username]";
>             parameters[SessionParameter.Password] = "[pwd]";
>             SessionFactory factory = SessionFactory.NewInstance();
> 
>             var repoInfoList = factory.GetRepositories(parameters);
> 
> Could you help with this, please?