Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > How to CHANGE the Credentials for a web service proxy when using CredentialCache ?

Reply
Thread Tools

How to CHANGE the Credentials for a web service proxy when using CredentialCache ?

 
 
Liviu Olaru
Guest
Posts: n/a
 
      01-21-2004
Hi

I'm trying to invoke a Web Service which is using BASIC authentication.
Code for invoking:

CredentialCache cc = new CredentialCache();
//the network credential used to authenticate client
NetworkCredential networkCred = new NetworkCredential("USERNAME",
"PASSWORD");
// the web service proxy
WSProxy wsProxy = new WSProxy();

//Add the network credential to the cache
cc.Add(new Uri(wsProxy.Url), "Basic", networkCred);
//Set the proxy credentials
wsProxy.Credentials = cc;

//call a method on proxy
wsProxy.HellloWorld();

I WANT TO USE THE SAME URL WITH DIFFERENT CREDENTIALS.( OR WITH NO
CREDENTIAL )

//so, now I try to remove the credential from cache
cc.Remove(new Uri(wsProxy.Url), "Basic")

If I remove the credential from CredentialCache, the subsequent calls to
the web service will use the same credentials as for the first call, even
the CredentialCache is empty !

so, when I call

WSProxy wsProxy2 = new WSProxy();
wsProxy.Credentials = cc; // THIS LINE HAS NO EFFECT ! CAN BE COMMENTED
OUT !
wsProxy2.HelloWorld();

the client is autenticated with the old credentials. (I wanted to get
AccesDenied)

It seems that, for the first call, the SoapHttpClientProtocol.Invoke
method, in the case of a successful request, copies the credentials from
CredentialCache and store them, per URL basis, in a internal store that is
used for subsequent calls, even the new proxys have been setted different
credentials.

Thanks











 
Reply With Quote
 
 
 
 
Jan Tielens
Guest
Posts: n/a
 
      01-21-2004
Try this:

NetworkCredential networkCred = new NetworkCredential("USERNAME",
"PASSWORD");

// the web service proxy
WSProxy wsProxy = new WSProxy();
wsProxy.Credentials = networkCred;
// do stuff

WSProxy wsProxy2 = new WSProxy();
// do stuff

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan


"Liviu Olaru" <(E-Mail Removed)> wrote in message
news:#kf5eK$(E-Mail Removed)...
> Hi
>
> I'm trying to invoke a Web Service which is using BASIC

authentication.
> Code for invoking:
>
> CredentialCache cc = new CredentialCache();
> //the network credential used to authenticate client
> NetworkCredential networkCred = new NetworkCredential("USERNAME",
> "PASSWORD");
> // the web service proxy
> WSProxy wsProxy = new WSProxy();
>
> //Add the network credential to the cache
> cc.Add(new Uri(wsProxy.Url), "Basic", networkCred);
> //Set the proxy credentials
> wsProxy.Credentials = cc;
>
> //call a method on proxy
> wsProxy.HellloWorld();
>
> I WANT TO USE THE SAME URL WITH DIFFERENT CREDENTIALS.( OR WITH NO
> CREDENTIAL )
>
> //so, now I try to remove the credential from cache
> cc.Remove(new Uri(wsProxy.Url), "Basic")
>
> If I remove the credential from CredentialCache, the subsequent calls

to
> the web service will use the same credentials as for the first call, even
> the CredentialCache is empty !
>
> so, when I call
>
> WSProxy wsProxy2 = new WSProxy();
> wsProxy.Credentials = cc; // THIS LINE HAS NO EFFECT ! CAN BE

COMMENTED
> OUT !
> wsProxy2.HelloWorld();
>
> the client is autenticated with the old credentials. (I wanted to get
> AccesDenied)
>
> It seems that, for the first call, the SoapHttpClientProtocol.Invoke
> method, in the case of a successful request, copies the credentials from
> CredentialCache and store them, per URL basis, in a internal store that is
> used for subsequent calls, even the new proxys have been setted different
> credentials.
>
> Thanks
>
>
>
>
>
>
>
>
>
>
>



 
Reply With Quote
 
 
 
 
Liviu Olaru
Guest
Posts: n/a
 
      01-21-2004

I have multiple URLs the client can authenticate to and I do not want to ask
user for credentials again.

Sorry, Jan, that I replied private.

"Jan Tielens" <(E-Mail Removed)> wrote in message
news:efsogP$(E-Mail Removed)...
> Try this:
>
> NetworkCredential networkCred = new NetworkCredential("USERNAME",
> "PASSWORD");
>
> // the web service proxy
> WSProxy wsProxy = new WSProxy();
> wsProxy.Credentials = networkCred;
> // do stuff
>
> WSProxy wsProxy2 = new WSProxy();
> // do stuff
>
> --
> Greetz
>
> Jan Tielens
> ________________________________
> Read my weblog: http://weblogs.asp.net/jan
>
>
> "Liviu Olaru" <(E-Mail Removed)> wrote in message
> news:#kf5eK$(E-Mail Removed)...
> > Hi
> >
> > I'm trying to invoke a Web Service which is using BASIC

