tag:blogger.com,1999:blog-8912334.post-1125313767215270872005-08-29T03:55:00.000-07:002005-09-21T02:09:41.816-07:00Winform, Web Services & credentialJust a tip today. <br /><br />Last week I built a web service based application which needs a windows authentication. <br />The schema was:<br />A winform client <br />A group of IIS web services. <br />An oracle database (as alway on this blog lol)<br /><br />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"<br /><br />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. <br /><br />Then I changed my web.config file, puting the line :<br /><authentication mode="Windows" /> <br /><br />Ok IIS was then fine to authenticate users. <br />but my Winform webservice client wasn't ready yet. <br /><br />In order to be "windowsly" authenticate a webservice client need to send credentials to the server. <br />The .net framework provide a secure and elegant way to to that:<br /><br /><font face="courrier"><br />using System;<br />using System.Net;<br />....<br /><br />MyService.MyWebMethod ws = new MyService.MyWebMethod();<br />ws.Credentials = <b>CredentialCache.DefaultCredentials</b>;<br />...<br /></font><br /><br />and it works ! <br />I was then able to retrieve informations about my connected users. For instance<br />the login :<br /><font face="courrier"><br />...<br />strlogin = user.identity.name<br />...<br /></font><br /><br />that's all folks! <br />hope this helps!<br />Comments are welcome!Marcnoreply@blogger.com