Winform, Web Services & credential
Just a tip today.
Last week I built a web service based application which needs a windows authentication.
The schema was:
A winform client
A group of IIS web services.
An oracle database (as alway on this blog lol)
How could the winform client say to the web services. "Hey i'm a member of this windows network, my login is Jdoe, trust me"
Ok, first I asked my favourite web administrator to configure my IIS application to not allow anonymous users. Exactly like for a classical ASPX application.
Then I changed my web.config file, puting the line :
<authentication mode="Windows" />
Ok IIS was then fine to authenticate users.
but my Winform webservice client wasn't ready yet.
In order to be "windowsly" authenticate a webservice client need to send credentials to the server.
The .net framework provide a secure and elegant way to to that:
MyService.MyWebMethod ws = new MyService.MyWebMethod();
ws.Credentials = CredentialCache.DefaultCredentials;
and it works !
I was then able to retrieve informations about my connected users. For instance
the login :
strlogin = user.identity.name
that's all folks!
hope this helps!
Comments are welcome!