We have an aspx page that needs to check if video files exist on our video server and display a link if the file does exist. However, our videos are not stored on the C drive, but on the D drive instead.
I have tried
System.IO.File.Exists(#"http://ourvideoserver/pcode/videofile_name.mp4") and
System.IO.File.Exists(#"\\ourvideoserver\\D:\\pcode\\videofile_name.mp4")
the last one was just taking a wild guess
And I cannot figure out how to check the files on a remote server on a different drive than C.
Could someone point me in the right direction on how to check in the D drive of the remote server
In UNC paths, drives are represented by a $. That is, D$. Try this:
System.IO.File.Exists(#"\\ourvideoserver\D$\pcode\videofile_name.mp4")
So, something like this should work (it does when I run it as a unit test with a change in the server name).
[TestMethod]
public void CheckUNCFileExists()
{
Assert.AreEqual(true, File.Exists("\\\\fileserver\\documents\\file.txt"));
Assert.AreEqual(true, File.Exists(#"\\fileserver\documents\file.txt"));
}
One thing that you might want to check is the name of the actual share, using an administrative command prompt on the file server (in my case it is the "documents" share):
C:\Windows\system32>net share
Share name Resource Remark
-------------------------------------------------------------------------------
C$ C:\ Default share
IPC$ Remote IPC
ADMIN$ C:\Windows Remote Admin
documents C:\documents
The command completed successfully.
If the path seems ok (and you can get to it with Windows Explorer), another thing to investigate is whether the application pool identity of your web application (probably you if you are debugging on your desktop using something like Visual Studio, or whatever your IIS admin configures on the web server side) has read access to the share (for windows sharing permissions) and read access (via NTFS permissions) on the folder/file (also, depending on how paranoid your admins are, you might also need "traverse" permissions on higher folders).
If you can't get to it with Windows Explorer, and you are using an administrative share (ex c$, d$, etc), you should re-share the folder with a different share name (since this will allow you to change permissions to make it readable by you/and the IIS application pool identity). If you are really bent on using the administrative share name, you'll have to modify permissions of the administrative share and may need to undertake something like this:
http://support.microsoft.com/kb/971277
Related
I have a very simple task on microsoft IIS (Which means 2 days of configuration hell)
I need to add a virtual directory that points to a different server (Shared folder).
I opened a user in the local and the remote servers and I can see the content of the folder, but when I try to copy something to that folder (from the code) I get access denied.
Of course that the user has a full control (shared and ntfs) but not matter what I'm doing I just can't make this simple task to work.
What have I missed? What should I do to make it work?
Thanks in advance - Tal.
The problem can be solved by changing the appPoolIdentity to a local windows user that has permissions to read\write to the network virtual folder.
The downside (at least from my experience) is performance, the IIS become slow very fast (30 online users in my case).
I was trying to browse a file(S:\Scalable Development\DRD_ToolPointManagement.doc) from shared location trough web browser using application. when I run my application in local, it is working where as if I push the code to dev and QA environment, not able to open a file
There are two different problems, firstly using a mapped drive and secondly access rights to the folder. Both of these depend upon which account the application is running under. Have a look at http://www.iis.net/learn/get-started/planning-for-security/understanding-built-in-user-and-group-accounts-in-iis
You need the built in group IIS_WPG which covers the application pool to have access to the network drive. If the S: drive is not mapped on the web server, you will also need to use the UNC path. If you look in Windows Explorer, your S: drive will appear something like
myshare (\\myserver) (S:) which should be translated to \\myserver\myshare\Scalable Development\DRD_ToolPointManagement.doc
Your domain administrator may need to allow access to the network share, and you may need to consider impersonation
When using the Web browser control, you're using the Internet Explorer. Thus, security settings may apply.
You need to change these in the Control Panel's internet settings of every machine you want to deploy to.
For example you may have to add the location to the trusted zone. Also, the target IE may not be configured to open Office documents in-place.
I have a Windows service that can't access an NFS share on a UNIX box. I can't access the share with the UNC path, so I have to have it mounted.
I have a console application that can see the drive and runs fine, but when I deploy my Windows service, it can't see the drive.
I have the drive mounted as my local user as well as the administrator.
I've tried mounting a drive from my application by using "Process.Start(mBatchFilePath);", but that didn't work either.
I'm running as the local user (set as administrator).
Tried using a symbolic link
Going to try to set up an FTP to transfer the files
Does anyone have any suggestions on how I can make this work?
SOLVED: I used SSH.Net and transfer files with an SFTP server
I don't think that mapping the drive to a symbolic link is a real solution. The Problem is, that the service runs under a certain user account and thus it accesses all resources with the privileges of this account. Of course your IT admin is right, it's not a good idea to let the service run under the local administrator account.
You should create a new user account that is allowed to access the shared folder. Then set up the service that it runs under this account and the service should be able to access the network share. But remember, a network share that is mapped to a drive letter is only mapped for the current user. So the service (that runs under a different user account) simply doesn't have any drive with this letter, it is not mapped under its account.
So in your service you should always access the share with its full UNC path and not with a mapped drive letter.
Since we were connecting to a Solaris server from a windows box I needed to use SFTP to send files to the server.
I contemplated some sort of a folder sync, but it wasn't a route I wanted to go down.
I used the SSH.Net libraries.
I need to query the file system of a remote workstation on a Windows domain. The program should search the remote file system for the existence of specific filenames and file paths. For example, assume I want to find out whether “c:\program files\mozilla\firefox.exe” or “c:\program files\chrome\chrome.exe” exists on any workstation in a domain of 10,000 machines.
What options I know:
1) Only C# code with windows impersonation using WIN32 API and using UNC path with Admin Share access like \ServerName\C$\FolderName.(I am not sure that we need to run the app from domain server to get workstation Admin Share access).
2) Using WMI with C# Management classes, get remote system access with Domain Admin credentials impersonation, then use query(s) to get the remote file information.
I have implemented both scenarios, but I am not sure which one best and performs well on real time. I have only tested with 2-3 systems network available with me.
I have questions in my mind.
1) Which option is best suits for the situation?
2) Which one is faster, safer and consistent?
Please suggest me one of those or any best option available for above requirement.
Thank You,
Ravi
No need to run this from a domain controller. With proper privs, you can run WMI queries from anywhere. In fact, pushing them to a DC would add a hop to the query and likely be slower than querying directly. If you have domain admin privs for the process, I'd just query directly to the unc path for the file existence check, and be done with it.
I have one service that will create a text file to local machine and then need to copy the same file to another server .
I am using " File.Copy(SourceFilePath, TargetFilePath, true);"
and getting an exception at the target file path "access denied. I am able to copy the files manually to that location ( TargetFilePath) .
any idea , what is going wrong ??
I don't have any network drive mapping with this target location.
Thanks in Advance
This is a classic permissions issue. You need to make sure that the service is running in the context of a user with the ability to copy files. Since you need to copy files around, I would suggest using a user that is in the Backup Operators group, although you might want something more restrictive for your scenario.
Edit: Since you're also copying to another server, your user will need to have rights on that server as well. For that purpose, you might run your service under a domain account (assuming your machines are both in a domain). You can also test by using the Run As... option on a console app with the same code - that way you can debug permissions issues before setting up the service.
The account that the service is running on must have access to the other machine.
From the source machine can you manually copy the files to the Target?
C:>Xcopy \sourcemachine\dir*.txt \TargetMachine\dir\ /Y/K/D/C
That should help you narrow it down if the problem is related to code or permissions.
If you're not running on a domain, your code can impersonate a user on the other machine that does have rights.