can we check folder permission on remote machine using c#.
Assuming the account used to execute your code has access to those folders then, yes.
You can use the GetAccessControl method of a DirectoryInfo instance.
If the folder isn't shared, you can always use the C share: \\somemachine\C$\program files
Related
I need to read and write(update) some remote machine file.I am able to find the remote file using WMI(System.Management) but not able to do read or updation on that.
Any help would be appreciated.
Thanks
Himanshu
The WMI doesn't have any class (or method) to read or write the content of files. You may only retrieve the metadata (FileName, Date, Size) of the files using CIM_DataFile, or do tasks like Copy, Rename, Delete or Compress files.
RRUZ is correct: WMI cannot copy or create files over a network. This is because it would require credential "hopping":
http://msdn.microsoft.com/en-us/library/windows/desktop/aa389288%28v=vs.85%29.aspx
However, a workaround was recently created by Stackoverflow.com user Frank White in C#, and the WMI logic ports directly to VBS. Here's his solution:
WMI remote process to copy file
I ported it to a fully working VBScript:
https://stackoverflow.com/a/11948096/1569434
First check your file access in premmisions and set user "Everyone" to Full Control
then try it again.
I have a batch file where I copy file from a different server. I have no issues running it on the server. But when I try to run it from a web application, the file does not copy. I keep getting access denied error. I have used xcopy, copy and robocopy.
I have provided full access to source and destination folder for all users.
No luck. Keep getting the same error :
copy /y \N01APW280\d$\Oracle\Middleware\user_projects\epmsystem1\diagnostics\logs\essbase\essbase_0\app\PLPLAN\PLPLAN.LOG D:\Hyperion\ERPI_Actuals_Load\Logs\
It is rather awkward to try and use a command-line utility, such as copy, from a web app; you should rather be using the programmatic abilities within your web application instead.
Aside from that, you main issue is that web apps are typically executed with very limited privileges, using local machine accounts that have no way of accessing administrative level shares on remote machines such as \N01APW280\d$. Another possible issue is that the local account that is being used by the web app cannot write to D:\Hyperion\ERPI_Actuals_Load\Logs\ folder. And finally, your app may have enough privileges to instantiate an external process such as copy.exe.
How can I fetch a list of files from local Windows share (that requires credentials)? Is there anywhere I can specify a username/password to authenticate to that share location? using talend.
I don't know if it's an option for you because you didn't provide many context information.
But you could use the tSystem component to execute a command like this :
net use x: \\share\some /user:username password
Then use the tFileList component in order to retrieve the files from that directory.
I think you can mapped shared drive on your machine(where you want to execute the Talend job) then used that mapped drive location to get the files.
I'm running a powershell script that's on my local PC on a file share that's on a server. I had code in the script to let the user select to delete something permanently (using Remove-Item) or to send something to the Recycle bin using this code:
[Microsoft.VisualBasic.FileIO.Filesystem]::DeleteFile($file.fullname,'OnlyErrorDialogs','SendToRecycleBin')
When run locally (either from my desktop, or from the server) against a folder that's local to that respective location, it works fine. A file that is identified gets deleted & immediately shows up in the recycle bin.
However, if run from my desktop to the file share, it deletes the file, but it doesn't show up in either the server's recycle bin or the local one either. I've tried UNC naming and mapped drive naming, and have come to believe this may be by design.
Is there a workaround for this?
Only files deleted from redirected folders end up in the recycle bin. If you want to be able to undelete files deleted across the network then you need to use a third-party utility.
I am trying to get a Perl scripts to access a file over UNC path using specified credentials. Is this possible? If not with Perl, what else could I use?
Thanks
-Jesse
Do you have to access many varied paths with differing credentials or just one?
As non-programming solution can you map the network share to a drive letter permananently in Windows before running your perl program?
Check out the module Win32::NetResource it has methods to allow you to connect to Windows network resources, such as drive shares and supply the credentials.
AddConnection(\%NETRESOURCE,$Password,$UserName,$Connection)
Makes a connection to a network resource specified by %NETRESOURCE