首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Vbscript webdav文件夹创建

Vbscript webdav文件夹创建
EN

Stack Overflow用户
提问于 2013-07-03 22:43:29
回答 3查看 752关注 0票数 0

我正在尝试用Vbscript创建文件夹。

我是Vbscript的新手。

无法理解此代码返回的原因:文件夹尚未创建。状态为不支持的媒体类型。

我在这里拍的,http://blogs.msdn.com/b/webdav_101/archive/2008/03/12/howto-vb-an-example-to-create-a-public-folder-with-storage-limit-settings.aspx

代码Vbscript

代码语言:javascript
复制
cmdMakeFolder_Click

Private Sub cmdMakeFolder_Click()
    Dim XMLreq
    Set XMLreq = createobject("MSXML2.XMLHTTP.3.0")
    Dim sReq
    Dim parsePhone
    Dim sSourceURL

    sSourceURL = "https://shkur.webdav.hidrive.strato.com/users/shkur/"
    ' Note: This URL is broken down as:
    '     myexserver is the Exchange box name
    '     MYDOM.EXTEST.MYCOMP.COM  is the full domain name the Exchange box is in.
    '     Exadmin/admin is a special designation giving the login user higher level privs.
    ' Exchange explorer may/may not need the %20 in PUBLIC%20FOLDERS
    ' The account you use to log in with Must have full blown Exchange admin privs and be 
    ' a domain acct.

    'XMLreq.open "MKCOL", sSourceURL, False, "Administrator", "Pxxxx" 
          ' If the Exchange is the DC, you probably dont have to specify the DC to login
    XMLreq.open "MKCOL", sSourceURL, False, "login", "password" 
          ' Here Exchange box is not the DC

    XMLreq.setRequestHeader "Content-Type", "text/xml"

    sReq = "<?xml version='1.0'?>"
    sReq = sReq & "<a:propertyupdate xmlns:a='DAV:' xmlns:e='http://schemas.microsoft.com/exchange/' " & _
                    "xmlns:p='http://schemas.microsoft.com/mapi/proptag/'>"
    sReq = sReq & "<a:set><a:prop>" & vbCrLf
    sReq = sReq & "<e:outlookfolderclass>IPF.Folder</e:outlookfolderclass>" & vbCrLf    
          ' Folder class for outlook
    sReq = sReq & "<a:contentclass>urn:content-classes:folder</a:contentclass>" & vbCrLf  
          ' Folder content class
    sReq = sReq & "<a:isreadonly>1</a:isreadonly>" & vbCrLf  ' Read only
    sReq = sReq & "<a:ishidden>1</a:ishidden>" & vbCrLf       ' Hidden

     sReq = sReq & "<p:x67790003>1</p:x67790003>" & vbCrLf 
          'Use the quotas specified by other properties.
     sReq = sReq & "<e:storagequotaissuewarninglimit>200</e:storagequotaissuewarninglimit>" & vbCrLf 
          'Issue warning at (Kb).
     sReq = sReq & "<p:x67210003>1</p:x67210003>" & vbCrLf  'Prohibit post at (Kb).
     sReq = sReq & "<p:x67220003>1</p:x67220003>" & vbCrLf  'Maximum item size (Kb).

    sReq = sReq & "<e:addressbookdisplayname>qwe</e:addressbookdisplayname>" & vbCrLf

    sReq = sReq & "</a:prop></a:set></a:propertyupdate>"

    XMLreq.send sReq
    'Debug.Print "xmlReq.Status = " & XMLreq.Status
    If XMLreq.Status = "201" Or XMLreq.Status = "207" Then
        MsgBox "The folder has been created.  Status is " & XMLreq.statusText, vbCritical, "Folder Created!!"
    Else
        ' Note: Error 405 can mean permissions problem on item already exists.
        MsgBox "The folder has not been created.  Status is " & XMLreq.statusText, vbCritical, " Folder not Created!!"
    End If
End Sub
EN

回答 3

Stack Overflow用户

发布于 2013-07-04 05:17:23

该响应状态(415 -不支持的媒体类型)表示服务器已经拒绝了请求实体。在您的请求中,请求实体是XML。请注意,“普通的”MKCOL请求在主体中不使用XML,只有扩展的MKCOL使用,这并不是在所有服务器上实现的。

所以最有可能的原因是您使用的webdav服务器不支持扩展的MKCOL

https://datatracker.ietf.org/doc/html/draft-ietf-vcarddav-webdav-mkcol-06

票数 2
EN

Stack Overflow用户

发布于 2013-07-04 07:29:19

отвечаюсамсебевоттакработает!

代码语言:javascript
复制
    cmdMakeFolder_Click

Private Sub cmdMakeFolder_Click()
    Dim XMLreq
    Set XMLreq = createobject("MSXML2.XMLHTTP.3.0")
    'Set XMLreq = createobject("MSXML2.XMLHTTP.4.0")
    Dim sReq
    Dim parsePhone
    Dim sSourceURL

    sSourceURL = "https://shkur.webdav.hidrive.strato.com/users/shkur/qweer/"
    ' Note: This URL is broken down as:
    '     myexserver is the Exchange box name
    '     MYDOM.EXTEST.MYCOMP.COM  is the full domain name the Exchange box is in.
    '     Exadmin/admin is a special designation giving the login user higher level privs.
    ' Exchange explorer may/may not need the %20 in PUBLIC%20FOLDERS
    ' The account you use to log in with Must have full blown Exchange admin privs and be 
    ' a domain acct.

    'XMLreq.open "MKCOL", sSourceURL, False, "Administrator", "Pxxxx" 
          ' If the Exchange is the DC, you probably dont have to specify the DC to login
    XMLreq.open "MKCOL", sSourceURL, False, "login", "password" 
          ' Here Exchange box is not the DC

    XMLreq.setRequestHeader "Content-Type", "text/xml"

    'sReq = "<?xml version='1.0'?><a:propertyupdate xmlns:a='DAV:' xmlns:e='http://schemas.microsoft.com/exchange/' xmlns:p='http://schemas.microsoft.com/mapi/proptag/'><a:set><a:prop><e:outlookfolderclass>IPF.Folder</e:outlookfolderclass><a:contentclass>urn:content-classes:folder</a:contentclass><a:isreadonly>1</a:isreadonly><a:ishidden>1</a:ishidden><p:x67790003>1</p:x67790003><e:storagequotaissuewarninglimit>200</e:storagequotaissuewarninglimit><p:x67210003>1</p:x67210003><p:x67220003>1</p:x67220003><e:addressbookdisplayname>qwe</e:addressbookdisplayname></a:prop></a:set></a:propertyupdate>"

    XMLreq.send sReq
    'Debug.Print "xmlReq.Status = " & XMLreq.Status
    If XMLreq.Status = "201" Or XMLreq.Status = "207" Then
        MsgBox "The folder has been created.  Status is " & XMLreq.statusText, vbCritical, "Folder Created!!"
    Else
        ' Note: Error 405 can mean permissions problem on item already exists.
        MsgBox "The folder has not been created.  Status is " & XMLreq.statusText, vbCritical, " Folder not Created!!"
    End If
End Sub
票数 0
EN

Stack Overflow用户

发布于 2013-07-04 15:00:33

似乎您正试图在不理解MKCOL的服务器上使用MKCOL(特定于Microsoft)的非标准扩展。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17451090

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档