【问题标题】:VBA Kerberos AuthenticationVBA Kerberos 身份验证
【发布时间】:2014-06-16 20:37:51
【问题描述】:

我想使用 Windows 登录中的 Kerberos 票证向具有 VBA 的 Java servlet 发送 POST 请求以进行身份​​验证,然后从 servlet 检索 JSON 响应。我可以在不使用 InternetExplorer 对象的情况下实现这一点吗,例如使用 WinHttpRequest?

【问题讨论】:

    标签: vba authentication post kerberos winhttprequest


    【解决方案1】:

    WinHttpRequest 不是 IE 对象。只要您设置放宽安全权限,上述用例就可以完美运行。去年我实现了一个概念验证:Excel、VBA、REST、Tomcat、SPNEGO 身份验证。

    存根代码:

    Dim winHttp As Object
    Set winHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
    
    winHttp.SetAutoLogonPolicy (0)
    winHttp.Open "GET", "http://..."
    winHttp.send
    
    Dim success As Boolean
    success = winHttp.waitForResponse(5)
    If Not success Then
        Debug.Print "DOWNLOAD FAILED!"
        Exit Sub
    End If
    
    Dim responseText As String
    responseText = winHttp.responseText
    

    【讨论】:

    • 感谢您的回复!可以在 VBA 中放宽安全权限吗?您能否从您的概念证明中发布一些相关的 VBA 代码?
    • 再次感谢!我要到星期一才有机会测试你的代码,到时候我会告诉你它是否有效。
    • @user1829001,我很高兴听到你的结果。
    • 看来代码在我的情况下不起作用。我收到来自服务器的响应,上面写着“您的浏览器不支持 SPNEGO/Kerberos 身份验证。需要替代身份验证。”。
    • 我得到了解决方案:实际上它的工作方式与您的代码完全一样,唯一缺少的是 winHttp.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
    猜你喜欢
    • 2015-06-22
    • 1970-01-01
    • 2017-06-28
    • 2017-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多