> authentication.
> > Code for invoking:
> >
> > CredentialCache cc = new CredentialCache();
> > //the network credential used to authenticate client
> > NetworkCredential networkCred = new NetworkCredential("USERNAME",
> > "PASSWORD");
> > // the web service proxy
> > WSProxy wsProxy = new WSProxy();
> >
> > //Add the network credential to the cache
> > cc.Add(new Uri(wsProxy.Url), "Basic", networkCred);
> > //Set the proxy credentials
> > wsProxy.Credentials = cc;
> >
> > //call a method on proxy
> > wsProxy.HellloWorld();
> >
> > I WANT TO USE THE SAME URL WITH DIFFERENT CREDENTIALS.( OR WITH NO
> > CREDENTIAL )
> >
> > //so, now I try to remove the credential from cache
> > cc.Remove(new Uri(wsProxy.Url), "Basic")
> >
> > If I remove the credential from CredentialCache, the subsequent

calls
> to
> > the web service will use the same credentials as for the first call,

even
> > the CredentialCache is empty !
> >
> > so, when I call
> >
> > WSProxy wsProxy2 = new WSProxy();
> > wsProxy.Credentials = cc; // THIS LINE HAS NO EFFECT ! CAN BE

> COMMENTED
> > OUT !
> > wsProxy2.HelloWorld();
> >
> > the client is autenticated with the old credentials. (I wanted to

get
> > AccesDenied)
> >
> > It seems that, for the first call, the

SoapHttpClientProtocol.Invoke
> > method, in the case of a successful request, copies the credentials from
> > CredentialCache and store them, per URL basis, in a internal store that

is
> > used for subsequent calls, even the new proxys have been setted

different
> > credentials.
> >
> > Thanks
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >

>
>



 
Reply With Quote
 
Jan Tielens
Guest
Posts: n/a
 
      01-21-2004
Please look for follow-ups on this thread in the framework.webservices
newsgroup...

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan


"Liviu Olaru" <(E-Mail Removed)> wrote in message
news:#CKyXX$(E-Mail Removed)...
>
> I have multiple URLs the client can authenticate to and I do not want to

ask
> user for credentials again.
>
> Sorry, Jan, that I replied private.
>
> "Jan Tielens" <(E-Mail Removed)> wrote in message
> news:efsogP$(E-Mail Removed)...
> > Try this:
> >
> > NetworkCredential networkCred = new NetworkCredential("USERNAME",
> > "PASSWORD");
> >
> > // the web service proxy
> > WSProxy wsProxy = new WSProxy();
> > wsProxy.Credentials = networkCred;
> > // do stuff
> >
> > WSProxy wsProxy2 = new WSProxy();
> > // do stuff
> >
> > --
> > Greetz
> >
> > Jan Tielens
> > ________________________________
> > Read my weblog: http://weblogs.asp.net/jan
> >
> >
> > "Liviu Olaru" <(E-Mail Removed)> wrote in message
> > news:#kf5eK$(E-Mail Removed)...
> > > Hi
> > >
> > > I'm trying to invoke a Web Service which is using BASIC

> > authentication.
> > > Code for invoking:
> > >
> > > CredentialCache cc = new CredentialCache();
> > > //the network credential used to authenticate client
> > > NetworkCredential networkCred = new NetworkCredential("USERNAME",
> > > "PASSWORD");
> > > // the web service proxy
> > > WSProxy wsProxy = new WSProxy();
> > >
> > > //Add the network credential to the cache
> > > cc.Add(new Uri(wsProxy.Url), "Basic", networkCred);
> > > //Set the proxy credentials
> > > wsProxy.Credentials = cc;
> > >
> > > //call a method on proxy
> > > wsProxy.HellloWorld();
> > >
> > > I WANT TO USE THE SAME URL WITH DIFFERENT CREDENTIALS.( OR WITH NO
> > > CREDENTIAL )
> > >
> > > //so, now I try to remove the credential from cache
> > > cc.Remove(new Uri(wsProxy.Url), "Basic")
> > >
> > > If I remove the credential from CredentialCache, the subsequent

> calls
> > to
> > > the web service will use the same credentials as for the first call,

> even
> > > the CredentialCache is empty !
> > >
> > > so, when I call
> > >
> > > WSProxy wsProxy2 = new WSProxy();
> > > wsProxy.Credentials = cc; // THIS LINE HAS NO EFFECT ! CAN BE

> > COMMENTED
> > > OUT !
> > > wsProxy2.HelloWorld();
> > >
> > > the client is autenticated with the old credentials. (I wanted to

> get
> > > AccesDenied)
> > >
> > > It seems that, for the first call, the

> SoapHttpClientProtocol.Invoke
> > > method, in the case of a successful request, copies the credentials

from
> > > CredentialCache and store them, per URL basis, in a internal store

that
> is
> > > used for subsequent calls, even the new proxys have been setted

> different
> > > credentials.
> > >
> > > Thanks
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
"The credentials supplied conflict with an existing set of credentials" -=rjh=- NZ Computing 2 07-15-2006 11:09 PM
Credentials persist after CredentialCache.Remove() Stan Rawrysz ASP .Net Security 0 04-14-2005 12:51 AM
How to CHANGE the Credentials for a web service proxy when using CredentialCache ? Liviu Olaru ASP .Net Security 3 01-21-2004 08:39 AM
authentication using CredentialCache against proxy server problem Tom ASP .Net Security 0 08-07-2003 08:15 AM



Advertisments