我能想出通过全部股份迭代的机器上,并读取权限你最好的分享上有。
ManagementClass manClass = new ManagementClass(@"\\" +computerName [email protected]"\root\cimv2:Win32_Share"); //get shares
//run through all the shares
foreach (ManagementObject objShare in manClass.GetInstances())
{
//ignore system shares
if (!objShare.Properties["Name"].Value.ToString().Contains('$'))
{
//print out the share name and location
textBox2.Text += String.Format("Share Name: {0} Share Location: {1}", objShare.Properties["Name"].Value, objShare.Properties["Path"].Value) + "\n";
Int32 permissions = 0;
try
{
//get the access values you have
ManagementBaseObject result = objShare.InvokeMethod("GetAccessMask", null, null);
//value meanings: http://msdn.microsoft.com/en-us/library/aa390438(v=vs.85).aspx
permissions = Convert.ToInt32(result.Properties["ReturnValue"].Value);
}
catch (ManagementException me)
{
permissions = -1; //no permissions are set on the share
}
textBox2.Text += "You have permissions: " + permissions + "\n\n";
}
}
如果有人可以弄清楚如何获得别人对共享的权限,那将是惊人的。
感谢您的信息。运行Windows XP时可以参考Microsoft.HomeServer.SDK.Interop.v1吗? – 2011-06-03 15:01:58
我不知道答案,但我不这么认为。只要看看其他链接,他们应该给你足够的信息来完成你的任务。 – 2011-06-03 17:04:41
谢谢,我是abe按照我的回答收集每个共享上的权限 – 2011-06-03 19:25:00