Download file from SharePoint 2013 with authentication
Download file from SharePoint 2013 with authentication
I have a vb.net Tool, that Downloads a *. Zip file from a SharePoint Server. Till now it worked under SharePoint 2007.
Under SharePoint 2013 and I’m not abel to Download the File anymore. Under SharePoint 2013 the User has to Authenticate himself over this mask Authentication side in the Browser.
This was the Old Solution that worked on SharePoint 2007
Dim WebIntranet As New WebClient
Dim strURL as String = "https://example.com/content/P123456/Documents/File.zip"
WebIntranet.UseDefaultCredentials = True
'Download the File from the Server
WebIntranet.DownloadFile(strURL,
"D:TempFile.zip ")
For the new Solution it didn’t work and i tryed a few things:
First Approch:
Dim client As New WebClient
Dim _UserAgend As String = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36"
Dim strURL as String = "https://example.com/content/P123456/Documents/File.zip"
client.Headers.Add(HttpRequestHeader.UserAgent, _UserAgend)
WebIntranet.DownloadFile(strURL,
"D:TempFile.zip ")
Second Approch:
Dim securedPassword As SecureString = New SecureString
Dim _UserAgend As String = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36"
Dim username As String = "TestUser@Test.com"
Dim password As String = "123456"
client.Headers.Add(HttpRequestHeader.UserAgent, _UserAgend)
For Each c In password.ToCharArray()
securedPassword.AppendChar(c)
Next
client.Headers.Add(HttpRequestHeader.UserAgent, _UserAgend)
client.Credentials = New NetworkCredential(username, securedPassword) WebIntranet.DownloadFile(strURL,
"D:TempFile.zip ")
Both of the Approches didn’t work, they did not Donwloaded the File from the Sharepoint.
They only Downloaded the Authenticaton side and named it "File.zip"
Any help is welcomed
This question has not received enough attention.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Inspect the raw request first to see what responses you get. While yes we know authentication is needed. The raw responses should give low level clues as to what is needed.
– Nkosi
10 hours ago