Default credentials

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wild Wind

    #1

    Default credentials

    Hello,

    I have an application which calls a web service across the
    Internet from a client machine.

    The site that I have deployed the application to is such that
    to browse the Internet using a web browser, a person needs to
    do the following:

    (a) ensure that a proxy server address is specified;

    (b) enter a username and password into an authentication dialog
    that comes up whenever they start up the web browser.

    I am finding that as a result, I cannot connect at all to the
    Internet directly.


    I have deployed the same application on other sites that use
    a proxy server to connect to the Internet by specifying the
    proxy server address in my config file and using this address
    to create a proxy for the web service using the following code:

    Dim WSProxy as MyWebServicePro xy
    WSProxy.Proxy = New WebProxy(proxyS erverAddresss, True, _
    Nothing, CredentialCache .DefaultCredent ials)
    WSProxy.CallWeb ServiceMethod()

    However, this works at client sites where I *don't* have to specify
    further authentication before web browsing. In other words, it
    *doesn't* work for the client site first mentioned above.


    My questions are:

    When someone supplies the authentication details when they want
    to use the web browser, are those details added to a CredentialCache ?

    If so, can I get at this CredentialCache to get these credentials?

    If not, should I create my own credentials based on the username,
    password and domain that the user normally enters when accessing
    the web via a web browser?

    TIA,

    --
    Akin

    aknak at aksoto dot idps dot co dot uk



  • Hernan de Lahitte

    #2
    Re: Default credentials

    If you need to pass certain credentials to your proxy WS class, just use
    something like this:

    CredentialCache cache = new CredentialCache ();
    cache.Add( new Uri( WSProxy.Url ), "Negotiate" , new NetworkCredenti als(
    "youruser", "yourpwd", "yourdomain ") );
    WSProxy.Credent ials = cache;

    If you use NTLM auth in IIS, "Negotiate" will be fine. If you use "Basic"
    auth instead, just put "Basic" where it says "negotiate" .
    --
    Hernan de Lahitte
    Lagash Systems S.A.



    This posting is provided "AS IS" with no warranties, and confers no rights.

    "Wild Wind" <nobody@blackho le.com> wrote in message
    news:2l7h6qF9ch 05U1@uni-berlin.de...[color=blue]
    > Hello,
    >
    > I have an application which calls a web service across the
    > Internet from a client machine.
    >
    > The site that I have deployed the application to is such that
    > to browse the Internet using a web browser, a person needs to
    > do the following:
    >
    > (a) ensure that a proxy server address is specified;
    >
    > (b) enter a username and password into an authentication dialog
    > that comes up whenever they start up the web browser.
    >
    > I am finding that as a result, I cannot connect at all to the
    > Internet directly.
    >
    >
    > I have deployed the same application on other sites that use
    > a proxy server to connect to the Internet by specifying the
    > proxy server address in my config file and using this address
    > to create a proxy for the web service using the following code:
    >
    > Dim WSProxy as MyWebServicePro xy
    > WSProxy.Proxy = New WebProxy(proxyS erverAddresss, True, _
    > Nothing, CredentialCache .DefaultCredent ials)
    > WSProxy.CallWeb ServiceMethod()
    >
    > However, this works at client sites where I *don't* have to specify
    > further authentication before web browsing. In other words, it
    > *doesn't* work for the client site first mentioned above.
    >
    >
    > My questions are:
    >
    > When someone supplies the authentication details when they want
    > to use the web browser, are those details added to a CredentialCache ?
    >
    > If so, can I get at this CredentialCache to get these credentials?
    >
    > If not, should I create my own credentials based on the username,
    > password and domain that the user normally enters when accessing
    > the web via a web browser?
    >
    > TIA,
    >
    > --
    > Akin
    >
    > aknak at aksoto dot idps dot co dot uk
    >
    >
    >[/color]


    Comment

    • Wild Wind

      #3
      Re: Default credentials

      Hello Hernan,

      Thanks for your answer.

      Is there a way of knowing whether the dialog box that
      comes up on my client site requires NTLM or Basic authentication?

      As I said, the dialog comes up whichever site you visit using
      a web browser - I assume it must be something they have set up
      on their firewall.

      Will it matter if I just use "Negotiate" ?

      Also, if I add several NetworkCredenti al objects to my cache, and add
      this cache to my proxy, will it use all of the credentials in the
      cache to authenticate until one succeeds?

      Thanks in advance,

      Akin

      "Hernan de Lahitte" <hernan@lagash. com> wrote in message
      news:%23iTAeRgZ EHA.212@TK2MSFT NGP12.phx.gbl.. .[color=blue]
      > If you need to pass certain credentials to your proxy WS class, just use
      > something like this:
      >
      > CredentialCache cache = new CredentialCache ();
      > cache.Add( new Uri( WSProxy.Url ), "Negotiate" , new NetworkCredenti als(
      > "youruser", "yourpwd", "yourdomain ") );
      > WSProxy.Credent ials = cache;
      >
      > If you use NTLM auth in IIS, "Negotiate" will be fine. If you use "Basic"
      > auth instead, just put "Basic" where it says "negotiate" .
      > --
      > Hernan de Lahitte
      > Lagash Systems S.A.
      > http://weblogs.asp.net/hernandl
      >
      >
      > This posting is provided "AS IS" with no warranties, and confers no[/color]
      rights.[color=blue]
      >
      > "Wild Wind" <nobody@blackho le.com> wrote in message
      > news:2l7h6qF9ch 05U1@uni-berlin.de...[color=green]
      > > Hello,
      > >
      > > I have an application which calls a web service across the
      > > Internet from a client machine.
      > >
      > > The site that I have deployed the application to is such that
      > > to browse the Internet using a web browser, a person needs to
      > > do the following:
      > >
      > > (a) ensure that a proxy server address is specified;
      > >
      > > (b) enter a username and password into an authentication dialog
      > > that comes up whenever they start up the web browser.
      > >
      > > I am finding that as a result, I cannot connect at all to the
      > > Internet directly.
      > >
      > >
      > > I have deployed the same application on other sites that use
      > > a proxy server to connect to the Internet by specifying the
      > > proxy server address in my config file and using this address
      > > to create a proxy for the web service using the following code:
      > >
      > > Dim WSProxy as MyWebServicePro xy
      > > WSProxy.Proxy = New WebProxy(proxyS erverAddresss, True, _
      > > Nothing, CredentialCache .DefaultCredent ials)
      > > WSProxy.CallWeb ServiceMethod()
      > >
      > > However, this works at client sites where I *don't* have to specify
      > > further authentication before web browsing. In other words, it
      > > *doesn't* work for the client site first mentioned above.
      > >
      > >
      > > My questions are:
      > >
      > > When someone supplies the authentication details when they want
      > > to use the web browser, are those details added to a CredentialCache ?
      > >
      > > If so, can I get at this CredentialCache to get these credentials?
      > >
      > > If not, should I create my own credentials based on the username,
      > > password and domain that the user normally enters when accessing
      > > the web via a web browser?
      > >
      > > TIA,
      > >
      > > --
      > > Akin
      > >
      > > aknak at aksoto dot idps dot co dot uk
      > >
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Hernan de Lahitte

        #4
        Re: Default credentials

        > Is there a way of knowing whether the dialog box that[color=blue]
        > comes up on my client site requires NTLM or Basic authentication?[/color]
        When you first try to communicate with your WS server, you will receive a
        header with the authentication method required by IIS. There you have a
        sample code that will read the auth. header.

        try
        {
        WebRequest wreq = WebRequest.Crea te( new Uri( url ) ); //url is your WS
        URL.
        WebResponse wresp = wreq.GetRespons e();
        wresp.Close();
        }
        catch( WebException e )
        {
        if( e.Status == WebExceptionSta tus.ProtocolErr or )
        {
        string rawMethod = e.Response.Head ers[ "WWW-Authenticate" ];
        // rawMethod will has the required authentication method
        }
        else
        {
        throw;
        }
        }
        [color=blue]
        > As I said, the dialog comes up whichever site you visit using
        > a web browser - I assume it must be something they have set up
        > on their firewall.[/color]
        If your receive a Dialog asking for your creds with NTLM auth (not Basic)
        check out your IE configuration
        (Tools/Options/Security/[Custom Level] User Authentication (Prompt for user
        name and password) option checked.
        [color=blue]
        > Will it matter if I just use "Negotiate" ?[/color]
        This will work only for Integrated Windows Authentication method (Negotiate
        will switch between Kerberos and NTLM).
        [color=blue]
        > Also, if I add several NetworkCredenti al objects to my cache, and add
        > this cache to my proxy, will it use all of the credentials in the
        > cache to authenticate until one succeeds?[/color]
        Sure. You may use something like this:

        CredentialCache cache = new CredentialCache ();

        cache.Add(new Uri( WSProxy.Url ),"Basic",new NetworkCredenti al( "youruser",
        "yourpwd", "yourdomain ") );
        cache.Add(new Uri( WSProxy.Url ),"Negotiate" , new
        NetworkCredenti al("youruser", "yourpwd", "yourdomain ") );

        WSProxy.Credent ials = cache;
        And depending on your Auth method, the appropiate credential will be used.
        Always remember that the DefaultCredenti als property contains the system
        credentials of the current security context. For client applications, these
        represent the user name, password, and domain of the user who is currently
        logged in. For ASP.NET applications, the default credentials are the user
        credentials of the logged-in user or the user being impersonated.

        Regards,
        Hernan.

        --
        Hernan de Lahitte
        Lagash Systems S.A.



        This posting is provided "AS IS" with no warranties, and confers no rights.

        "Wild Wind" <nobody@blackho le.com> wrote in message
        news:2l8si6Fa6j fpU1@uni-berlin.de...[color=blue]
        > Hello Hernan,
        >
        > Thanks for your answer.
        >
        > Is there a way of knowing whether the dialog box that
        > comes up on my client site requires NTLM or Basic authentication?
        >
        > As I said, the dialog comes up whichever site you visit using
        > a web browser - I assume it must be something they have set up
        > on their firewall.
        >
        > Will it matter if I just use "Negotiate" ?
        >[/color]
        [color=blue]
        > Thanks in advance,
        >
        > Akin
        >
        > "Hernan de Lahitte" <hernan@lagash. com> wrote in message
        > news:%23iTAeRgZ EHA.212@TK2MSFT NGP12.phx.gbl.. .[color=green]
        > > If you need to pass certain credentials to your proxy WS class, just use
        > > something like this:
        > >
        > > CredentialCache cache = new CredentialCache ();
        > > cache.Add( new Uri( WSProxy.Url ), "Negotiate" , new NetworkCredenti als(
        > > "youruser", "yourpwd", "yourdomain ") );
        > > WSProxy.Credent ials = cache;
        > >
        > > If you use NTLM auth in IIS, "Negotiate" will be fine. If you use[/color][/color]
        "Basic"[color=blue][color=green]
        > > auth instead, just put "Basic" where it says "negotiate" .
        > > --
        > > Hernan de Lahitte
        > > Lagash Systems S.A.
        > > http://weblogs.asp.net/hernandl
        > >
        > >
        > > This posting is provided "AS IS" with no warranties, and confers no[/color]
        > rights.[color=green]
        > >
        > > "Wild Wind" <nobody@blackho le.com> wrote in message
        > > news:2l7h6qF9ch 05U1@uni-berlin.de...[color=darkred]
        > > > Hello,
        > > >
        > > > I have an application which calls a web service across the
        > > > Internet from a client machine.
        > > >
        > > > The site that I have deployed the application to is such that
        > > > to browse the Internet using a web browser, a person needs to
        > > > do the following:
        > > >
        > > > (a) ensure that a proxy server address is specified;
        > > >
        > > > (b) enter a username and password into an authentication dialog
        > > > that comes up whenever they start up the web browser.
        > > >
        > > > I am finding that as a result, I cannot connect at all to the
        > > > Internet directly.
        > > >
        > > >
        > > > I have deployed the same application on other sites that use
        > > > a proxy server to connect to the Internet by specifying the
        > > > proxy server address in my config file and using this address
        > > > to create a proxy for the web service using the following code:
        > > >
        > > > Dim WSProxy as MyWebServicePro xy
        > > > WSProxy.Proxy = New WebProxy(proxyS erverAddresss, True, _
        > > > Nothing, CredentialCache .DefaultCredent ials)
        > > > WSProxy.CallWeb ServiceMethod()
        > > >
        > > > However, this works at client sites where I *don't* have to specify
        > > > further authentication before web browsing. In other words, it
        > > > *doesn't* work for the client site first mentioned above.
        > > >
        > > >
        > > > My questions are:
        > > >
        > > > When someone supplies the authentication details when they want
        > > > to use the web browser, are those details added to a CredentialCache ?
        > > >
        > > > If so, can I get at this CredentialCache to get these credentials?
        > > >
        > > > If not, should I create my own credentials based on the username,
        > > > password and domain that the user normally enters when accessing
        > > > the web via a web browser?
        > > >
        > > > TIA,
        > > >
        > > > --
        > > > Akin
        > > >
        > > > aknak at aksoto dot idps dot co dot uk
        > > >
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        Working...