473,804 Members | 3,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

determine network directory permissions

Can anyone point me to code samples that can get the permission set
for a network drive? I tried the FileInfo and DirectoryInfo classes
but they do not seem to list what I need.

Feb 12 '07 #1
1 1673
Do you need to get the permissions for a share or do you need to get the ACLs
for a mapped network drive?

In the latter case you should be able to do it using
DirectoryInfo.G etAccessControl ().

In the first case you can do it using WMI:

string machine = "MachineNam e";
ConnectionOptio ns co = new ConnectionOptio ns();
co.Impersonatio n = ImpersonationLe vel.Impersonate ;
co.EnablePrivil eges = true;

ManagementScope scope = new ManagementScope ("\\\\" + machine +
"\\root\\cimv2" , co);
scope.Connect() ;

ObjectQuery query = new ObjectQuery("SE LECT * FROM
Win32_LogicalSh areSecuritySett ing");

ManagementObjec tSearcher searcher = new
ManagementObjec tSearcher(scope , query);

ManagementObjec tCollection queryCollection = searcher.Get();
foreach (ManagementObje ct m in queryCollection )
{
string shareName = "\\\\" + machine + "\\" + m["Name"];
Console.WriteLi ne(shareName);

InvokeMethodOpt ions options = new InvokeMethodOpt ions();

ManagementBaseO bject outParamsMthd =
m.InvokeMethod( "GetSecurityDes criptor", null, options);
ManagementBaseO bject descriptor =
outParamsMthd["Descriptor "] as ManagementBaseO bject;

ManagementBaseO bject[] dacl = descriptor["DACL"] as
ManagementBaseO bject[];

foreach (ManagementBase Object ace in dacl)
{
ManagementBaseO bject trustee = ace["Trustee"] as
ManagementBaseO bject;
string domain = (string) trustee["Domain"];
string name = (string)trustee["Name"];

Console.WriteLi ne(domain + "\\" + name);
}
}
HTH, Jakob.

--
http://www.dotninjas.dk

"The ants are driving me crazy" wrote:
Can anyone point me to code samples that can get the permission set
for a network drive? I tried the FileInfo and DirectoryInfo classes
but they do not seem to list what I need.

Feb 13 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7230
by: Stanley J, Mroczek | last post by:
My disk was replaced and i reload all my software. I think that i named my computer best-si-01 instead of BEST-SI-01 and thats my error? Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details:...
1
6575
by: brian.oneil2 | last post by:
Is there a way to install this onto a network file share and allow a team to access it? I would say share a CD from a networked CD drive, but there are multiple CD's that would have to be inserted. TIA, Brian
2
5683
by: Peter O'Reilly | last post by:
I am experiencing difficulty access a mapped network drive in an ASP.NET application. While using the .Net framework v 1.1 implementation of System.IO.Directory.Exists(), it fails to recognize a mapped network drive. This is true if the path specified uses a mapped drive letter or is expressed as a UNC address. I have also tried the drive letter and UNC paths with and without trailing backslashes, respectively.
4
4509
by: Kim Kragh | last post by:
Hi. I've tried to save, move files from asp.net (using the FileInfo object). It works fine locally, but I can't make it work on network drives. I have granted the aspnet user all required permissions, but still with no luck. Should I tweak something else (policy or app setting)? Can I access a NAS box running Storage Server 2003 as an active directory user?
2
6066
by: Tom Wells | last post by:
I have a little file upload page that I have been able to use to successfully upload files to the C: drive of LocalHost (my machine). I need to be able to upload to a network drive from the intranet server. On the line: dirs = Directory.GetDirectories(currentDir) I get "Access to the path "\\les-net\les\Special Projects\ATSPDF" is denied." How do I get the GetDirectories command to user my user ID and password when it tries to hit the...
5
13307
by: Mitchell S. Honnert | last post by:
Is there a way, given the full path of a folder on a network, that one can programatically tell if you have Read access to that folder? I have an application where the user is able to select a number of search folders using the standard dialog control. There shouldn't be an issue with the search folder being on a local drive or a network drive. But if you don't have Read access to the folder, there's trouble. The user can see the...
2
8099
by: Jerad Rose | last post by:
I have a fairly simple C# console app which copies files from a network folder to a local folder. When the app resides on my local C: drive, it runs just fine. However, when the app resides on a network drive, copying the same files from the same source drive and to the same destination drive, it gives me the following exception: System.Security.SecurityException: Request for the permission of type...
1
3759
by: Raymond Du | last post by:
Hi, I try to use ASP.Net 2.0 FileUpload control to upload files. The page is working fine when I upload files and save them into my local computer, but fails when the files are to be saved to a network drive. I believe this is permission issue, the account on my local computer does not have permissions to write to network drive. Can someone tell me how resolve this problem? I already went to IIS and impersonate anonymous access...
1
1389
by: pxpilot | last post by:
HELP! I know there's a lot of urls out there, please don't reply with a link. I have tried them all but i guess i am missing something. I have 2 servers on the same network, my ASP.NET runs on Server1 and need to write RSS to a Server2 Something like this: Dim enc As Encoding = Encoding.UTF8 Dim objXMLTW As New XmlTextWriter("\\Server2\wwwroot\SiteRoot
0
9707
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10586
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6856
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.