8

I want to download a file from a Sharepoint server that protected with NTLM authentication from my Android application. I found some tutorials and couldn't successful.

I tried using The Java CIFS Client Library and did not successful again.

I investigated this post: Manipulating SharePoint list items with Android (JAVA) and NTLM Authentication but i do not want to consume a webservice, i just want to download a file.

Any suggestions?

Oguz Ozkeroglu
  • 3,025
  • 3
  • 38
  • 64
  • How do you plan to communicate with SharePoint without using a Web Service? If not you will have to set up some sort of web page where you can get a byte array back by sending the required information like username, password and filename by querystring - would that do? – Eric Herlitz Jul 13 '12 at 21:34
  • I have a url to a file like this: http://sub.domain.com//FolderName/FileName.docx and i want to download and display file to user. When i tested it in a browser, it asked me a username and password and then downloaded file. – Oguz Ozkeroglu Jul 14 '12 at 07:53
  • I'm doing the same thing, I succeeded to connect to Sharepoint and to get file stream, but how did you display the file to the user? – Gaby Jun 16 '14 at 05:53
  • @OguzOzkeroglu : Have you got the solution for it? I am able to get data from NTLM authenticated web services using KSOAP2. I struggling to download file from a NTLM authenticated url same like you. – Monish Kamble Aug 12 '16 at 05:18
  • @MonishKamble : I was, but I don't remember right now, sorry. – Oguz Ozkeroglu Aug 14 '16 at 11:03
  • @OguzOzkeroglu : Thank you for the reply. Its ok. I did it. – Monish Kamble Aug 16 '16 at 11:32
  • @OguzOzkeroglu bununla ilgili çözüm nedir acaba? – arenko Sep 08 '21 at 17:34
  • @arenko 9+ yıl olmuş maalesef pek bir detay hatırlamıyorum. – Oguz Ozkeroglu Sep 15 '21 at 06:07

3 Answers3

3

Did you use standard Java java.net.Authenticator http://developer.android.com/reference/java/net/Authenticator.html? If it doesn't support NTLM check http://developer.android.com/reference/org/apache/http/auth/NTCredentials.html and related org.apache.http package. Also look at blog http://mrrask.wordpress.com/2009/08/21/android-authenticating-via-ntlm/ where it is shown how to use it. In par

Artem Oboturov
  • 4,344
  • 2
  • 30
  • 48
3

Why complicate things

You should be able to send the authentication in the Uri.

URL url = new URL ("http://user:pass@sub.domain.com/FolderName/FileName.docx");

This technique should work with both Windows Authentication and Basic Authentication

Eric Herlitz
  • 25,354
  • 27
  • 113
  • 157
  • Use an account that works. Tested this on 5(!) different SharePoint servers here and it works everywhere. – Eric Herlitz Jul 14 '12 at 15:43
  • The server may be configured to accept only certain authentication protocols. In the cases that work, perhaps the admin set it to work with ANY auth (including basic http auth, not just NTLM). – hopia Jul 02 '13 at 16:23
  • how can i validate that the user and pass are correct?, how can i open the file or webpage? – Bachask8 Oct 14 '13 at 20:42
0

Try using Chilkat, although it's not free. but you can easily implement it in your code.

Chilkat Link

Kevin Tan
  • 169
  • 12