Browser same origin policy no server but on local computer, same folder and sub folders - same-origin-policy

Situation
I find weired e that browsers don't recognize as same origin (so do not authorize to work together) two files I put into the same directory and sub dirs on a local drive. In fact is out of my comprehension why two files that are both into c:/mypath/ and are called main.html and insideiframe.html are an issue for browsers if they access, comunicate or get data or content from each other. I do understand the issue if they were one in adomain.com and the other in anotherdomain.com but in my own local drive and even into the same local directory... I would understand if the browser at runtime asked for user permission for accessing same dir and subdirs but completely locking any access, that's seems more like an overkill that a real need.
So the question is:
Is there any explication about why browsers in general don't recognize as secure the act of accessing file content loaded into iframes for files that are into the same localDrive/directory and relative /subdirectories?

Related

Hyperlink to a file in the current folder regardless of its location on the drive

Putting together a .doc file with a table of content with links to external files. The challenge is: how to make them so that it points to the given file in the current folder regardless of its location on the disk.
Context: I will be sending the set of files to another person, so I can't put the path on my machine, nor on a server since they will be working offline. They will be working on Remarkable device and I want them to be able to use the major overview file with the links to access each of the files, rather than having to browse the folders.

Share path between server and client (delphi) application

On my LAN I have 2 applications running in server/client mode developed with Delphi (but I don't think this is important).
On server PC (where run server application) there is a USB hard disk, this hard disk have many folder and subfolder shared on LAN.
Now I need to do this:
1. The server application must send to client application a shared folder (for example "d:\folder\subfolder\", then the client application must open this path to show the files (using explorer).
2. The user, using client application, must select a shared folder (for example "\SERVER\folder\subfolder\") and send this to server application, the server application must convert this path in local path (for example "d:\folder\subfolder\") and save it inside a database.
My problem is: is there a simple way to:
1. Convert the local path to remote path before send it to client se the client can open it easily?
2. Convert the remote path to local path before save it inside database.
NOTE: the main folder or main drive of shared hard disk can be change.
NOTE2: I'd like use IP address and not windows pc name if possible because it can be change.
I hope I explained.
Thanks
If I understand you correctly you want to acces some files that are inside some shared folder. Right?
If that is true then go and acces to these files unsing the network path which is formed in this manner
\\Networkedcomputer\SharedFolderName\Subfolder\...
where:
NetworkComputer is either a name of computer that is sharing that folder or its IP adress. I asume you are interested in using of IP adresses since you already have acces to that information from your other networked components.
SharedFolderName is the network name that was chosen when specific filder was set to be shared on the network. This name doesen't even have to be the same as the name of actual folder
Subolder can be any subfolder of the share folder
In order to get networked path to your shared folder you do need to know network name of the shared folder.
Perhaps you could even retrieve this information from SelectDirectory method which shows special dialog for selecting of directory, but I'm not sure if it does support networked folders. If not you could make use of OpenDialog.
NOTE: In any case when selecting the shared folder either with the use of SelectDirectory or OpenDialog you would need to go to that folder through Network Places (Network -> MyComputerName) and not directly through MyComputer.
But if you need to aquire the shared name for any local folder programatically I think you would have to go and read that information from registry as I'm not sure there is a specific API call for this.
EDIT: The answer on SO question below refers to several Delphi components that can be used for managing of Shared network resources. So I guess you could use to retrieve the network path for a shared local folder but I haven't tried them out.
How do I remotely obtain a system's network shares and connections?

Scan directory for file names in MVC

I'm developing a MVC5 web app, hosted through azure, that lets you manage your movies (it's just for myself at the moment). I'm trying to find a way to scan a local folder on the users pc for a list of file names. I do realise the security/permissions issues I might run into. I do not need the file uploaded, only the full file name.
It would work by the user being able to select a folder where they store their movies and it will take in all the file names, including the ones in any sub directories.
I tried a multiple file upload form but quickly ran into issues with the max request limit which I tried messing around with but it proved redundant in the end. I can settle for the user selecting multiple files but would rather it done the directory way.
I know this might prove impossible in the end but any help would be greatly appreciated.

How to store per-user temporary files?

I need to store some temporary files from my program sometimes, currently I use the AppData path which works. However, I have just been trying my program on a non Admin (guest) account on Windows. This is resulting in errors because Windows is refusing me access to the AppData folder.
What would be the most ideal path to use instead of AppData, that even a user with the lowest permissions can use?
I tried Googling this one because I am sure I have seen an article on the Microsoft website that lists the different paths and requirements needed but I can't find it.
Thanks
If you want to store temporary files then use a sub-folder in the temporary directory. Use GetTempPath to find out where this is.
Note that on all modern versions of Windows, this folder is a per-user folder and is not shared between different users. If you want a location that is shared between all users then you need the CSIDL_COMMON_APPDATA folder. However, as you have discovered, standard users do not have rights to write in the folder. The standard approach is for the installation program to create a sub-folder with a permissive ACL that allows sufficient write access for standard users.

How to find out the name of the common documents folder on a network machine

Given that I am executing an EXE file (D2006 app) on a machine across the network, how can I get the pathname to the commondocs folder on that machine, given that the EXE might have been invoked from a UNC shortcut or a mapped drive letter shortcut, and the platform of the remote machine is not necessarily known (but will be >= WinXP)?
The situation is where the client has a large number of dispersed machines, and they can't be bothered installing my app on all the PC's. So what they do is install the executable somewhere on the network and give everybody a shortcut to that. This already seems to suit them fine and there are no issues there.
At their request, I made the app read the settings from an INI file placed in the same folder as the executable. I can only assume they have configured things so that all the users can write to that folder so that the INI file can be saved back.
However, I want to change it so that the INI file is read and saved to somewhere in the commondocs folder tree on the remote machine, so that they don't need to provide write access to a Program files folder.
The machine that's running your program is the only machine you have access to. The machine where your program is stored is irrelevant. It's just a disk drive. It might not be running Windows. It might even be a NAS that's hardly running anything at all.
If the customer wants the common-documents folder of the file server to act as the common-documents folder for everyone on all the client systems, then get the sysadmin to configure a shared folder on the server and then configure the clients to use that remote folder as their common-documents folder. There is no special programming required on your part for that.
To get the common-documents folder of the machine your program is running on, you can call any of various API functions, including ShGetFolderPath. The CSIDL value you need is CSIDL_COMMON_DOCUMENTS. If you call SHGetKnownFolderPath instead, use FOLDERID_PublicDocuments.

Resources