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.GetAccessControl().
In the first case you can do it using WMI:
string machine = "MachineName";
ConnectionOptions co = new ConnectionOptions();
co.Impersonation = ImpersonationLevel.Impersonate;
co.EnablePrivileges = true;
ManagementScope scope = new ManagementScope("\\\\" + machine +
"\\root\\cimv2", co);
scope.Connect();
ObjectQuery query = new ObjectQuery("SELECT * FROM
Win32_LogicalShareSecuritySetting");
ManagementObjectSearcher searcher = new
ManagementObjectSearcher(scope, query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject m in queryCollection)
{
string shareName = "\\\\" + machine + "\\" + m["Name"];
Console.WriteLine(shareName);
InvokeMethodOptions options = new InvokeMethodOptions();
ManagementBaseObject outParamsMthd =
m.InvokeMethod("GetSecurityDescriptor", null, options);
ManagementBaseObject descriptor =
outParamsMthd["Descriptor"] as ManagementBaseObject;
ManagementBaseObject[] dacl = descriptor["DACL"] as
ManagementBaseObject[];
foreach (ManagementBaseObject ace in dacl)
{
ManagementBaseObject trustee = ace["Trustee"] as
ManagementBaseObject;
string domain = (string) trustee["Domain"];
string name = (string)trustee["Name"];
Console.WriteLine(domain + "\\" + name);
}
}
HTH, Jakob.