BITS 2.0 authentication error

Topics: Updater Application Block
Feb 16, 2005 at 7:54 AM
originally posted by: rs220

I downloaded the BITS 2.0 fix, and updated my BITSDownloader.cs, BITSInterop.cs, added the config file settings for user authentication, and added the BITS wrapper. The manifest file downloads without a problem, but BITS returns an error trying to download the files for the update (The requested resource requires user authentication). All files that should be downloaded are listed in my log file, and then the BITS error appears. Anonymous access is enabled in IIS. I've tried several authentication methods with and without sending a username and password. Everything is fine if I use "localhost" in my URL, but if I use the machine name, I get the authentication error. I can get to the manifest file directly in IE.

Also, the BITS fix ( mentions IBackgroundCopyJob2, but I don't see IBackgroundCopyJob2 implemented anywhere in the new BITS code.
Feb 18, 2005 at 5:30 AM
originally posted by: provmed

I was working with the same issue. The manifest would download, the directory structures would be created, then temporary file stubs would be created, but then BITS would fail. I found that the main issue was with the IIS setting for the virtual directory. On the properties for the Directory set the the Script Source Access check box, Read of course needs to be set, but write should be unchecked, unless you are pushing to the server, and Directory Browsing is optional. I find will testing that is good to be used, but probably not for the final configuration. Also, relating to the BackGroundCopy2. We were using the BITS wrapper initiallty, which adds some overhead to the project. Did some testing and found that the BackgroundCopy2 can be refernenced is the setting of credentials. I followed the example. The following is a code snippet from the BITSDownloader.cs file. Also there is a better outlined BITSInterop.cs. Adaptation may be needed for your use, but try without changing this first. I did not. Made the change, same result, found the configuration and tested.

/// <summary>
/// Method responsible for setting the credentials on the BackgroundJob.
/// </summary>
/// <param name="backGroundCopyJob">
/// BackgroundJob to set the credentials on.
/// </param>
private void SetBackgroundJobCredentials(IBackgroundCopyJob backGroundCopyJob)
IBackgroundCopyJob2 copyJob = (IBackgroundCopyJob2) backGroundCopyJob;

credentials.Credentials.Basic.UserName = userName;
credentials.Credentials.Basic.Password = password;
credentials.Scheme = authenticationScheme;
credentials.Target = targetServerType;
copyJob.SetCredentials(ref credentials);
Feb 24, 2005 at 7:02 AM
originally posted by: rs220

Thanks for the info. I ended up fixing this with IIS settings. I saw a similar issue related to Windows Server 2003, but I'm running XP and the fix worked. In IIS, I removed the mapping for ".config" (under "Mappings" from the Configuration button). I also had to add additional MIME types for all file types that would be served as updates. It was allowing dlls to download, but I had to add exe, pdf, etc.