我只是尝试使用Windows身份验证在远程计算机中使用Web服务,但本地和版本中的登录凭据不同远程计算机。
代码段:
Dim objproxy As New WebReference.Service1
'Create a new instance of CredentialCache.
Dim mycredentialCache As CredentialCache = New CredentialCache()
'Create a new instance of NetworkCredential using the client
Dim credentials As NetworkCredential = New NetworkCredential("username", "pwd","domain")
'Add the NetworkCredential to the CredentialCache.
'mycredentialCache.Add(New Uri(objproxy.Url), "Basic", credentials)
objproxy.Credentials = credentials
暂停但是当我使用
时mycredentialCache.Add(New Uri(objproxy.Url), "Basic", credentials)
我收到“401 Unauthorized”消息,
请协助。
答案 0 :(得分:1)
您需要Windows身份验证,因此请使用:
mycredentialCache.Add(New Uri(objproxy.Url), "Negotiate", credentials)