public override InheritedFromInfo[] GetInheritSource(string objName, string serverName, bool isContainer, uint si, IntPtr pAcl) { object obj = SecuredObject.GetKnownObject(Community.Windows.Forms.AccessControlEditorDialog.TaskResourceType, objName, serverName); RawAcl acl = NativeMethods.RawAclFromPtr(pAcl); // Get list of all parents var parents = new System.Collections.Generic.List <object>(); object folder = obj.GetPropertyValue(isContainer ? "Parent" : "Folder"); while (folder != null) { parents.Add(folder); folder = folder.GetPropertyValue("Parent"); } // For each ACE, walk up list of lists of parents to determine if there's a matching one. for (int i = 0; i < acl.Count; i++) { } return(new InheritedFromInfo[NativeMethods.GetAceCount(pAcl)]); }
public SecuredObject(object knownObject) { // If just being passed a security object, grab it and stop if (knownObject is CommonObjectSecurity) { ObjectSecurity = knownObject as CommonObjectSecurity; } else { // Special handling for Tasks if (knownObject.GetType().FullName == "Microsoft.Win32.TaskScheduler.Task" || knownObject.GetType().FullName == "Microsoft.Win32.TaskScheduler.TaskFolder") { IsContainer = knownObject.GetType().Name == "TaskFolder"; TargetServer = knownObject.GetPropertyValue("TaskService").GetPropertyValue <string>("TargetServer"); } // Get the security object using the standard "GetAccessControl" method try { ObjectSecurity = knownObject.InvokeMethod <CommonObjectSecurity>("GetAccessControl", AccessControlSections.All); } catch (TargetInvocationException) { try { ObjectSecurity = knownObject.InvokeMethod <CommonObjectSecurity>("GetAccessControl", AccessControlSections.Access | AccessControlSections.Group | AccessControlSections.Owner); } catch { } } catch { } if (ObjectSecurity == null) { try { ObjectSecurity = knownObject.InvokeMethod <CommonObjectSecurity>("GetAccessControl"); } catch { } } if (ObjectSecurity == null) { throw new ArgumentException("Object must have a GetAccessControl member."); } // Get the object names switch (knownObject.GetType().Name) { case "RegistryKey": ObjectName = knownObject.GetPropertyValue <string>("Name"); DisplayName = System.IO.Path.GetFileNameWithoutExtension(ObjectName); break; case "Task": DisplayName = knownObject.GetPropertyValue <string>("Name"); ObjectName = knownObject.GetPropertyValue <string>("Path"); break; default: ObjectName = knownObject.GetPropertyValue <string>("FullName"); DisplayName = knownObject.GetPropertyValue <string>("Name"); if (ObjectName == null) { ObjectName = DisplayName; } break; } // Set the base object BaseObject = knownObject; } IsContainer = SecuredObject.IsContainerObject(ObjectSecurity); MandatoryLabel = new SystemMandatoryLabel(ObjectSecurity); }