Web Service Credentials - Access Denied

Discussion in 'ASP .Net Security' started by Stan, Dec 8, 2003.

  1. Stan

    Stan Guest

    I am having problems passing the credentials from the
    current user to the Web Service. THANK YOU in advance for
    any help!!

    Web Service and Web application are on different machines.
    Anonymous logon is off and Inegrated Security on for both.
    Impersonate is set to true.

    Web application code ...
    WebService MyWebService = new WebService();
    //MyWebService.Credentials = new NetworkCredential
    (UserName, PW, Domain);
    MyWebService.DoWork();

    Error: HTTP status 401: Access Denied.

    If I uncomment the MyWebService.Credentials and hard code
    the credentials then it works. But, I need to pass the
    credentials of the current user.

    I've tried just passing the Credential cache
    MyWebService.Credentials = new System.Net.CredentialCache
    ();

    I've tried using Digest authentication to no avail:
    CredentialCache cache = new CredentialCache();
    cache.Add( new Uri(MyWebService.Url), "Digest", new
    NetworkCredential(UserName, password, domain));
    MyWebService.Credentials = cache;

    Thanks again for any help
     
    Stan, Dec 8, 2003
    #1
    1. Advertising

  2. Stan

    maud_chiva Guest

    You must use the static method
    MyWebService.Credentials =
    CredentialCache.DefaultCredential;
    in order to pass the current authenticated user
    credential to the webservice.

    See http://msdn.microsoft.com/library/default.asp?
    url=/library/en-
    us/cpguide/html/cpconusinginternetrequestresponseclasses.a
    sp


    >-----Original Message-----
    >I am having problems passing the credentials from the
    >current user to the Web Service. THANK YOU in advance

    for
    >any help!!
    >
    >Web Service and Web application are on different

    machines.
    >Anonymous logon is off and Inegrated Security on for

    both.
    >Impersonate is set to true.
    >
    >Web application code ...
    >WebService MyWebService = new WebService();
    >//MyWebService.Credentials = new NetworkCredential
    >(UserName, PW, Domain);
    >MyWebService.DoWork();
    >
    >Error: HTTP status 401: Access Denied.
    >
    >If I uncomment the MyWebService.Credentials and hard

    code
    >the credentials then it works. But, I need to pass the
    >credentials of the current user.
    >
    >I've tried just passing the Credential cache
    >MyWebService.Credentials = new System.Net.CredentialCache
    >();
    >
    >I've tried using Digest authentication to no avail:
    >CredentialCache cache = new CredentialCache();
    >cache.Add( new Uri(MyWebService.Url), "Digest", new
    >NetworkCredential(UserName, password, domain));
    >MyWebService.Credentials = cache;
    >
    >Thanks again for any help
    >
    >.
    >
     
    maud_chiva, Dec 8, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    8,235
    Clint ()
    Dec 21, 2004
  2. mangia

    Access Denied - Network Service vs Local Service

    mangia, Sep 23, 2004, in forum: ASP .Net Security
    Replies:
    3
    Views:
    255
    Ken Schaefer
    Sep 27, 2004
  3. Homa

    Access Denied with Custom Credentials

    Homa, Sep 27, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    121
  4. Alex Washtell via .NET 247

    Web Service + Anon Access, but getting 401 Access Denied Error

    Alex Washtell via .NET 247, Apr 5, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    216
    Mauro Ottaviani [MSFT]
    Apr 5, 2005
  5. Rajiv Abraham
    Replies:
    3
    Views:
    310
    Rajiv Abraham
    Apr 16, 2010
Loading...

Share This Page