Use Windows credentials to download file in Windows form app
Posted on 2008-06-11
I'm writing a Windows form application (.NET 2.0, VS2008). I need the app to download some files from an intranet site, but only allow users who are members of a specific AD group to download these files. I've setup the AD group and IIS permissions with no problems. Now I'm a little stuck how to get the right user credentials to download the file with.
As far as I understand, if the user is logged into the AD and I set webclient.UseDefaultCredentials to true, it will pass through the user credentials OK. The scenario I need to allow for is a user who is logged onto their PC locally. I'll need it to prompt for their domain credentials and then pass it to webclient.credentials. This is where I need a hand. Any ideas on how I should cater for that scenario? I've been looking into ICredentials and related bit 'n' pieces and it's got me a littlle baffled.
Any information, suggestions or samples would be appreciated. Thanks.