UserID and PWD sent to Webservice

I have this code in my client app "windows forms":

CredentialCache cc = new CredentialCache();
WebService ws = new testApp.WebService();
cc.Add(new Uri(ws.Url), "Basic", new NetworkCredential("userName", "MyPwd"));
ws.PreAuthenticate = true;
ws.Credentials = cc;
MessageBox.Show(s.HelloWorld());

Now, in the server side "web service", how do i retreive the user id and the pwd i added to the credentialcache..

i tried User.Identity.Name but it showed me the name of the current windows user that uses the Client app....

Thanks




Answer this question

UserID and PWD sent to Webservice

  • Trixtan

    Hello,

    thank you but thats now what i wanted, i have the user names and pwds saved on database and i want to authenticate them myself, all i want to know is how to get the user name and pwd that were sent in the request...



  • EricLeBouffon

    Which method u want to use (Basic auth or SoapHeader)

  • Teggno

  • Bakker

    If u still want to use Basic authentication then u can retreive username and password by writing custom authentication module. In the AuthenticateRequest event u can decode authorization header to get username and password.



  • AlinB

    If u r using IIS to host ur web service then just turn on Basic auth in IIS.

    IIS will do the authentication. So u must have a user account which u r passing in the credential cache.

    Let us say that if user and pwd is test/test and machine name is MachineName

    Then

    User.Identity.AuthenticationType = "Basic"

    User.Identity.IsAuthenticated= true
    User.Identity.Name = MachineName\test




  • NLARGE

    i need some code samples please

    thank you



  • BillyB26

    Then why u want to use Basic authentication. Basic authentication is also not secure unless u use SSL. For custom authentication u can use WSE which provides security.

    If u don't care if the user and pwd are sent in clear text then u can use custom SoapHeader to send user and pwd and on the server u will have both user and pwd available to authenticate.



  • amit lohia

    i really do not know much about the two.. so if you can show me a sample of both a will be appreciated...

    thanks alot in advance



  • UserID and PWD sent to Webservice