How to pass credentials to a web service???

E

Ed Staffin

When my users log into my web app they do it using Windows auth.

Now, when they do something that needs to call our WebService that updates
WSS, one of the things we are currently doing in the constructor of the
service is:

Public Sub New()
MyBase.New()
m_Svc = New MySvc
m_Svc.Credentials = CredentialCache.DefaultCredentials
End Sub

The problem with this is that I believe the DefaultCredential is not that of
my logged in user.

So, the question of the moment is, how do I translate User.Identity or User
or whatever it is off the User object, into a variable that I can assign to
m_Svc.Credentials?

In other words, what I kinda want to do is:

Public Sub New(c as System.Net.ICredentials )
MyBase.New()
m_Svc = New MySvc
m_Svc.Credentials = c
End Sub


So, when I create my object it goes something like:

Dim oUser As New EkWssComWrapper.EkWssProjectUser(User.Identity.????)
Thanks ... Ed



What do I pass here?
 
T

Timothy H. Schilbach

This always works for me:

Dim usrLookup As New ADGroupLookup.Service

'make sure we authenticate to our protected web service

usrLookup.Credentials = New System.Net.NetworkCredential("domain\username",
"password")

That should work like a charm

-Timothy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top