user81503
user81503

Reputation: 21

Consuming Web Service via Windows Authentication

I am just trying to consuming a web service in remote computer using windows authentication however login credentials are different in local & remote computer.

Code Snippet:

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

It is timing out but when i use

mycredentialCache.Add(New Uri(objproxy.Url), "Basic", credentials)

I get "401 Unauthorized" message,

Please assist.

Upvotes: 1

Views: 2584

Answers (1)

Randy Levy
Randy Levy

Reputation: 22655

You want windows authentication so use:

mycredentialCache.Add(New Uri(objproxy.Url), "Negotiate", credentials)

See Passing Credentials for Authentication to Web Services

Upvotes: 1

Related Questions