WebDAV返回401

编程入门 行业动态 更新时间:2024-10-26 03:29:12
本文介绍了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==

  • 有关详细信息,请参见

    • 维基百科上的基本访问身份验证
    • RFC 7235 :超文本传输​​协议(HTTP/1.1):身份验证
    • Basic access authentication on Wikipedia
    • RFC 7235: Hypertext Transfer Protocol (HTTP/1.1): Authentication

    更多推荐

    WebDAV返回401

    本文发布于:2023-11-26 16:45:26,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1634419.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:WebDAV

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!