public static void Grand <TSecuredDataObject, TOperation>([NotNull] TSecuredDataObject dataObject, [NotNull] TOperation operation, int?userID, int?groupID, DateTimeInterval interval) where TSecuredDataObject : class, ISecuredDataObject <TOperation> where TOperation : class, IFxDataObject { if (dataObject == null) { throw new ArgumentNullException("dataObject"); } if (operation == null) { throw new ArgumentNullException("operation"); } if ((userID == null && groupID == null) || (userID != null && groupID != null)) { throw new ArgumentException(Translations.PermissionsManager_Grand_One_and_only_one_of_parameters__userID__groupID__must_be_specified); } var doType = ObjectTypeHelper.GetObjectType(dataObject.GetType()); var p = new TblPermissions { OwnerUserRef = userID, OwnerGroupRef = groupID, CanBeDelagated = true, WorkingInterval = interval }; p.SetObjectID(doType, dataObject.ID); p.SetOperationID(doType, operation.ID); ServerModel.DB.Insert(p); }
public static void Delegate <TSecuredDataObject, TOperation>(int ownerUserID, [NotNull] TSecuredDataObject dataObject, [NotNull] TOperation operation, int?targetUserID, int?targetGroupID, DateTimeInterval interval) where TSecuredDataObject : class, ISecuredDataObject <TOperation> where TOperation : class, IFxDataObject { if (dataObject == null) { throw new ArgumentNullException("dataObject"); } if ((targetUserID == null && targetGroupID == null) || (targetUserID != null && targetGroupID != null)) { throw new ArgumentException(Translations.PermissionsManager_Delegate_One_and_only_one_of_parameters__targetUserID__targetGroupID__must_be_specified); } if (operation == null) { throw new ArgumentNullException("operation"); } var doType = ObjectTypeHelper.GetObjectType(dataObject.GetType()); var prm = GetPermissions(doType, ownerUserID, null, operation.ID); if (prm.Count < 0) { throw new SecurityException(string.Format(Translations.PermissionsManager_Delegate_, ownerUserID, operation.Name, dataObject.GetType().Name, dataObject.ID)); } var p = new TblPermissions { CanBeDelagated = true, OwnerGroupRef = targetGroupID, OwnerUserRef = targetUserID, WorkingInterval = interval, ParentPermitionRef = prm[0] }; p.SetObjectID(doType, dataObject.ID); p.SetOperationID(doType, operation.ID); ServerModel.DB.Insert(p); }
public static void Delegate <TSecuredDataObject, TOperation>(int ownerUserID, [NotNull] TSecuredDataObject dataObject, [NotNull] TOperation operation, int?targetUserID, int?targetGroupID, DateTimeInterval interval) where TSecuredDataObject : class, ISecuredDataObject <TOperation> where TOperation : class, IFxDataObject { if (dataObject == null) { throw new ArgumentNullException("dataObject"); } if ((targetUserID == null && targetGroupID == null) || (targetUserID != null && targetGroupID != null)) { throw new ArgumentException("One and only one of parameters (targetUserID, targetGroupID) must be specified"); } if (operation == null) { throw new ArgumentNullException("operation"); } var doType = ObjectTypeHelper.GetObjectType(dataObject.GetType()); var prm = GetPermissions(doType, ownerUserID, null, operation.ID); if (prm.Count < 0) { throw new SecurityException(string.Format("User {0} have no access to do {1} on {2} ID = {3}. Cannot perform delegation", ownerUserID, operation.Name, dataObject.GetType().Name, dataObject.ID)); } var p = new TblPermissions { CanBeDelagated = true, OwnerGroupRef = targetGroupID, OwnerUserRef = targetUserID, WorkingInterval = interval, ParentPermitionRef = prm[0] }; p.SetObjectID(doType, dataObject.ID); p.SetOperationID(doType, operation.ID); ServerModel.DB.Insert(p); }