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.
Related
we have a suite of applications which are add-ons to an enterprise product installed onto a windows server into the program files(x86) folder. The applications are written in c#. A share is created on the server allowing users to launch the applications in the installation folder either by terminal server or across the network.
The common settings for our applications are stored within a single xml file. Some of these settings only need to be read and are configured by a dedicated application that requires admin rights (as it also performs other functions such as scheduling tasks). Other settings need to be modified by various department managers to suit they way they want the applications to work and should not require admin access - but they need to be persisted in the same file as they are application rather than user specific.
I am somewhat confused with all of the available options for where the settings file might be stored (including special folders) such that admin access is not required to write to the file, yet the file location is accessible irrespective of whether the user is launching the application via terminal server, network share etc.
Is the program files folder the best option and just creating the necessary permissions on the share? Or is there a special folder for this scenario? If there is a special folder, what is the correct way to access it? (I did try this route, but kept finding the file was being created/updated on the user's local machine rather than the network file).
thanks
Matt
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
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 have developed an ASP.NET MVC 3 which must access to a SharePoint Remote Folder.
To do that, during the development, before to run the Visual Studio Development Server, I try to access to the remote folder. Then, I must introduce the credentials of the user who has permission to see the remote resource. After this, using the following code:
string path = #"\\tests.sharepoint.es\folder1";
DirectoryInfo di = new DirectoryInfo(path);
DirectoryInfo[] dis = di.GetDirectories();
The access to the folder is successful. However, this fails when I executed my web application from the IIS, getting the next error:
Access to the path '\tests.sharepoint.es\folder1\' is denied.
Even if I set for the Application Pool the same user that runs the Visual Studio Development Server, it continues failing.
I have identified that the users who runs the World Wide Web Publish Service (W3SVC) is SYSTEM (an account who obviously doesn't have permission to access to the folder) but I can't change this and I am not sure if this causes the problem.
Also, I have read some posts about using SPSecurity.RunWithElevatedPrivileges but I can't use it because my IIS server doesn't have Sharepoint installed (it is in another machine) and therefore, I can't use Microsoft.Sharepoint.dll as far as I know.
UPDATE: When I try to access to the resource using my windows explorer, I have read that OS uses WebDav instead of NetBios. Can IIS use this protocol to access to the resource?
If you really need to access remote resource with Windows permissions from Windows web server (or any other server that impersonates remote client) than you must run such code under account directly signed in on the server box. This is caused by "NTLM one hop" policy - user's credentials can be used only on machine user directly signed in to or machine user directly communicates to (and not on third one that this second machine tries to connect to).
Safest approach is to run process under account that have access to remote resource and run code in that process. You can run IIS process under such account, but you may need to revert impersonation back to process if running code during requests.
You can also directly impersonate particular user but you'll need to have plain text login information. This is most likely against security policy for most companies.
Note: you very well may end up building anonymization proxy - be very careful to understand what it means to access remote resource under account different from actual user's account.
Fortunately, I have found how to resolve the access problem.
I have used the solution described in this post.
My code seems like this:
PinvokeWindowsNetworking.connectToRemote(#"\\tests.sharepoint.es\folder1", "domain\user", "password");
//manage files and folders of my remote resource
//...
PinvokeWindowsNetworking.disconnectRemote(#"\\tests.sharepoint.es\folder1");
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.