G
Guest
hi,
I am trying following code.
string fileObject = @"C:\Documents and Settings\myfolder\Temp.txt";
ManagementBaseObject ret = null;
ManagementPath path = new ManagementPath( );
path.Server = @"ServerName"; // Assuming that server name is server i am
trying to connect to
path.NamespacePath = @"root\cimv2";
path.RelativePath = @"Win32_LogicalFileSecuritySetting.Path=" + "'" +
fileObject + "'";
ManagementObject lfs = new ManagementObject(path);
// Get the security descriptor for this object
bool EnablePrivileges = lfs.Scope.Options.EnablePrivileges;
lfs.Scope.Options.EnablePrivileges = true;
// Dump all trustees (this includes owner)
string accountName, SID;
foreach (ManagementBaseObject b in lfs.GetRelated())
{
accountName= (string)b["AccountName"]; --I am getting error on
this line
SID = (string)b["SID"];
Console.WriteLine("Trustees {0} is {1}", b["AccountName"],
b["SID"]);
}
I am getting error on the line marked(--I am getting error on this line) in
above code. When i tried above code for local machine everything is working
fine.
Thanks in advance for help.
I am trying following code.
string fileObject = @"C:\Documents and Settings\myfolder\Temp.txt";
ManagementBaseObject ret = null;
ManagementPath path = new ManagementPath( );
path.Server = @"ServerName"; // Assuming that server name is server i am
trying to connect to
path.NamespacePath = @"root\cimv2";
path.RelativePath = @"Win32_LogicalFileSecuritySetting.Path=" + "'" +
fileObject + "'";
ManagementObject lfs = new ManagementObject(path);
// Get the security descriptor for this object
bool EnablePrivileges = lfs.Scope.Options.EnablePrivileges;
lfs.Scope.Options.EnablePrivileges = true;
// Dump all trustees (this includes owner)
string accountName, SID;
foreach (ManagementBaseObject b in lfs.GetRelated())
{
accountName= (string)b["AccountName"]; --I am getting error on
this line
SID = (string)b["SID"];
Console.WriteLine("Trustees {0} is {1}", b["AccountName"],
b["SID"]);
}
I am getting error on the line marked(--I am getting error on this line) in
above code. When i tried above code for local machine everything is working
fine.
Thanks in advance for help.