DefaultCredentials and WebClient

Discussion in 'ASP .Net Security' started by Colin Bowern, Jan 9, 2004.

  1. Colin Bowern

    Colin Bowern Guest

    I'm trying to make a call inside an ASP.NET web application to an external
    quasi-web service (aka FrontPage Server Extensions):

    Dim rpcClient As New WebClient
    Dim rpcData As New NameValueCollection
    Dim rpcResponseArray As Byte()

    rpcData.Add("method", "open service:6.0.2.5530")
    rpcClient.Credentials = System.Net.CredentialCache.DefaultCredentials
    rpcClient.Headers.Add("X-Vermeer-Content-Type",
    "application/x-www-form-urlencoded")
    rpcResponseArray = rpcClient.UploadValues(currentSite.Url.ToString() +
    "/_vti_bin/_vti_aut/author.dll", rpcData)

    The app however, is throwing back a 401 Unauthorized. I've been able to
    validate the right context is passing through the app by checking
    System.Security.Principal.WindowsIdentity.GetCurrent().Name to see the right
    user name. And if I create the credential cache manually, it works:

    Dim myCreds As New NetworkCredential("userid", "password", "mydomain")
    Dim myCache As New CredentialCache
    myCache.Add(New Uri("http://dev.mydomain.net/"), "Basic", myCreds)
    rpcClient.Credentials = myCache

    Any thoughts on why impersonation wouldn't pass through the right
    credentials to teh WebClient class in an ASP.NET web application?

    Thanks!
    Colin
     
    Colin Bowern, Jan 9, 2004
    #1
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.