简体   繁体   中英

Why does new FileStream get access violation in REST service when path has IP Address?

Why does this get an access violation:

     using fs := new FileStream( fullFilename, FileMode.Open, System.IO.FileAccess.Read )

when the fullfilename is like "\\\\52.1.1.1\\d$\\temp\\file.bmp" and EVERYONE has access to the folder?

If the file is just "d:\\temp\\file.bmp", the FileStream can read it. There is something about the IP address part.

The language is Oxygene, but I'm not sure why that would make a difference. But it IS .Net. FWIW.

Guessing a lot here, but:

I guess your REST service is running in a webserver, like IIS? By default, Windows services run as the LocalService account . This " presents anonymous credentials on the network ".

"EVERYONE has access to the folder", you say, but " Contrary to popular belief, anyone who is logged in anonymously—that is, they did not authenticate—will NOT be included in the EVERYONE group. " .

(and why does EVERYONE have access to d$ - an administrative share, anyway?).

Your service has no access, and you need to make it pass some credentials to the share explicitly, or run in an IIS application pool as a credentialed account which can access the share.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM