WebDAV返回401-如何进行身份验证? [英] WebDAV return 401 - How to authenticate?

查看:1689
本文介绍了WebDAV返回401-如何进行身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对WebDAV有问题.我必须获取文件列表.我有这个要求:

I have a problem with WebDAV. I have to get a list of files. I have this request:

<?xml version="1.0"?>
<D:searchrequest xmlns:D = "DAV:">
<D:sql>
    SELECT "DAV:displayname" FROM "address" WHERE "DAV:ishidden" = false AND "DAV:isfolder" = false 
</D:sql>
</D:searchrequest>

响应:

401-未经授权:由于凭据无效,访问被拒绝.

401 - Unauthorized: Access is denied due to invalid credentials.

我有用户名和密码(可以访问),但是我不知道如何将这些数据发送到XML请求中.

I have user and password (who has access), but I don't know, how I can put this data to XML request.

推荐答案

WebDAV使用HTTP身份验证.

WebDAV uses an HTTP authentication.

因此,您将凭据放入HTTP标头,而不是HTTP正文中的WebDAV XML.

So you put your credentials to an HTTP header, not to the WebDAV XML in the HTTP body.

基本的HTTP身份验证的工作方式如下:

The basic HTTP authentication works like:

  • 您从服务器获取WWW-Authenticate标头

WWW-Authenticate: Basic realm="server"

  • 您将Authorization标头包含在下一个请求中.标头的值为:

  • You include the Authorization header to the next request. The value of the header is:

    Authorization: Basic username:password
    

    其中username:password采用Base-64编码.

    where the username:password is in Base-64 encoding.

    Authorization: Basic dXNlcjpwYXNzd29yZA==
    

  • 有关详细信息,请参见

    • Basic access authentication on Wikipedia
    • RFC 7235: Hypertext Transfer Protocol (HTTP/1.1): Authentication

    这篇关于WebDAV返回401-如何进行身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