Page view counter

Forward Credentials from ASP.NET Web-application to ASP.NET Web-Service

Last post 08-26-2005 9:54 PM by JawadKhan. 3 replies.

Sort Posts:

  • Forward Credentials from ASP.NET Web-application to ASP.NET Web-Service

    08-23-2005, 12:09 PM
    • Loading...
    • nissan
    • Joined on 05-10-2005, 4:32 PM
    • Posts 257
    • Points 911
    Hi,
    I don't have much knowledge about this. But, i have to get the person's UID and pwd who is logged into windows and pass this info along to a web service. Any ideas?
  • Re: Forward Credentials from ASP.NET Web-application to ASP.NET Web-Service

    08-23-2005, 12:52 PM
    • Loading...
    • JawadKhan
    • Joined on 03-08-2005, 7:41 PM
    • Toronto, Canada
    • Posts 1,066
    • Points 5,360
    You have to add similiar code like this ...

    //Create an instance of the CredentialCache class.
    CredentialCache cache = new CredentialCache();

    // Add a NetworkCredential instance to CredentialCache.
    // Negotiate for NTLM or Kerberos authentication.
    cache.Add( new Uri(myProxy.Url), "Negotiate", new NetworkCredential("UserName", "Password", "Domain"));

    //Assign CredentialCache to the Web service Client Proxy(myProxy) Credetials property.
    myProxy.Credentials = cache;

    or Visual basic.Net
    'Create an instance of the CredentialCache class.
    Dim cache As CredentialCache = New CredentialCache()

    'Add a NetworkCredential instance to CredentialCache.
    'Negotiate for NTLM or Kerberos authentication.
    cache.Add(New Uri(myProxy.Url), "Negotiate", New NetworkCredential("UserName", "Password", "Domain"))

    'Assign CredentialCache to the Web service Client Proxy(myProxy) Credetials property.
    myProxy.Credentials = cache

    Use System.Net.CredentialCache.DefaultCredentials instead of  new NetworkCredential("UserName", "Password", "Domain") if you want to pass the currently logged in user credentials. Make sure you have anonymous access disabled in IIS.
  • Re: Forward Credentials from ASP.NET Web-application to ASP.NET Web-Service

    08-26-2005, 5:21 PM
    • Loading...
    • nissan
    • Joined on 05-10-2005, 4:32 PM
    • Posts 257
    • Points 911
    Could u please explain me more about this :
    what is,  new Uri(myProxy.Url),  what are we doing here??
     
    I want to use Integrated Security and log on to another external server and pass these credentials to a web service which is on the external server. what can i do to achieve that. Could u please let me know.
  • Re: Forward Credentials from ASP.NET Web-application to ASP.NET Web-Service

    08-26-2005, 9:54 PM
    • Loading...
    • JawadKhan
    • Joined on 03-08-2005, 7:41 PM
    • Toronto, Canada
    • Posts 1,066
    • Points 5,360

    Hi Nissan,

       Here is a very Simple Example ....

        http://samples.gotdotnet.com/quickstart/aspplus/doc/secureservices.aspx


       Proxy class is the class which gets created when you add a WebReference to your Project i.e. client that is calling the WebService. You can also generate that class using wsdl tool.

    Specifically look at the code NetWork credentials and username and password getting passed.

    Since the Webservice is on external server and not in your domain you have to use the method as described in the example in the link rather then passing your current credentials.

Page 1 of 1 (4 items)