Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to download word document hosted on Windows qshare from a Linux machine

 
Bhaskar Kamuju
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to download a word document from a Windows/Microsoft qshare location using Java.

I use the following code to do that


This works perfectly fine when I run it from a windows machine.
But it throws an exeption "401- Unauthorized access" when I try to run this from a Linux machine.
java.io.IOException: Server returned HTTP response code: 401 for URL: http://qshare/sites/ib_coe/Footprint.doc
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon nection.java:1313)
at FileReaderTest.readFileFromServer(FileReaderTest.java:58)
at FileReaderTest.main(FileReaderTest.java:92)

Both the Linux machine and the qshare are in the same network, so I don't see any firewall issue here.

So, is there any other property I need to set?

Can anyone tell me how this can be resolved?

One more thing is when I try to open "http://qshare/sites/ib_coe/Footprint.doc" using Firefox, I keep getting an alert prompting for username/password, but I am not able to go in inspite of entering the username and password. Whereas in IE I can go directly in, it does some windows authentication and allows me to enter without prompting for username/password.



Thanks,
Bhaskar

 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more thing is when I try to open "http://qshare/sites/ib_coe/Footprint.doc" using Firefox, I keep getting an alert prompting for username/password, but I am not able to go in inspite of entering the username and password.

This statement is the key! What are you using to host qshare? IIS? If so, how is the security configured in IIS? Is it using integrated Windows authentication (don't think that is the correct technical term, but I hope you get the idea)? If so, then running the code from Windows works because the OSes are swapping credentials (the credentials in your code are being ignored). If all of this is so, you need to modify how IIS is doing authentication. Only when you can access the document via Firefox by entering in the username/password will your Java code work.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic