Access a remote file using a SharePoint web part

I recently created a program that parses a remote file from \ some_server \ c $ \ directory \ file.xls , and it works fine on my local computer like a regular aspx page.

Then I placed the program in the web part of the form on my SharePoint VM server and I get this error: access to the path '\ Some_server \ with $ \ directory \ file.xls' is denied.

The file is split into Domain \ Authenticated Users , so I'm not sure why this will be rejected? Is it possible that my SharePoint is trying to call it with a local or network service account? How can I read it? Thank.

+3
source share
7 answers

The salamander is right, SharePoint does not work with trust to do this.

Change the trust level for SharePoint in it. web.config from WSS_Medium to Full is a quick fix, but there are security implications.

+3
source

Be that as it may, you may run into the classic release of NTLM Double-Hop. You can authenticate the front end, but since the front side does not have your password, it cannot then authenticate to the resource on another server.

Working with elevated privileges and setting permissions based on the application pool identifier can be one way to move forward.

+3
source

, RunWithElevatedPrivleges, SharePoint . , , . .

+2

, ?

, , SPSecurity.RunWithElevatedPrivileges . .

+1

SharePoint . .

0

, FULL TRUST, , SharePoint .

0

SharePoint, ? SPSecurity.RunWithElevatedPrivledges.

RWEP . SPSite SPWeb, SPContext ( SPContext.Current.Site), - . RWEP.

SPSecurity.RunWithElevatedPrivileges(() { (SPSite site = SPSite (SPContext.Current.Site.Url)) { (SPWeb web = site.OpenWeb()) { //... - SPWeb } } });

If you need to access a file from an external access point in order to update it using existing processes, you can use the file sharing path that is accessible to all SPDocumentLibrary, but choose "Actions" → "Open with Windows Explorer" to get network path.

0
source

Source: https://habr.com/ru/post/1698293/


All Articles